Hilscher Community Forum
connecting a microphone via USB - Printable Version

+- Hilscher Community Forum (https://forum.hilscher.com)
+-- Forum: netPI 3 - Docker featuring Industrial Raspberry Pi 3 platform (https://forum.hilscher.com/forum-1.html)
+--- Forum: Software (https://forum.hilscher.com/forum-5.html)
+--- Thread: connecting a microphone via USB (/thread-612.html)

Pages: 1 2


connecting a microphone via USB - tad - July-6th-2020

Dear Armin,

To run a container application which is developed on commercial raspberry pi, I need to map a microphone via USB port.
I think a directory '/dev/snd' must be mounted when creating a new container on netPI.

But,  the attached failure message appears when deployed.
Is there any solution to activate the microphone device?

Thank you very much for your support.
Best regards,


RE: connecting a microphone via USB - Armin@netPI - July-6th-2020

Hello Tad,

you are trying to map a "volume". This is not correct.

You have to map a "device" since /dev/snd is a device. Like here as example: https://registry.hub.docker.com/r/hilschernetpi/netpi-desktop-hdmi/

To be honest, I have not made any experience with a microphone yet. So you need to collect your own experience with it.

Regards


RE: connecting a microphone via USB - tad - July-8th-2020

Dear Armin,

Thank you very much for your support.

I mapped the device as /dev/snd:/dev/snd.
After that, I entered below from the console.
That means Linux detects a device with integrated speaker and microphone (Jabra SPEAK) as 'Bus 001 Device 007'.
But, arecord doesn't recognize this device.

root@raspberrypi:/# lsusb
Bus 001 Device 007: ID 0b0e:0420 GN Netcom Jabra SPEAK 510
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@raspberrypi:/# arecord -l
**** List of CAPTURE Hardware Devices ****
root@raspberrypi:/#

If 'hilschernetpi/netpi-raspbian' is deployed on a commercial Raspberry Pi with Docker, the USB device is recognized only by enabling a privileged mode.

pi@testmic03:~$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 2: Microphone [USB Microphone], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
pi@testmic03:~$

Do you think netPI has some limitations for microphone input?

Thank you very much for your support.
Best regards,


RE: connecting a microphone via USB - Armin@netPI - July-8th-2020

You say the microphone is recognized on a commercial Raspberry Pi if you enable "privileged" mode, correct?

But what happens if you enable "privileged" mode on the netPI too? Have you tried this already?

There is one important point to know in general about Docker and USB. Every time a container is started then Docker makes a snapshot of the connected USB devices and maps them into the container. If you connect USB devices after the container is started they will not be recognized. So make sure you have connected the USB device when you power on netPI and the containers are started later by Docker automatically. Then your are safe.


RE: connecting a microphone via USB - Armin@netPI - July-8th-2020

In order to get out the problem we can debug the "arecord" program using another program called "strace".

It is tracing all Linux calls of a program. If not already installed in the container instrall strace using "apt install strace" command first.

Then to debug call "strace arecord -l 2>mytrace.txt" and it will be tracing all outputs to the "mytrace.txt" file. After that post the "mytrace.txt" and maybe I can recognize what the problem is. Maybe it is a missing microphone Linux kernel driver, I don't know.


RE: connecting a microphone via USB - Armin@netPI - July-8th-2020

There is another idea. Please run the container also in "host" network mode. Maybe this also has an influence.


RE: connecting a microphone via USB - tad - July-8th-2020

Dear Armin,

Thank you very much for your help.
I attached 'mytrace.txt' which was gathered as follows.

root@raspberrypi:/home/pi# strace arecord 1 2>mytrace.txt
root@raspberrypi:/home/pi# lsusb
Bus 001 Device 004: ID 0b0e:0420 GN Netcom Jabra SPEAK 510
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@raspberrypi:/home/pi# arecord -l
**** List of CAPTURE Hardware Devices ****
root@raspberrypi:/home/pi#

I have always activated privileged mode and mapped /dev/snd:/dev/snd on my netPI.
Even if Network=bridge to host, I see the same phenomenon between bridge and host.

I tried to reproduce 'mytrace.txt' again with a different USB device (microphone).
I will then inform you its result.

Best regards,


RE: connecting a microphone via USB - Armin@netPI - July-8th-2020

Well I have one question. Have you installed the "alsa" driver tools in your Raspbian container?

Here is the example taken from the Dockerfile https://github.com/HilscherAutomation/netPI-desktop-hdmi/blob/master/Dockerfile

"apt install -y alsa-oss alsa-tools alsa-tools-gui alsa-utils alsamixergui mpg123"

Please call this command line and try again


RE: connecting a microphone via USB - Armin@netPI - July-8th-2020

How is the same trace using the tool on a commercial Raspberry Pi? Please repeat it and then we can compare the two files.


RE: connecting a microphone via USB - Armin@netPI - July-8th-2020

I watched your logfile.

It says: uname({sysname="Linux", nodename="raspberrypi", ...}) = 0

So did make this trace on the commercial Raspberry Pi or on netPI?