Wednesday, May 14, 2014

Getting Started with Audio Cape Revision B



UPDATE: CircuitCo has created a new page, BBB Audio Cape RevB Getting Started, that works out of the box with the Beaglebone Black RevC (I just tested on a new board).  It uses the debian flashed on the eMMC at the factory.  The directions below are for building your own debian Linux system and setting it up on the microSD.

I just started working with the new Audio Cape RevB from CircuitCo, I have revision B1.  I have tested it with a BeagleBone Black with PCB RevB5.  I know a few other people who might want to use this so I have summarized the steps to get audio output.  I haven't tested audio input yet, I might post that if it looks complicated.

AudioCape Rev B1 Picture
To build u-boot, the Linux kernel and debian root filesystem, and set up on the BeagleBone Black, I used instructions from eewiki.net by Robert Nelson.  

A few notes on the process of building and setting up debian on a mini SD card from that page.
  1. If you need to rebuild Linux, use the ./linux-dev/tools/rebuild.sh script.
  2. Don't forget to unmount the SD before you remove it to boot the board.
    # sync
    # sudo umount /media/boot
    # sudo umount /media/rootfs
  3. If you want to boot from SD only, delete the MLO file from the eMMC /boot/uboot directory.

Post installation steps.  

I can't access the serial port with the cape installed with my USB to serial cable, so I'm using ssh. Luckily I know what the IP address is so I don't need to remove the cape and reconnect serial.

$ ssh 192.168.0.113 -l root

# apt-get update
# apt-get install alsa-base alsa-utils
# aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
default:CARD=Black http://www.troubleshooters.com/linux/sound/sound_troubleshooting.htm
TI BeagleBone Black,
Default Audio Device
sysdefault:CARD=Black
TI BeagleBone Black,
Default Audio Device

Enable the audio cape at boot.

# sensible-editor /boot/uboot/uEnv.txt

Add this line or, if you have multiple optargs settings, combine them all onto one line.

## Enable Audio Rev B1 cape
optargs=capemgr.enable_partno=BB-BONE-AUDI-02

Next, reboot the board.   When it comes up you can see that HDMI is using the overlay without audio, BB-BONELT-HDMIN, instead of the normal HDMI with audio because of a conflict with the audio cape.

# dmesg | grep bone-capemgr | grep conflict -A 3
[    1.804057] bone-capemgr bone_capemgr.9: slot #5: BB-BONELT-HDMI conflict P9.25 (#7:BB-BONE-AUDI-02)
[    1.813631] bone-capemgr bone_capemgr.9: slot #5: Failed verification
[    1.820367] bone-capemgr bone_capemgr.9: loader: failed to load slot-5 BB-BONELT-HDMI:00A0 (prio 1)
[    1.829837] bone-capemgr bone_capemgr.9: loader: check slot-6 BB-BONELT-HDMIN:00A0 (prio 2)


# cat /sys/devices/bone_capemgr.*/slots
0: 54:PF---
1: 55:PF---
2: 56:PF---
3: 57:PF---
4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
6: ff:P-O-L Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN
7: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-BONE-AUDI-02

# aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
default:CARD=EVM
DA830 EVM,
Default Audio Device
sysdefault:CARD=EVM
DA830 EVM,
Default Audio Device

Test that audio output is working.

# speaker-test
speaker-test 1.0.25

Playback device is default
Stream parameters are 48000Hz, S16_LE, 2 channels
WAV file(s)
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 128 to 32768
Period size range from 8 to 2048
Using max buffer size 32768
Periods = 4
was set period_size = 2048
was set buffer_size = 32768
 0 - Front Left
 ...

This should output noise, there are other settings that you can use with speaker-test to check which is right and left.

# speaker-test -c2 -t wav