• 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.
  • 相关阅读:
    mybatis自动生成代码配置文件
    Struts2的类型转换器
    CSS布局自适应高度终极方法
    Winform WebBrowser控件对访问页面执行、改写、添加Javascript代码
    利用using语句解决Lock抛出异常时发生死锁的问题
    Flash与Silverlight终极大比拼
    System.Collections.Specialized.NameValueCollection PostVars
    Hook浏览器控件WebBrowser对WININET.dll的调用
    WebBrowser中打开新页面保留sessionid
    Linksys路由器自动重启加流量
  • 原文地址:https://www.cnblogs.com/catmelo/p/3500455.html
Copyright © 2020-2023  润新知