2015年1月8日 星期四

Intel Edison mini breakout board w/ MPD

This document would give a guide for playbacking flac or music file on Intel Edison with external usb DAC. Please understand that, I would not give all commend because i wrote this guide after my task done.


I would use Burson Conductor as a target device, it adept with c-media cm6631a usb receiver chip.






Requirement

HW requirement:
  1. Intel Edison mini breakout board
  2. otg usb micro b male to type B (usually dac with type b input)
  3. dc power core (7~15v)
  4. optional : wifi i-PEX connect line
SW requirement:
  1. Linux operation (Ubuntu or Debian is better for operation consistence.)
  2. other SW would be found in apt-get.

Before-guide

In this guide, if start from “#”, it mean comment on your host. If it start with “$”, it mean commend on intel edison. I would suggest operating on linux. because we finally would compiler kernel for wifi driver support.


Flash ubilinux, debian w/ Wheezy for Edison

I prefer Debian than Yocto
    1. #mkdir download
    2. #cd download
  1. install the flash tool first
    # apt-get install dfu-util
  2. flash image
    # cd toFlash
    # sudo ./flashall.sh
  3. after flash done, please wait reboot twice.
  4. maybe you need do some configure on Intel Edison.
    # sudo screen /dev/ttyUSB0 115200
    1. log on into edison with
      1. user : edison
      2. password: edison
    2. strongly suggest follow sparkfun’s reference site to add/modify the default user.
      1. sudo, ssh, etc.

Setup wifi

after flash ubilinux, wifi would be work now.  we would let it connect to wifi ap first, to make sure the device is workable.
  1. get hex_string
    $wpa_passphrase
    1. got the psk and remember your psk value for later usage.
  2. $vim /etc/network/interfaces
    1. commend auto usb0 with “#”
    2. uncomment wlan0, the line start should not have “#”
    3. fill your ssid and psk to profile field.
    4. in my case, I use eap wifi auth, here is a sample
      auto wlan0
      iface wlan0 inet dhcp
      wpa-driver wext
      wpa-ssid
      wpa-ap-scan 2
      wpa-eap PEAP
      wpa-key-mgmt WPA-EAP
      wpa-anonymous-identity
      wpa-identity
      wpa-password
      wpa-phase2 auth=MSCHAPV2
  3. $ifup wlan0
    1. if wifi cant work, try iwconfig to check the quality and signal strength
    2. $iwconfig
      1. some like as Link Quality=70/70  Signal level=-36 dBm

Install MPD for a client-server playback server.

Compile new version MPD

this is for  new features (maybe new bugs...)
  1. the version in ubilinux is old, but we could install it to configure some variable.
    $apt-get install mpd
  2. now we should compile it by yourself
  3. remove mpd first
    $apt-get remove mpd
  4. apt-get install some necessary packages
    $sudo apt-get install build-essential libglib2.0-dev git vim
  5. add the source repository
    $ sudo vim /etc/apt/sources.list
  6. remove “#” from deb-src or add it!
    $ sudo apt-get update
  7. use apt-build to update necessary packages.
    $ sudo apt-get build-dep mpd
  8. compiler mpd from source code tarball
    $ wget -O - http://www.musicpd.org/download/mpd/stable/mpd-0.19.7.tar.gz | tar -zxf -
    $ cd mpd-0.19.7
    $ make clean
    $ ./configure
  9. you would need to install some build tools here. check the missing dependent package and install them.
    $ make
    $ sudo make install
    $ whereis mpd
  10. base on last command, do a software link for it.
    $ sudo ln -s /usr/local/bin/mpd /usr/bin/mpd

configure config

  1. after compile and install, we need some configure let it work for our purpose.
    $sudo aplay -lcard
    1. 1: Audio [USB2.0 High-Speed True HD Audio], device 0: USB Audio [USB Audio]
  2. make sure following path exist, and check some values that we care.
    $ sudo vim /etc/mpd.conf
    music_directory      "/home//music"
    playlist_directory           "/home//.mpd/playlists"
    #bind_to_address
    port                         "6600"
    audio_output {
           type            "alsa"
           name            "Burson Conductor" # any you like
           device          "hw:1,0" #value in aplay -l
           auto_resample    "no"
           auto_format      "no"
           auto_channels    "no"
    }
    mixer_type                     "disabled"
    replaygain                     "off"
    $ sudo service mod restart
  3. Done!
    but no sound output here. because default configure of Intel ‘s kernel have not build in  snd-usb-audio module. we should follow next step.


Build your own kernel

remember back to your linux work station.
  1. now we can build the new kernel for audio support
    # mkdir edison
    # cd  edison
    # wget -O - http://downloadmirror.intel.com/24389/eng/edison-src-rel1-maint-rel1-ww42-14.tgz#_ga=1.225557722.1979370645.1410536481 | tar -zxf -
    # wget -O - https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.10.17.tar.bz2 | tar -jxf -
    # cd ./linux-3.10.17
    # patch -p1 < ../edison-src/device-software/meta-edison/recipes-kernel/linux/files/upstream_to_edison.patch
    # cp ../edison-src/device-software/meta-edison/recipes-kernel/linux/files/defconfig .config
    # cp drivers/tty/serial/mfd_trace.h include/trace/
  2. add usb sound support
    # make menuconfig
    1. mark module M at device driver -> Sound card support -> Advenced Linux Sound Architecture -> USB sound devices -> USB Audio / MIDI driver
  3. add for wifi module boardcom 4334x
    1. # cp -rf ../edison-src/broadcom_cws/
  4. Now build it
    # make -j16  -p broadcom_cws/wlan/driver_bcm43x/ deb-pkg
  5. Wait it compil done, you would get three debs at parent folder “edison”
    linux-headers-3.10.17-poky-edison_3.10.17-poky-edison-1_i386.deb
    linux-image-3.10.17-poky-edison_3.10.17-poky-edison-1_i386.deb
    linux-libc-dev_3.10.17-poky-edison-1_i386.deb
  6. now copy file into your Intel edison, if you have already set up ssh on edison, you can use scp to transfer file.
    1. # scp *.deb xx.xx.xx.xx:/home//
  7. change to your edison command line
  8. maybe you want to backup /boot before next step.
    1. $ cp -R /boot/* /home//boot_backup
  9. $ dpkg -i *.deb
    $ mv /boot/vmlinuz-3.10.17-poky-edison /boot/vmlinuz
    $ reboot
  10. after here, you should have a snd-usb-audio workable kernel on Edison or got a brick!!!
    1. if fail, go to “toFlash”, try again…

Configure ALSA

  1. now you should install some alsa packages.
    1. $ apt-get install alsa-utils
    2. $ sudo su
    3. $ alsactrl init
    4. aplay -Dhw:1,0 any.mp3
    5. If you got music from dac, done.
forgive me, I would not write the mpd client now, maybe later.

沒有留言: