• WANTED: Happy members who like to discuss audio and other topics related to our interest. Desire to learn and share knowledge of science required. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

Strange issue with my CamillaDSP gadget

stemag

Member
Joined
Nov 1, 2022
Messages
32
Likes
24
I am experiencing a strange problem with my CamillaDSP box using RPi4 USB gadget port as capture device.
My digital audio chain is as follows:
piCorePlayer 8.2.0 RPi4 --> latest Raspberry Pi OS RPi4 --> USB DAC

In my first attempts, the pCP host did not recognise the gadget device. However, after a few cable disconnections and reconnections, the gadget device was magically recognised. I myself cannot explain the reason for this success. Since then I have done countless tests of the system and: the camilladsp gadget always worked properly, and the DAC produced the right sounds.
Unfortunately, after a few more cable disconnections and reconnections, the system returned to the situation of the first attempts: the gadget device was not recognised by the host.
From then on, no matter how many attempts I made, the camilladsp gadget was no longer recognised by the host.
Please note the following:
- On the camilladsp gadget the command 'arecord -l' shows the UAC2Gadget device, as expected.
- Checking with dmesg, it seems that neither the gadget nor the host notices connections and disconnections between the USB-C port on the gadget side and a USB-A port on the host side
- The same seems to happen when trying to connect the gadget device to an Ubuntu server (instead of the piCorePlayer host)
- I tried replacing USB cables and the power/data splitter, but nothing changed

I need your help.
 
Last edited:
That sounds like an annoying problem. One thing that comes to mind is maybe another USB device is interfering with the g_audio module. Can you check what modules are loaded with lsmod and see if any USB module is installed.
 
Can you check what modules are loaded with lsmod and see if any USB module is installed.
@IAtaman, thank you for answering.
To be honest, I don't know how to check the presence of any USB modules. Can you help me do that?
Please find attached the output of lsmod.
 

Attachments

  • lsmod.txt
    3.7 KB · Views: 63
I am experiencing a strange problem with my CamillaDSP box using RPi4 USB gadget port as capture device.
My digital audio chain is as follows:
piCorePlayer 8.2.0 RPi4 --> latest Raspberry Pi OS RPi4 --> USB DAC

In my first attempts, the pCP host did not recognise the gadget device. However, after a few cable disconnections and reconnections, the gadget device was magically recognised. I myself cannot explain the reason for this success. Since then I have done countless tests of the system and: the camilladsp gadget always worked properly, and the DAC produced the right sounds.
Unfortunately, after a few more cable disconnections and reconnections, the system returned to the situation of the first attempts: the gadget device was not recognised by the host.
From then on, no matter how many attempts I made, the camilladsp gadget was no longer recognised by the host.
Please note the following:
- On the camilladsp gadget the command 'arecord -l' shows the UAC2Gadget device, as expected.
- Checking with dmesg, it seems that neither the gadget nor the host notices connections and disconnections between the USB-C port on the gadget side and a USB-A port on the host side
- The same seems to happen when trying to connect the gadget device to an Ubuntu server (instead of the piCorePlayer host)
- I tried replacing USB cables and the power/data splitter, but nothing changed

I need your help.
1) Random, inexplicable problems are often caused by power supplies - the Pi 4 is very fussy.
2) You have 2 Pi 4s in the mix? Have you considered using just the one of them for both music playback and CamillaDSP? MoOde supports CamillaDSP.
 
@IAtaman, thank you for answering.
To be honest, I don't know how to check the presence of any USB modules. Can you help me do that?
Please find attached the output of lsmod.
I don't see g_audio module in the list. Can you try loading it with modprobe to see what happens please.

sudo modprobe g_audio
 
Can you try loading it with modprobe to see what happens please.
After loading g_audio, two new modules appear:
Bash:
pi@camilladsp:~ $ lsmod | grep g_audio
g_audio                16384  0
libcomposite           69632  3 u_audio,g_audio,usb_f_uac2

Then I have started the gadget init service, but it exited with error:
Bash:
pi@camilladsp:~ $ sudo systemctl status gadget_init
● gadget_init.service - Gadget Mode Boot Starter
     Loaded: loaded (/lib/systemd/system/gadget_init.service; disabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Wed 2023-07-19 11:54:18 CEST; 3s ago
    Process: 736 ExecStart=/home/pi/gadget_init.sh (code=exited, status=2)
   Main PID: 736 (code=exited, status=2)
        CPU: 33ms

lug 19 11:54:18 camilladsp systemd[1]: Started Gadget Mode Boot Starter.
lug 19 11:54:18 camilladsp gadget_init.sh[744]: ls: write error: Device or resource busy
lug 19 11:54:18 camilladsp systemd[1]: gadget_init.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
lug 19 11:54:18 camilladsp systemd[1]: gadget_init.service: Failed with result 'exit-code'.
The gadget device is not recognized by host.

Loading g_audio after gadget initialization, this is what dmesg reports:
Bash:
[   29.153717] g_audio gadget.0: Linux USB Audio Gadget, version: Feb 2, 2012
[   29.153740] g_audio gadget.0: g_audio ready
[   29.153754] dwc2 fe980000.usb: bound driver g_audio
[   83.062632] UDC core: audio-basic: couldn't find an available UDC or it's busy
Needless to say that gadget is not recognized by host.
 
Last edited:
1) Random, inexplicable problems are often caused by power supplies - the Pi 4 is very fussy.
Thank you for answering.
I will try with a more beefy power supply.
2) You have 2 Pi 4s in the mix? Have you considered using just the one of them for both music playback and CamillaDSP? MoOde supports CamillaDSP.
Yes, one RPi4 as a streamer, and another as a DSP. By using a separate DSP I can use REW sweep signal to check the effect of equalisation. I don't like Moode, I much prefer piCorePlayer with Jivelite displayed on my TV and a wifi mini keyboard.
 
Thank you for answering.
I will try with a more beefy power supply.

Yes, one RPi4 as a streamer, and another as a DSP. By using a separate DSP I can use REW sweep signal to check the effect of equalisation. I don't like Moode, I much prefer piCorePlayer with Jivelite displayed on my TV and a wifi mini keyboard.
I might have to give piCorePlayer a go!
 
[ 83.062632] UDC core: audio-basic: couldn't find an available UDC or it's busy
That is not good. When you google that, it points to potential driver problems. Can you use the same USB port for other tasks?
Can you also please share the contents of the gadget_init.sh file - there might be some clues there as to what is supposed to happen but not happening.
 
That is not good. When you google that, it points to potential driver problems.
This message only appears after loading the g_audio module.

Can you use the same USB port for other tasks?
I connected my smartphone to the RPi4 USB-C port (through the splitter), but it is was not recognized by the gadget.

Can you also please share the contents of the gadget_init.sh file
Please find attached the gadget initialization script (the extension was renamed to .txt as the .sh file could not be attached).

Thanks a lot.
 

Attachments

  • gadget_init.txt
    2.7 KB · Views: 62
The script is using the composite gadget driver. IIRC this lets you mix and match gadget functions on the same port, in contrast to the individual gadget drivers like g_audio. I think it's and either/or thing, so if g_audio is loaded you won't be able to load the composite driver, and vice versa.

What is this 'splitter' you are using?
 
This message only appears after loading the g_audio module.


I connected my smartphone to the RPi4 USB-C port (through the splitter), but it is was not recognized by the gadget.


Please find attached the gadget initialization script (the extension was renamed to .txt as the .sh file could not be attached).

Thanks a lot.
Okay, that makes sense, gadget_init.sh is initializing the same hardware g_audio is trying to use.

At this point I am improvising, so take it with a grain of salt please and if you have a chance to back-up the image on your RPI, I recommend you to do so.

Bash:
AUDIO_SAMPLE_SIZE_CAPTURE=4 # 1 for S8LE / 2 for S16LE / 3 for S24LE / 4 for S32LE
AUDIO_SAMPLE_SIZE_PLAYBACK=4

Capture and playback bit depth is set to 32bit Float. I had problems with that format before. Can you try changing those to 2 or 3 to see if that makes a difference.

If you want to use the OTG port for audio only, instead of using the gadget_init.sh script, why don't you give this method a go:


Going back and reading what you wrote, that first it didn't work, then it did work and now it is not working again, I can't help thinking maybe a problem with the splitter PCB - a dry solder joint a loose track. Before anything, maybe that is worth a visual inspection.
 
This one, purchased on AliExpress. Thank you.
Good to see they say that it's outside the USB specifications and may cause damage/issues with chargers other than the 'official' one. I'd be happier with one of the adapters designed to connect to the 5V pin header, but some of those take shortcuts too.

When disconnecting/reconnecting were you careful about the orientation of the USB-C connectors? I know it's not _meant_ to matter, but sometimes hardware has implementation errors and it does. A bit like the small implementation issue on the early Pi4 boards that stopped them working with some Apple PSUs (among others).
 
If you want to use the OTG port for audio only, instead of using the gadget_init.sh script, why don't you give this method a go:
I tried that method, but no success.

Going back and reading what you wrote, that first it didn't work, then it did work and now it is not working again, I can't help thinking maybe a problem with the splitter PCB - a dry solder joint a loose track. Before anything, maybe that is worth a visual inspection.
That's what I thought too. That's why I checked the splitter, and also replaced it with another (identical) one. No success.
 
Good to see they say that it's outside the USB specifications and may cause damage/issues with chargers other than the 'official' one. I'd be happier with one of the adapters designed to connect to the 5V pin header, but some of those take shortcuts too.
Having doubts, I powered the host with a very robust power supply, eliminated the splitter, and connected the host directly to the gadget with a USB-A/USB-C cable. This way the gadget is powered by the host. 'dmesg' does not report any undervoltage errors, neither in the gadget nor in the host. Do you see any counter-indications that might affect operation? However, even in this way, the gadget is not detected by the host.
 
Assuming it's a known-good USB-A/USB-C cable it seems you've eliminated the usual hardware suspects. @phofman has been more in-depth than most of us with the audio gadget so may have some ideas about what else you could check.
 
IMO it's better to start troubleshooting with the g_audio module as it's much easier to configure than the composite configfs.

Of course dwc must be switched to the gadget mode in config.txt.

I always power rpi4 through the GPIO pins, have no experience with USB-C power in the gadget mode.
 
Just to take any possible problems with the piCorePlayer host out of the equation, I will connect the USB-C port of the gadget to a USB-A port on my Ubuntu server. I expect the server to detect the gadget and the corresponding track to be displayed by dmesg.
Is this a right expectation?
 
Back
Top Bottom