Beaglebone Black can't get USB audio to work

683 views
Skip to first unread message

Jim S

unread,
Nov 21, 2016, 10:21:54 AM11/21/16
to BeagleBoard

Trying to add USB audio device to BBB.  I am running this headless - no HDMI display, no direct keyboard or mouse.  USB audio device is C-Media.  Have a powered USB hub.  Have an Arduino board connected by USB but don't think it affects this issue.  USB audio device is seen by aplay -l and aplay -L but trying to use it doesn't work and usually hangs the system requiring a power cycle.  System is for Asterisk VOIP and from here:
http://beaglebone-asterisk.raspbx.org/


root@raspbx:~# uname -a
Linux raspbx 3.14.37-ti-r57 #1 SMP PREEMPT Sat Apr 4 06:18:14 UTC 2015 armv7l armv7l armv7l GNU/Linux

root@raspbx:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Black [TI BeagleBone Black], device 0: HDMI hdmi-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Device [C-Media USB Audio Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
root@raspbx:~#

root@raspbx:~# aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
default:CARD=Black
    TI BeagleBone Black,
    Default Audio Device
sysdefault:CARD=Black
    TI BeagleBone Black,
    Default Audio Device
dmix:CARD=Black,DEV=0
    TI BeagleBone Black,
    Direct sample mixing device
dsnoop:CARD=Black,DEV=0
    TI BeagleBone Black,
    Direct sample snooping device
hw:CARD=Black,DEV=0
    TI BeagleBone Black,
    Direct hardware device without any conversions
plughw:CARD=Black,DEV=0
    TI BeagleBone Black,
    Hardware device with all software conversions
default:CARD=Device
    C-Media USB Audio Device, USB Audio
    Default Audio Device
sysdefault:CARD=Device
    C-Media USB Audio Device, USB Audio
    Default Audio Device
front:CARD=Device,DEV=0
    C-Media USB Audio Device, USB Audio
    Front speakers
surround40:CARD=Device,DEV=0
    C-Media USB Audio Device, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Device,DEV=0
    C-Media USB Audio Device, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Device,DEV=0
    C-Media USB Audio Device, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Device,DEV=0
    C-Media USB Audio Device, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Device,DEV=0
    C-Media USB Audio Device, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Device,DEV=0
    C-Media USB Audio Device, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=Device,DEV=0
    C-Media USB Audio Device, USB Audio
    Direct sample mixing device
dsnoop:CARD=Device,DEV=0
    C-Media USB Audio Device, USB Audio
    Direct sample snooping device
hw:CARD=Device,DEV=0
    C-Media USB Audio Device, USB Audio
    Direct hardware device without any conversions
plughw:CARD=Device,DEV=0
    C-Media USB Audio Device, USB Audio
    Hardware device with all software conversions
root@raspbx:~#

As an attempt to test I ran:
root@raspbx:/opt/jimscripts# speaker-test -D default:Device

speaker-test 1.0.27.2

Playback device is default:Device
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 2048 to 16384
Period size range from 1024 to 1024
Using max buffer size 16384
Periods = 4
was set period_size = 1024
was set buffer_size = 16384
 0 - Front Left

At this point the system hung and I had to power cycle.

I edited /boot/uboot/eEnv.txt to disable HDMI audio so USB is default audio but this didn't seem to help.  Current line in that file is:

optargs=capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN

What should I be looking at/doing?  Any help is appreciated.

Jim S

unread,
Nov 23, 2016, 9:34:44 AM11/23/16
to BeagleBoard
Apparently, from a little searching and reading others are having similar trouble and the issue is DMA for the USB audio - it needs to be disabled (I think...).  This requires recompiling the kernel with this disabled.  Haven't compiled a kernel before so am looking for some detailed instructions on this and replacing the existing kernel (would like to keep the rest of the configured system if possible).  Anyone have any good links on doing this?  I have found several places that give the line setting the option of disabling DMA and I think I could add that to detailed kernel cross compiling instructions...

Robert Nelson

unread,
Nov 23, 2016, 9:49:54 AM11/23/16
to Beagle Board, jimski...@gmail.com
git clone https://github.com/RobertCNelson/yakbuild
cd yakbuild/
cp recipe.sh.sample recipe.sh

Open receipe.sh and set:

toolchain="gcc_linaro_gnueabihf_4_8"
&
kernel_tag="3.14.37-ti-r57"

Then run:

./build_deb.sh

once Kernel Configuration loads:

Device Drivers --->
[*] USB support --->
MUSB DMA mode (TI CPPI 4.1 (AM335x)) --->

You'll see:
│ │ ( ) Inventra
│ │
│ │ (X) TI CPPI 4.1 (AM335x)
│ │
│ │ ( ) Disable DMA (always use PIO)

Change too:

│ │ ( ) Inventra
│ │
│ │ ( ) TI CPPI 4.1 (AM335x)
│ │
│ │ (X) Disable DMA (always use PIO)

Exit via esc and < Yes > to save your new configuration..

Let it build, (ignorly all the libfakeroot-sysv.so errors)

eventually you'll have a linux-image-*deb package under deploy, copy
this to your beagle and run "sudo dpkg -i linux-image*.deb" and reboot

Regards,


--
Robert Nelson
https://rcn-ee.com/

Jim S

unread,
Nov 23, 2016, 11:00:25 AM11/23/16
to BeagleBoard, jimski...@gmail.com
Thanks!  I take it that is done on the BBB itself?  (rather than cross compiled)  Any issue with doing this over ssh?  (particularly the selecting of kernel configuration boxes)

I saw in another thread

https://groups.google.com/forum/embed/?place=forum/beagleboard&showsearch=true&showpopout=true&showtabs=false&hideforumtitle=true&parenturl=http%3A%2F%2Fbeagleboard.org%2Fdiscuss#!category-topic/beagleboard/usb/HQnLSvyYISI
 that it might be possible to achieve the same thing by adding musb_hdrc.use_dma=n to the kernel cmdline.  I have only fiddled a bit with this on desktops and the BBB is a little different.  Can I add this as to uEnv.txt as an addition to the optargs=... line?  That would be a lot simpler, at least to test and verify that this is the issue, than recompiling the kernel.  If not there, where do I place that?

William Hermans

unread,
Nov 23, 2016, 11:22:38 AM11/23/16
to beagl...@googlegroups.com
Tells me this can be cross compiled. I can not speak for this set of scripts yet, as I have not used them. But I've used other similar scripts from Robert, and they will generally pull in most, if not all requirements for you. Sometimes, you may have to apt-get install <something> but Roberts scripts generally tell you when it hits this wall.

The command line argument probably won't work.But the only way you'll know for sure is if you try it. A lot of those cmdline args are x86 specific, and if they are ARM compatible, many times they won't work. The only one I've personally had success with thus far is ipv6.disable, the rest( maybe 2-3 others ) did not work for me, and one after reading I found out was an x86 compatible cmdline arg anyhow.

optargs is general the place to put cmdline arguments into your uEnv.txt file. That is on older kernels. The newer 4.x kernels, well the images they come with have a first and second stage uEnv.txt file, where it's best to edit the cmdline variable in the second stage uEnv.txt file. Whether or not if it works . . . you'll have to figure that out by trial and error I'm thinking.

Robert Nelson

unread,
Nov 23, 2016, 11:26:43 AM11/23/16
to Beagle Board, jimski...@gmail.com
On Wed, Nov 23, 2016 at 10:00 AM, Jim S <jimski...@gmail.com> wrote:
> Thanks! I take it that is done on the BBB itself? (rather than cross
> compiled) Any issue with doing this over ssh? (particularly the selecting
> of kernel configuration boxes)

Depends, run it on x86, it'll be pretty quick..

Run on beagle, wait a few hours..

Jim S

unread,
Nov 27, 2016, 10:14:58 PM11/27/16
to BeagleBoard, jimski...@gmail.com
I got the kernel recompiled with disabled DMA and installed it.  Sound now works fine. 

For anyone else wanting to do this I followed Roberts notes and used a couple other pages to help with figuring out some details such as installing things needed for the cross compile on a Ubuntu PC:
http://elinux.org/Building_BBB_Kernel
http://wiki.beyondlogic.org/index.php/BeagleBoneBlack_Building_Kernel

I didn't mess with TFTP as both those pages show.  After the cross compile I  transferred the new kernel file to the BBB with Filezilla (after I backed up the system in case of trouble) and installed with dpkg -i ... as Robert suggested. 

ckern...@gmail.com

unread,
May 31, 2020, 3:30:35 PM5/31/20
to BeagleBoard
Thanks Robert for providing these instructions. Does anyone know if there are any changes required since they were posted in 2016? I was able to build the linux image as described, but after installing it onto the BBB using dpkg the board no longer boots. Instead, it hangs immediately on power-up with all 4 LEDs on.

Any ideas for things to try would be greatly appreciated.

Thank you

Chris

Robert Nelson

unread,
May 31, 2020, 3:38:41 PM5/31/20
to Beagle Board, ckern...@gmail.com
On Sun, May 31, 2020 at 2:30 PM <ckern...@gmail.com> wrote:
>
> Thanks Robert for providing these instructions. Does anyone know if there are any changes required since they were posted in 2016? I was able to build the linux image as described, but after installing it onto the BBB using dpkg the board no longer boots. Instead, it hangs immediately on power-up with all 4 LEDs on.
>
> Any ideas for things to try would be greatly appreciated.

First regarding, MUSB & DMA, we gave up.. It's been PIO mode by
default for a few years now..

Second, which kernel are you using? Please if you can also share a
usb serial boot log (using J1)

https://elinux.org/Beagleboard:BeagleBone_Black_Serial

ckern...@gmail.com

unread,
Jun 7, 2020, 6:49:02 PM6/7/20
to BeagleBoard



Thanks for letting me know that MUSB & DMA is no longer a thing. With that in mind, I finally figured out my problem getting the USB audio to work. Turns out my USB audio device was pulling too much current from the USB port. Beginner's mistake! I finally tried connecting it to a powered USB hub and now it’s working. Should have tried that a long time ago, but I was confused by the mpg123 error messages and the DMA issues others were having when trying to get USB audio to work.


Since I figure this might help others, here are the steps I took to get things working:


I re-flashed the eMMC with ‘bone-eMMC-flasher-ubuntu-18.04.4-console-armhf-2020-03-12-2gb.img’. It looks like the kernel is “Linux 4.19.94-ti-r36 armv71”.


I installed mpg123 and tested it with an mp3 file. It worked, sending its output to the default HDMI output.


I then plugged in the USB audio device. Sure enough, It shows up when calling ‘aplay -L’.


To set the USB audio to the default audio device, I next created a file called ‘/etc/asound.conf’ with following:


pcm.!default {

type hw

card 1

}

ctl.!default {

type hw

card 1

}


Running ‘alsamixer’ from the command line should now show USB audio as the connected audio device.


Finally, make sure the USB audio device is connected to a powered USB hub and things should work. Before I had the powered hub, I would get the following error when running ‘mpg123 Swish.mp3’ (this is what threw me off for so long):

 

High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3

        version 1.25.10; written and copyright by Michael Hipp and others

        free software (LGPL) without any warranty but with best wishes

[?25l

Terminal control enabled, press 'h' for listing of keys and functions.

Playing MPEG stream 1 of 1: Swish.mp3 ...

MPEG 1.0 L III cbr128 48000 mono

[src/libout123/modules/alsa.c:181] error: cannot open device default

[src/libout123/libout123.c:585] error: failed re-opening of device after pause

main: [src/mpg123.c:798] error: Deep trouble! Cannot flush to my output anymore!

[src/libout123/modules/alsa.c:181] error: cannot open device default

[src/libout123/libout123.c:585] error: failed re-opening of device after pause

 

Anyway, thanks to Robert and everyone else for your help. Audio is a playin!




On Sunday, May 31, 2020 at 12:38:41 PM UTC-7, RobertCNelson wrote:
Reply all
Reply to author
Forward
0 new messages