USB audio on HIkey with Android


Does Hikey board supports USB audio with the latest Android release?


It won’t support it out-of-the-box because the kernel doesn’t have the USB audio driver enabled. However I think that is probably all that is missing!

Android Lollipop added support for USB audio so if you were to recompile the kernel with SND_USB_AUDIO enabled then there’s a good chance things would spring to life.


Even after enabling SND_USB_AUDIO flag in kernel ,I could not hear audio.

Enabled CONFIG_SND_USB_AUDIO=y in hikey_defconfig file and found change got effect in .config file.
Made kernel build, loaded built Image using fastboot on to Hikey board and I could see below log message from “adb shell dmesg”
[ 1.829292] usbcore: registered new interface driver snd-usb-audio

We have connected USB logitech Headset to Hikey board and here is the log from dmesg confirms it detects Logitech USB headset.
[ 4.219011] input: Logitech Logitech USB Headset as /devices/platform/soc/f72c0000.usb/usb1/1-1/1-1.2/1-1.2:1.3/0003:046D:0A44.0002/input/input2
[ 4.273785] hid-generic 0003:046D:0A44.0002: input,hidraw1: USB HID v1.00 Device [Logitech Logitech USB Headset] on usb-f72c0000.usb-1.2/input3

With the same build when I see system logs using logcat, it says his kernel does not have usb audio support
$ adb logcat |grep usb
01-01 00:00:11.216 1701 1701 E AudioFlinger: int android::load_audio_interface(const char *, audio_hw_device_t **) couldn’t load audio hw module audio.usb (No such file or directory)
01-01 00:00:11.216 1701 1701 I AudioFlinger: loadHwModule() error -2 loading module usb
01-01 00:00:11.216 1701 1701 W APM::AudioPolicyManager: could not open HW module usb
01-01 00:00:24.874 2105 2105 W WiredAccessoryManager: This kernel does not have usb audio support
01-01 00:00:24.875 2105 2105 I SystemServiceManager: Starting$Lifecycle
01-01 00:00:24.900 2105 2105 E UsbDeviceManager: failed to write to /sys/class/android_usb/android0/f_rndis/ethaddr
01-01 00:00:26.795 2105 2117 I StatusBarManagerService: registerStatusBar$Stub$Proxy@5b91890

Do I reuire to enable below flag also?


You won’t need CONFIG_USB_AUDIO, that is part of the USB gadget support and is used to add kernel support for having the kernel act as though it were a sound card.

I’m afraid it looks like there is also a component in the Android framework that will need to be included. This will need a full AOSP rebuild in order to test (and I still can’t promise I’ve remembered everything).

Anyhow the component you need to enable is called audio.usb.default (which has the same role as audio.a2dp.default but for USB rather than for Bluetooth). Examples of current AOSP devices that have this enabled are shown below:

whitebeam$ repo grep audio.usb.default
device/asus/flo/       audio.usb.default \
device/asus/fugu/    audio.usb.default \
device/htc/flounder/    audio.usb.default \
device/huawei/angler/    audio.usb.default \
device/lge/bullhead/    audio.usb.default \
device/lge/hammerhead/    audio.usb.default \
device/moto/shamu/    audio.usb.default \
docs/<li>add audio.usb.default to PR
hardware/libhardware/modules/usbaudio/ := audio.usb.defau
system/extras/Binary file perfprofd/tests/ matches

You ought to be able to drop a similar stanza into device/linaro/hikey/ and rebuild.


Thanks for your suggestion.
Enabled “audio.usb.default” at /linaro/hikey/ file.

However now from system logs, USB audio interface is loading successfully,see the below logs for more information
01-01 00:00:12.207 1686 1686 I AudioFlinger: loadHwModule() Loaded usb audio interface from USB audio HW HAL (audio) handle 5

Here is the confirmation from kernel which says snd-usb-audio is registered
4.193146] usbcore: registered new interface driver snd-usb-audio

but somehow from system logs,it says This kernel does not have usb audio support.
01-01 00:00:25.118 2047 2047 W WiredAccessoryManager: This kernel does not have usb audio support
01-01 00:00:25.118 2047 2047 I SystemServiceManager: Starting$Lifecycle
01-01 00:00:25.138 2047 2047 E UsbDeviceManager: failed to write to /sys/class/android_usb/android0/f_rndis/ethaddr
01-01 00:00:26.638 2047 2188 I StatusBarManagerService: registerStatusBar$Stub$Proxy@af9a95b

Please let me know if there is anything I am missing in enabling USB audio on Hikey Board.


Do I require to make changes to device/linaro/hikey/init.hikey.usb.rc file same as device/htc/flounder/init.flounder.usb.rc file?


I don’t think those changes are needed. Again that is code to support USB gadget functions (like when you switch between PTP and MTP mode on an Android phone).

I guess the first step of diagnostics if to figure out it the Logitech dongle is being picked up by alsa. As it happens I (think I) have the same dongle and I noticed there’s no dmesg output to show alsa is working with the dongle (on my host PC). Perhaps try the following instead (with the dongle connectect)?

cat /proc/asound/cards


Below is the information captured on HiKey using wifi ADB.

hikey:/proc/asound $ cat cards
USB AUDIO at usb-f72c0000.usb-1.2, full speed


Here are the brief steps to enable usb audio on HiKey.
Step1: Here is the hikey-linaro kernel patch to enable CONFIG_SND_USB_AUDIO=y flag at hikey-linaro kernel.
Build kernel Image after applying below patch and by following instructions from here
diff --git a/arch/arm64/configs/hikey_defconfig b/arch/arm64/configs/hikey_defconfig
index d0d6180…f07454b 100644
— a/arch/arm64/configs/hikey_defconfig
+++ b/arch/arm64/configs/hikey_defconfig
@@ -394,6 +394,7 @@ CONFIG_USB_CONFIGFS_F_ACC=y

Step2: Here is the user mode patch at ./device/linaro/hikey to enable audio.usb.default.
Build the system image after applying below patch and by following instructions from here
diff --git a/ b/
index ed87bd4…32f6538 100644
— a/
+++ b/
@@ -50,7 +50,9 @@ PRODUCT_PROPERTY_OVERRIDES += wifi.interface=wlan0
PRODUCT_RUNTIMES := runtime_libart_default

Build BT a2dp audio HAL

-PRODUCT_PACKAGES += audio.a2dp.default

  •                audio.a2dp.default \
  •                audio.usb.default

Include USB speed switch App


Step3: Flash newly built system image and boot image on Hikey Board.

Step4: Follow the instructions from here to connect Hikey adb device through wireless on windows host PC,

Step5: Connect USB OTG Hub to Hikey Board, Reference to USB OTG hub image:

Step6: Connect USB audio device to USB OTG Hub,Reference to USB audio device:

Step7: On Windows host PC open command prompt and run the following commands.
>adb connect 192.168.x.x (Hikey Ip address)
>adb root
>adb connect 192.168.x.x (Hikey Ip address)
>adb remount
>adb shell stop media
>adb shell start media

Step8: Push Music file on to Hikey Board using following commands.
>adb connect 192.168.x.x (Hikey Ip address)
>adb root
>adb connect 192.168.x.x (Hikey Ip address)
>adb remount
>adb push Kalimba.mp3 >/sdcard/Music

Step9: Connect the mouse to USB OTG Hub and using mouse go to default android music app and play song.


Thanks for the report. I’m working to fix this in AOSP now:


Hi John, great to see you pick this up for AOSP… I was going to ping you about it when I got back from holiday but you beat me to it!

Thanks to Nuri for the great write up too. Really pleased to see all this come together!


Thanks for your support,Now I have started working on SPI from 40 pin expansion connector and to enable audio playback /record through SPI interface. SPI slave(audio) connected to HiKey board.


Does HiKey with Android support USB recording?
When I try to test using Voice Recorder APK thru USB MIC getting below errors and not able to record it.

06-22 22:29:57.779 4173 4173 E MediaPlayer: stop called in state 0
06-22 22:29:57.779 4173 4173 E MediaPlayer: error (-38, 0)
06-22 22:29:57.779 3870 3876 D NuPlayerDriver: reset(0xf46990c0)
06-22 22:29:57.779 3870 3876 D NuPlayerDriver: notifyListener_l(0xf46990c0), (
8, 0, 0)
06-22 22:29:57.779 3870 3875 W APM::AudioPolicyManager: getOutput() could not
find output for stream 1, samplingRate 0,format 0, channels 3, flags 0
06-22 22:29:57.780 3870 3870 W APM::AudioPolicyManager: getOutput() could not
find output for stream 1, samplingRate 0,format 0, channels 3, flags 0
06-22 22:29:57.781 3870 3870 W APM::AudioPolicyManager: getOutput() could not
find output for stream 1, samplingRate 48000,format 1, channels 3, flags 4
06-22 22:29:57.781 2076 2127 E AudioTrack: Could not get audio output for sess
ion 76, stream type -1, usage 13, sample rate 48000, format 0x1, channel mask 0x
3, flags 0x4
06-22 22:29:57.781 3870 4343 D NuPlayerDriver: notifyResetComplete(0xf46990c0)

06-22 22:29:57.782 2076 2127 E SoundPool: Error creating AudioTrack
06-22 22:29:57.814 4173 4173 E DisplayEventDispatcher: dispatcher 0x7fa995c3c0
~ Vsync pulse: timestamp=1910683, id=0, count=58671
06-22 22:29:57.815 4173 4173 W MediaPlayer: mediaplayer went away with unhandl
ed events
06-22 22:29:57.817 4173 4173 E AudioSystem: AudioSystem::getInputBufferSize fa
iled sampleRate 44100 format 0x1 channelMask 10
06-22 22:29:57.817 4173 4173 E AudioRecord: AudioSystem could not query the in
put buffer size for sampleRate 44100, format 0x1, channelMask 0x10; status -22
06-22 22:29:57.819 4173 4173 W AudioRecord: getPrimaryOutputSamplingRate faile
06-22 22:29:57.821 3870 4400 I AudioFlinger: AudioFlinger’s thread 0xf3e83c40
ready to run


To be honest I really don’t know. Until you (and John) added it didn’t support USB audio at all!

I’ll take a look through the source base and see if I come up with anything. However to be honest all I’ll be doing it running “repo grep audio.usb.default” and hoping something comes up!



Searching the tree led me to hardware/libhardware/modules/usbaudio/audio_hal.c as the code that bridges the ALSA USB audio in the kernel to the rest of the Android framework.

Looking through that file there is certainly support for audio input meaning you would not be wasting your time trying to debug it!

My best advice would be to make a copy of the Android source tree and point OpenGrok at it. OpenGrok does take a little while to set up (its a Java based server application) but it pays huge dividends by allowing you to do free text search over the while Android tree in milli-seconds! In particular it makes it easy to convert messages you see in logcat back to the line of source code that emitted it.


So I just plugged in a USB headset and using Urecord (available from F-Droid) was able to record and playback audio ok.

So I’m not sure what might be causing the trouble you’re seeing. Can you specify which app you were using?


Using smartvoicerecorder app
Not sure below error could be the reason,may i know which USB audio device you are using?
Getting below warning from logcat logs
W APM::AudioPOlicyManager: Input device 80000100 unreachable

will try with urecord and update result,could you please tell me AOSP code base date?


After updating to latest AOSP code ,Now USB recording is working fine.

Niranjan Yadla
Tensilica Products
Cadence Design Systems, Inc.