3.7 | 12 ratings Rate this file 449 Downloads (last 30 days) File Size: 15.3 KB File ID: #40313
image thumbnail

Simulink Support Package for Raspberry Pi Hardware



07 Mar 2013 (Updated )

Credit-card sized, low-cost, single-board computer with audio and video input/output

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information

Installer file for Simulink Support Package for Raspberry Pi Hardware. For more details on capabilities for this support package, please visit:


Opening the .mlpkginstall file from your operating system or from within MATLAB will initiate the installation process for this Hardware Support Package and acquire the latest support package available for the release you have.

This .mlpkginstall file is functional for R2013a and beyond.

If you are having issues with network connection to the Raspberry Pi, please see this Support Solution and related PDF document: http://www.mathworks.com/support/solutions/en/data/1-LTA2JJ/

Required Products Simulink
MATLAB release MATLAB 8.1 (R2013a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (72)
23 Feb 2015 Murat Belge

@Bip: Raspberry Pi support package is not available for MAC.

Comment only
12 Feb 2015 Bip

Bip (view profile)

Hi, I need this support package for 64-bit Mac Matlab R2013a. Is this available? This file should be named 'Windows 32-bit,64-bit Simulink Support Package for Raspberry Pi Hardware'. I'll add the tags.

Comment only
11 Feb 2015 abroug dhouha

I just installed the Support Packages for raspberry pi b+,now i want to test it by using the simulink support package on a simple application as a led controlling but i don't know how to use these package to control ( on/off)the led. can you help me please
thank you

Comment only
03 Feb 2015 Murat Belge

@Valmir: Just re-install the support package. The file containing Rasperry Pi firmware (raspberrypi_firmware_r2014a.zip) will be downloaded again as part of re-install.

Comment only
02 Feb 2015 Valmir Sadiku

Im using Matlab 2014b and when I try to install the Simulink Support Package for Raspberry Pi I get this error:

Error installing third party software Raspbian Wheezy:
Error executing command
"unzip('C:\MATLAB\SupportPackages\R2014b\downloads\raspberrypi_download\raspberrypi_firmware_r2014a.zip', 'C:\MATLAB\SupportPackages\R2014b\raspbian')"
Invalid zip file "C:\MATLAB\SupportPackages\R2014b\downloads\raspberrypi_download\raspberrypi_firmware_r2014a.zip".

It seems that the "raspberrypi_firmware_r2014a.zip" file is corrupt.
Does anyone know what the solution for that?

Thank you!

Comment only
01 Feb 2015 SST

SST (view profile)

I am using R2014b with the Pi B+ and I am trying to use Matlab with the Cirrus Logic audio card.

How do I set up the rasbian image to add matlab + simulink support to a raspbian image with version 14.2.0 of the support package?

Many Tanks

Comment only
26 Jan 2015 Murat Belge

@ESA & @junaid: Try the firmware download now. It should be working.

The download issue was caused by a stale file in our servers. It affected only R2013a and R2013b releases.

Comment only
25 Jan 2015 ESA

ESA (view profile)

@junaid: I have the same problem. @Murat Belge:2013b

Comment only
22 Jan 2015 Murat Belge

@junaid: Which MATLAB release are you on?

Comment only
21 Jan 2015 junaid

junaid (view profile)

while updating support packages i select respberry pi and whan i click on download i get this error again and again"firmware error.wait a couples of minutes and try again" help me to solve this error,,,,thanks :)

21 Jan 2015 junaid

junaid (view profile)

how to fix firmware error in matlab "firmware downloading error.wait a couple of minutes and try again in couple of minutes" while updating support packages for raspberry pi

Comment only
01 Dec 2014 Murat Belge


You can re-compile the generated code with -pg flag if you have an Embedded Coder license. Without an Embedded Coder license, it is not possible to change the build flags.

Comment only
27 Nov 2014 Lucas

Lucas (view profile)

Is it possible to compile the generated code on the RPi using gcc with custom flags (such as -pg for profiling)?

Thank you.

Comment only
13 Nov 2014 Carlos Moran  
12 Nov 2014 Rutuja Chavan

@Murat Belge
I am working on raspberry pi from last 6 month. Recently i started working on raspberry pi with matlab simulink. I have R2013a matlab version. I want to access my raspi through command window of matlab. But i am getting error. Basically i want to try camera interfacing with raspi and want to perform some operations on those images through matlab.
Is there any way to access raspi through command line interface in matlab.
basic commands are working for e.g.
h = raspberrypi(ipaddress of pi)
these commands are working
but following commands are not working
system(h, 'ls -al /home/pi')
I got error message as
Error using system Argument must contain a string.
I have gone through your comment about rapberry pi. But i don't have matlab 2014 version.
help me if you can

Comment only
17 Oct 2014 Brian McKay

Brian McKay (view profile)

@Bob: We are working on Mac and Linux versions of this support package. We'll be releasing those once they are fully completed.

Comment only
16 Oct 2014 Bob

Bob (view profile)

Please rename this "Windows Simulink Support Package for Raspberry Pi Hardware" until such time as it is more general. Thanks!

Comment only
06 Oct 2014 Thierry

Being able to use a *nix platform to target a *nix platform will be great

Comment only
26 Sep 2014 Murat Belge

sky1991: Do you have access to MATLAB R2014a? The Rasbian image used in R2013a support package for Raspberry Pi does not support Model B+ boards as this board was not available back then. We recently updated the R2014a support package to support Model B+ boards.

If you do not have access to R2014a MATLAB, you need to load a Raspbian Wheezy image to your board outside of MATLAB and make necessary modifications to the Rasbian image for Simulink compatibility.

Follow the getting started guide for Raspberry Pi to boot your board with Raspbian Wheezy: http://www.raspberrypi.org/help/quick-start-guide/

After booting the board, login to your board using a monitor and a keyboard and execute the following on a Linux shell:

$ sudo apt-get update
$ sudo apt-get install ibsdl1.2-dev alsa-utils espeak x11vnc guvcview i2c-tools libi2c-dev ssmtp ntpdate git-core v4l-utils cmake
$ cp /etc/ssh/sshd_config /home/pi/sshd_config.new
$ echo -e "\\n\\n# Turn off reverse DNS lookup\\nUseDNS no\\n" >> /home/pi/sshd_config.new
$ sudo mv /home/pi/sshd_config.new /etc/ssh/sshd_config

At this point reboot your board:
$ sudo shutdown -r now

After your board boots, launch MATLAB and test connectivity to your board:

>> h = raspberry_pi('<your board's ip address>')
>> h.connect

At this point you should see connection successful message on the MATLAB command line. Once you verify that connection is fine, you can start using your board with Simulink.

Comment only
25 Sep 2014 sky1991 matlab

Hello friends. I am new to Raspberry Pi B+ and simulink(I am Using MATLAB 2013a). I have downloaded and made the SD card according to intrunction in MATLAB Tutorial https://www.youtube.com/watch?v=akD1O49JbqY. But when I power on the Raspberry Pi B+ it just show red power LED and Green LED blinks only once .I tried by using connection check but its not working. Please help me out

Thanks in advance.

16 Sep 2014 Thierry

Any hope from January plans for Linux?
"10 Jan 2014
Murat Belge
We are looking into Linux/Mac support."

Comment only
05 Sep 2014 Murat Belge

Version 14.1.2 of the MATLAB Support Package for Raspberry Pi Hardware has been released. The updated support package contains full support for the new Raspberry Pi Model B+ board.

Comment only
15 Jul 2014 Murat Belge

Ravikiran: The Raspbian image that comes with Simulink Support Package for Raspberry Pi hardware is customized to work with Simulink features. You can find a comprehensive list of customizations in the comments section below. If you apply these customizations to your existing Raspbian image, you do not need to install our Raspbian image.

Here is the list of customizations:

Following Linux packages are installed on top of the base image: libsdl1.2-dev, alsa-utils, espeak, x11vnc, guvcview, i2c-tools, libi2c-dev, wiringPi, ssmtp, ntpdate.

Following additional modifications have been done:
* Add user "pi" to video group: "sudo usermod -a -G video pi"
* Load i2c module in /etc/modules (add line "i2c-dev")
* Comment out blacklisted items "spi-bcm2708" and "i2c-bcm2708" in /etc/modprobe.d/raspi-blacklist.conf
* Create /etc/modprobe.d/uvcvideo.conf and enable UVCVIDEO quirks
* Enable SSH using raspi-config
* Enable medium level overclocking using raspi-config
* Enable writing IP address configuration to the FAT partition of the SD card
* Enable speaking IP address when the board boots (/etc/rc.local)
* Turn off reverse DNS lookup for SSH (/etc/ssh/sshd_config)
* Set time zone to New York

Comment only
13 Jul 2014 Ravikiran B A

Is there any way to download and install just the support package and SDL, skipping the Raspbian altogether?
I have a slow connection and it takes forever to download the Linux image (which I already have from the RasPi site anyway).
Any suggestions would be appreciated!

Comment only
18 Apr 2014 Dan Lluch

Dan Lluch (view profile)

@J - this is available for R2013a and beyond only - that is why it isn't showing up.

Comment only
17 Apr 2014 J

J (view profile)

I have matlab R2012a that I downloaded through school's license. I'm trying to install the simulink pkg for raspberry pi and i'm having trouble fining the pkg.

When you run the targetInstaller and access install or update from the internet, I only see arduinos, beagleboard and legomindstorm.

When I try to access the pkg that i downloaded by using the 'folder' method it says it can't be found.

Any suggestions?

Comment only
19 Mar 2014 Murat Belge

For those who are interested in using the Raspberry Pi camera board, the R2014a MATLAB Support Package for Raspberry Pi hardware provides a command line interface to capture images from the camera.

Comment only
19 Feb 2014 Murat Belge

For those who want to use Raspberry Pi Camera Board with Simulink:

The latest release of the Raspbian Wheezy image has V4L2 drivers for the Camera Board. This means that you can use the V4L2 Video Capture block in the Simulink block library for Raspberry Pi to capture images from the Raspberry Pi Camera Board. Here are the instructions:

1. Upgrade your Raspbian image to the latest to get the official V4L2 driver for Camera Board:

# sudo apt-get update
# sudo apt-get dist-upgrade
# sudo rpi-update

2. Reboot

# sudo reboot

3. After reboot, execute the following command to load the V4L2 driver for the Raspberry Pi Camera:

# sudo modprobe bcm2835-v4l2

After this step, you should see a /dev/video0 device (check by "ls -al /dev/vid*") that corresponds to the Camera Board. Now use the V4L2 Video Capture Block to capture images from this video device.

Note that you need to perform step 3 above every time you reboot your board. You can incorporate the command in step 3 into "/etc/rc.local" to automatically load the V4L2 driver at boot time.

Comment only
17 Feb 2014 Neil

Neil (view profile)

Hello, I've finally figured it out. All of the source files are native to the Pi on it's ext file system. You can implement linux commands on the RPi using the h=raspberrypi; connection object.

Also there are third party programs such as WinSCP which will allow you to establish a connection with the RPi to give you a windows explorer-like interface where you can drag and drop files.

Once I figured this out, I've come to realize how powerful this is. We get the native flexibility of the RPi with the added power of loading SIMULINK models. Thank you.

Comment only
16 Feb 2014 Neil

Neil (view profile)

14 Feb 2014 Neil

Neil (view profile)

Hi, I was wondering, does anyone know where the headers are located? I looked in all the source directories and they don't have any of the .h or .c files the RPi is able to call.

Comment only
10 Jan 2014 Murat Belge

We are looking into Linux/Mac support.

Comment only
25 Dec 2013 Marcin Majda

Without Linux support it's useless. Is there plans to publish *nix version?

24 Dec 2013 Francesco Caminiti

Thanks Murat Belge you were right, I had to start Matlab on "administrator mode", I finally installed the support package ;) thanks again =)

Comment only
23 Dec 2013 Murat Belge

Francesco: Can you start MATLAB in "Administrator" mode and try the firmware update portion of the targetinstaller again? Your problem looks like an issue with permissions to query the removable drives.

Comment only
20 Dec 2013 Francesco Caminiti

Hi guys! I have a problem when I try to install support package for my Raspberry. I have installed on my Windows 7 (64bit) laptop Matlab R2013a: on Matlab command window I wrote " targetinstaller " and I followed all steps, but after I updated the firmware I get an error in the " Configure Network " step. I chose " Local area or home Network ", "next" after this I get this error " Error while querying removable drives ". At this time do I have to turn on the board and connect it with ethernet cable? I have a new SD card (8 GB Sandisk) for this support package so it's empty. Please I need help ;)

Comment only
14 Nov 2013 Kyler

Kyler (view profile)

Not useful if this can't be used on Mac/Linux.

14 Oct 2013 Brian McKay

Brian McKay (view profile)

Zhao, try looking at this File Exchange entry which provides a receipe for adding additional IO to support packages?

Comment only
12 Oct 2013 Zhao

Zhao (view profile)

this package includes ten functions that has no serial io function,how to add it to the package

Comment only
05 Oct 2013 Simon

Simon (view profile)

Is there any news on when the RPi support will arrive for Mac/Linux?

Comment only
26 Aug 2013 Murat Belge

Just double click on it. If you have a MATLAB installed it should be opened by MATLAB.

Another way to install the Raspberry Pi support package is to start MATLAB in administrator mode and run "targetinstaller" on the MATLAB command line.

Comment only
22 Aug 2013 Sebastian D'Amico

Sorry for the stupid question guys... but I don't know how to open the raspberrypi.mlpkginstall file within the zip file. Could you help me pls?

Comment only
07 Aug 2013 Murat Belge

RAJ: Is the download location for the firmware a UNC path? Try donwloading the firmware to a location in your local drive. Example: "C:\raspberrypi\firmware". Can you post what your download path was set to?

Comment only
06 Aug 2013 RAJ VIGNESH

When I try to download the firmware for raspberry pi, it gives an error telling "Firmware decompression error: Could not find the path specified". But the download completed properly. Please help.

Comment only
30 Jun 2013 RED STONE  
13 Jun 2013 Hugo

Hugo (view profile)

Sorry for the answer delay Murat. I will see if I can show you the model because is a university project and I dont know if my team allows it. If yes I will contact you ;) thanks

I want to have output sounds by GPIO but I think that will be impossible due to my sample time of 48000. I test the ports with a simple square at that frequency wave and a oscilloscope, and the PINS coul not output a steady frequency. :\

Another thing that I do not understand was the input audio block. If the raspberry does not have input sound ports how simulink have an input sound block? I think that for beginners the documentation could be better...

Comment only
11 Jun 2013 Murat Belge

Hugo: Can I have your Simulink model? This looks like a bug. I'd like to make sure it is fixed.

Comment only
08 Jun 2013 Hugo

Hugo (view profile)

I figure it out the problem about the sound. I fix it and the sound is now quite nice :D However, through other outputs the sound could be better? Like HDMI?

Another point, in my model I have 3 sounds outputs. I wanna that this 3 data sets go to the GPIO pins to control each one individualy. I try a simple model including a sine wave, a relay, a data conversion to boolean and a GPIO pin. No problem, I sent the model to raspberry.

When I test with my model an error occured and said to contact Mathworks. The error was: "Unexpected or internal error encountered in "in CGIR: b:\matlab\src\cg_ir\util_cg\cg_sanity_checker.cpp line 411: sanityCheckLValue: expression producing non-pointer type used in L-value context
". Please report this to MathWorks if you can cause it to recur".

Erro print from my workspace: https://feupload.fe.up.pt/get/nHLDjoC8w5137mK

My output is a vector with 32 samples from -1 to 1. I use the following blocks to peform the conversion to GPIO pin: relay, data conversion to boolean and a unbuffer. Could you help me Murat? :\

Thanks again

Comment only
08 Jun 2013 Hugo

Hugo (view profile)


this sample rate, in fact little fast, is the output of a much complex system that I have been working. I simply passed to raspberry and after some time the sound simply stop. I had not thought about the sample rate but it solves my problem regarding the sound stop and noisy! And thanks for the tip of speed/work improvement :D

Yes you are correct, the range is 2^15. I put it wrong.

Now I need to improve the sound quality. In my system I work always with a sample time of 48000 so I cannot improve more to obatin more precision on the output wave. The wave is also a combination of many frequencies. Another option could be improve inside the raspberry. With the conversion to 16 bits, the sound quality, which is normal, is not so good. So I search for a while and I can use the sound either by, 3.5mm jack, HDMI or a output sound card via USB. Using another port is possible to have better sound quality or the ALSA block and its 16bits limit me to the sound that I have now? I wanna try if I can have a similar sound like I listen when I run my model on my PC.

Thank you Murat for your help, really! ;)

Comment only
07 Jun 2013 Murat Belge


I think the crackling / popping sound is originating from the fact that the sample rate of the model (32/48e3) is too fast for the Linux OS to keep up. It is strange that the ALSA driver itself does not report any underruns. In any case, I changed the frame size going out of the Sine Wave block to 256 that got rid of the problem.

There is one more issue in your model in that the input to the ALSA Audio Playback function must be a signed int16 which means that samples are in the range [2^15, 2^15-1). Your MATLAB code was scaling the samples to 2^16-1.

Finally, you do not need to use a MATLAB function to scale the sine wave. Change the amplitude of the Sine Wave block to 32000 and use a Data Type Conversion block to convert the output to int16. Get rid of the MATLAB function block. Note also that adding the Data Type conversion block before matrix concatenation reduces the amount of work CPU is doing by half when doing data conversion.

Comment only
07 Jun 2013 Hugo

Hugo (view profile)

06 Jun 2013 Hugo

Hugo (view profile)

Murat Belge thank you for the response. I really need help on this :X

I put some other blocks on the model to ajust the signal for the ALSA block, the 2xN matrix int16 type.

it is better if you download the model. Thus I avoid get you wrong about what I tried. Link for download: https://feupload.fe.up.pt/get/To2nmpnz87UDsQ3

The output sound from raspberry comes from 3.5mm jack to a normal speakers (TEAC powermax 80/2). I can tell you that the sound goes noisy in less than 1 minute (I tested again before write this comment)

I do not have too much feedback on raspbeery to deal with this and I don't know if the problem is mine or some other thing inside the firmware.

I wait for response ;)

Comment only
06 Jun 2013 Murat Belge

I need some information to reproduce the issue you are facing.

1. What is the parameters of the sine wave block (samplet time, amplitude, etc.)?

2. What is the sampling rate of the ALSA Audio Playback block?

Comment only
05 Jun 2013 Hugo

Hugo (view profile)


I have been testing the raspberry support package but I found some problems during the simulation on the hardware.

the problem is related with the sound output on 3.5mm jack and the model itself. My glitch is easy viewed on a simple model with a sine wave and the ALSA playback audio block. When I simulate on Matlab2013 on a PC it is OK during the time I want. However, when I pass to raspberry, the simulation run for a couple of seconds (the sound is normal) and after it, the output sound is noisy :\

Why this happens? For me project I need a standalone program always running on raspberry and constantly output a sound (via 3.5mm jack or another)

Please help :X


Comment only
28 May 2013 Murat Belge

Right click on the MATLAB icon or the MATLAB entry in the start menu and choose "Run as administrator" option.

Comment only
28 May 2013 Chase

Chase (view profile)

How do I put it in administrator mode to fix the "unable to query removable devices" error? Thanks.

Comment only
05 May 2013 Hrvoje Bosnjak

no linux support

23 Apr 2013 fabrice

Hi Murat Belge
you are right, after putting in administrator mode , it is working

Comment only
23 Apr 2013 Murat Belge

Joshua: The new Raspian Wheezy image is based on "2013-02-09-wheezy-raspbian.zip".

Following Linux packages are installed on top of the base image: libsdl1.2-dev, alsa-utils, espeak, x11vnc, guvcview, i2c-tools, libi2c-dev, wiringPi, ssmtp, ntpdate.

Following additional modifications have been done:
* Add user "pi" to video group: "sudo usermod -a -G video pi"
* Load i2c module in /etc/modules (add line "i2c-dev")
* Comment out blacklisted items "spi-bcm2708" and "i2c-bcm2708" in /etc/modprobe.d/raspi-blacklist.conf
* Create /etc/modprobe.d/uvcvideo.conf and enable UVCVIDEO quirks
* Enable SSH using raspi-config
* Enable medium level overclocking using raspi-config
* Enable writing IP address configuration to the FAT partition of the SD card
* Enable speaking IP address when the board boots (/etc/rc.local)
* Turn off reverse DNS lookup for SSH (/etc/ssh/sshd_config)
* Set time zone to New York

Comment only
23 Apr 2013 Murat Belge

Fabrice/Leonardo: Did you start MATLAB in administrator mode?

Comment only
22 Apr 2013 fabrice

same for me
"unable to query removable devices"
on win7 or win8
any idea ?

Comment only
21 Apr 2013 Leonardo

Hi. I've been unable to complete my installation. It always stops with the same message: "unable to query removable devices", after the firmware download.
I'm running release 2013a with a Windows 8 Pro operating system. Any sugestions?

Comment only
20 Apr 2013 Joshua Hurst


It appears WiringPi has been added to this image?

Where can you find the updates that have been done to this image since the last one? Just curious what other things have now been included.

Thanks! Josh

Comment only
20 Apr 2013 Joshua Hurst

Thank you! I've spent hours trying to figure out why my new Rpi was not working!


12 Apr 2013 Murat Belge

We updated the firmware image for Raspberry Pi using the latest release of Raspbian Wheezy (base image 2013-02-09-wheezy-raspbian.zip). If your Raspberry Pi Model B has a Hynix memory chip (the black square RAM chip right in the middle Raspberry Pi board) and you are having difficulty booting your board, try the new firmware image. Launch "targetupdater" utility on MATLAB command line and follow instructions to update the firmware of your Raspberry Pi.

The firmware image uses 2 GB of the SD card. After booting your board with the new firmware, run "raspi-config" utility on your board and select "expand_rootfs" option to expand the firmware image to fill the rest of the SD card.

Comment only
02 Apr 2013 Murat Belge

We are looking into MAC/Linux support. Anybody else who wants Raspberry Pi support package to be available on MAC/Linux?

Comment only
28 Mar 2013 Magnus

Magnus (view profile)

Nice! Will this become available for linux or mac platforms as well?

Comment only
12 Mar 2013 Murat Belge

If you are having issues with updating the firmware of your Raspberry Pi, take a look at the following installation and troubleshooting guide: http://www.mathworks.com/support/solutions/attachment.html?resid=1-LUYRC0&solution=1-LTA2JJ

Comment only
12 Mar 2013 Murat Belge

Attach a pair of speakers or headphones to the analog audio port of the Raspberry Pi board to hear Raspberry Pi speak its IP address when it boots. If you do not have a monitor connected to the Raspberry Pi board, this feature may come in handy.

Comment only
11 Mar 2013 Joachim Schlosser

Works like a charm.

09 Mar 2013 Michael Lundgren

The pinmap for GPIO blocks is a nice touch.

08 Mar 2013 Tanya Morton

If the above URL doesn't work for you, then try http://www.mathworks.com/academia/raspberry-pi/

Comment only
13 Mar 2013

Fixed URL

20 Sep 2013

-updated thumbnail and description text

17 Jan 2014

no change - upgrading hardware support package download action

Contact us