MATLAB / Simulink on BeagleBone Black

转自:beagleboard@googlegroups.com邮件组

作者:kevind

 

I have MATLAB / Simulink working with BeagleBone Black.  I'm posting the instructions here in case anyone else might find it useful.

I'm using it with the audio cape, so these instructions include how to make the alsa sound Simulink blocks work. I haven't tried using HDMI audio; if you want to do that it might require a different alsa configuration.
 
BeagleBone Black Configuration:
 
You'll need to boot your BeagleBone to Ubuntu with a current image, anything prior to kernel 3.8.13-bone31 won't work with the Audio Cape. 
 
I used this one for uSD card:
and this one for eMMC:
 
decompress with 7zip, and write to uSD card with Win32 Disk Imager:
 
Boot to the SD card (requires holding down the button near the uSD card slot while applying power).
If you use the eMMC flasher, wait 10 minutes until LEDs all come on steady, then reboot without the uSD card.
 

# create a swap file (I used 512MB for booting from internal eMMC, use larger if booting from uSD card)
sudo su
mkdir -p /var/cache/swap/
dd if=/dev/zero of=/var/cache/swap/swapfile bs=1M count=512
chmod 0600 /var/cache/swap/swapfile
mkswap /var/cache/swap/swapfile
swapon /var/cache/swap/swapfile
# set the swap file to load on boot by adding an entry to /etc/fstab:
nano /etc/fstab

/var/cache/swap/swapfile    none    swap    sw    0   0

# install required packages
apt-get update
apt-get install build-essential libsdl1.2-dev mplayer espeak alsa-utils
wget -P /var/lib/alsa  http://beagleboardtoys.info/files/BeagleBoneAudio/asound.state
 
# set up build environment
mv /usr/include/sys/asoundlib.h /usr/include/arm-linux-gnueabihf/sys
rmdir /usr/include/sys
ln -s /usr/include/arm-linux-gnueabihf/sys /usr/include/sys
ln -s /usr/include/arm-linux-gnueabihf/asm /usr/include/asm
ln -s /usr/include/arm-linux-gnueabihf/bits /usr/include/bits
ln -s /usr/include/arm-linux-gnueabihf/gnu /usr/include/gnu
 
# test sound output if using the audio cape
# run alsamixer, and crank up the levels on "PCM" and "HP DAC", or you won't hear anything
alsamixer
# test that sound comes out, run 2X because sound ramp-up is delayed
aplay /usr/share/sounds/alsa/Front_Left.wav
aplay /usr/share/sounds/alsa/Front_Right.wav
# test with mp3 file if you have one
mplayer xxxxxxxx.mp3
 
 
MATLAB Configuration:
 
1) install the BeagleBoard target.  For R2012A/B, run "targetinstaller".
 
2) run "xmakefilesetup" 
 
For R2012B, set "Template" to "gmake_remotebuild" & "Configuration" to "LinuxRemoteBuild"
For R2012A, set "Template" to "beagleboardgmake" and "Configuration" to "BeagleBoard"
 
On the "Compiler" tab, set "Arguments" to "-c -mfloat-abi=hard"
 
3) in your Simulink model, select "Tools -> Run On Target Hardware -> Options"
 
Select "Run On Target Hardware", then:
 
"Target Hardware" is "BeagleBoard"
 
"Enable External mode" should be checked, and port set to "17725"
 
For "Host name", enter the IP address of your BeagleBone
For "User name", enter "Ubuntu"
For "Password", enter "temppwd" (or current password if you changed it)
For "Build Directory", enter "/home/Ubuntu"
 
3) In your Simulink model, if you use the ALSA audio blocks, leave the device name set to 'default'
 
 
4) Run your model using "Tools -> Run On Target Hardware -> Run"
 
MATLAB will generate C code from your Simulink model, send it to the BeagleBone, build the code on the BeagleBone, then run the code on the BeagleBone.  You can adjust parameters in your model while it runs (i.e. move a slider or type in a new value), and the new values will be sent to the BeagleBone.

转载于:https://www.cnblogs.com/catmelo/p/3500455.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值