ASL3 on RPi with AIOC gives "unable to detach the USB device" error

I'm setting up my first AllStarLink Node. I'm using a Rapsberry Pi 3 as my node server and trying to use a AIOC cable/soundcard connected to a HT radio for RF.

I'm using the allstar3-arm64-3.0.18.img.xz image for my setup and have run apt update/upgrade.

Trying to use the Interface Tune CLI to e.g. Toggle PTT on the radio gives the error

Device XXXXX is selected, the associated USB device string 1-1.1.3:1.0 was not found

I've edited /etc/asterisk/res_usbradio.conf and uncommented the usb_devices = 1209:7388 line so it picks up my AIOC and restarted the asterisk service after that change.
asl-find-sound finds the AIOC

he@asl-tf3hr:~ $ asl-find-sound
1-1.1.3:1.0     -->     1209:7388 AIOC

I've set up the node using asl-menu with radio interface USBRadio.

I've ensured the usbradio.conf contains settings from GitHub - skuep/AIOC: Ham Radio All-in-one-Cable, especially

rxboost = 0
rxsqhyst = 500
carrierfrom = usbinvert
ctcssfrom = no
rxdemod = speaker
txprelim = no
invertptt = no

Viewing /var/log/asterisk/messages.log shows the message below repeated every 500msec or so

[2025-05-11 21:21:57.287] ERROR[33890] chan_usbradio.c: Channel XXXXX: Is not able to detach the USB device

Same error message and behavior if I try to use SimpleUSB.

What could be the problem? As I read the code in chan_usbradio.c the code is trying to detach the kernel driver from the AIOC but is unable. Kernel issue? I've not installed any additional software on the ASL3 image running on the RPi that's attaching to the audio or HID device.

Any help or hints appreciated!

Thanks
Hrafnkell TF3HR

Does asl-find-sound give you the same device string as the PTT error?

Do you have devstr = anything in usbradio.conf?

Does asl-find-sound give you the same device string as the PTT error?

yes asl-find-sound gives me the same device string as the error

Do you have devstr = anything in usbradio.conf?

I have not changed devstr = in usbradio.conf so it is empty.

Is the AOIC the only usb device? And you have a 3B/3B+?

Is the AOIC the only usb device? And you have a 3B/3B+?

Yes it is the only USB device. I'm using a Raspberry Pi 3B+ rev 1.3.

I can replicate the problem on Debian 12 in an amd64 VirtualBox virtual machine when I attach the AIOC there, I immediately get the "Is not able to detach the USB device" in the asterisk/messages.log

I have solved the problem. Needed to change a udev rule. The asl3-asterisk pacakge comes with a udev rule that allows the asterisk process access to the usb device with the vendor ID of CM108. When using an AIOC with the AIOC vendor ID this rule is not applied and thus asterisk does not have read/write access to /dev/bus/usb/...
I copied the /etc/udev/rules.d/90-asl3.rules to 91-aioc.rules and changed the vendor ID in it to the AIOC vendor id

he@asl-tf3hr:/etc/udev/rules.d $ cat 91-aioc.rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="1209", GROUP="plugdev", TAG+="uaccess"

restarting the system after this change (or trigger udev). The detach error stops and the Tune CLI can PTT.

strace was the key to figuring this out. I ran strace on all the asterisk thread pids until I found a thread that was getting errors and saw it was trying to access the /dev/usb/... stuff with EACCESS error

73 de TF3HR

For completeness, I'm adding to this thread the extra steps I needed in addition to the udev rule above to get AIOC working with ASL3.

"Stock" AIOC detected carrier but stopped "listening" after less than a second.

G1LRO has documented this previously on https://g1lro.uk/?p=676
He links to a script that downloads python code that modifies the USB VID and PID and a register in the AIOC called VCOS_TIMCTRL. It seems his script doesn't work with the latest firmware, the struct packing/unpacking didn't match what the firmware was expecting. I've also been using the default AIOC USB VID and PID. The script also had problems accessing the hidraw interface it uses to read/write the registers in the AIOC.

I found that yet another udev rule was needed to allow access to the hidraw interface

SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1209", GROUP="plugdev", TAG+="uaccess"

I found python code that has correct struct packing/unpacking on the AIOC GitHub repository, in a pull request..

Using this code and the value from the G1LRO script for the VCOS_TIMCTRL I was able to program the register on my AIOC. After that it worked for my node.

Asterisk can not be running while you run the code as the hidraw interface is not accessible. I've had to stop asterisk and then plug in my AIOC to be able to get the hidraw interface to show up and be accessible.

Here is a link to a gist with my python code to program the AIOC register.

Can you point to the information that stated this was necessary? The hidraw subsystem is generally for Human Interface Device (HID) things like keyboards, mice, etc. The current channel drivers aren't interacting with hidraw. Is something about the AOIC device connecting more than a cm1xx (compatible) device?

The hidraw rule is not needed for ASL as such. It is needed to be able to run the Python script to change the registers in the AIOC, at least if you want to run the script as a user. Changing a register in AIOC seems to be needed for it to work with ASL.

You need the python hid module for the Python script. It uses the HID get/set feature report API to read and write to registers in the AIOC.

I don't have a source stating this is needed, just my experimentation why I wasn't able to write to the AIOC registers led me to create this rule. The register changing Python code worked after adding it.

The hid python module provided by Debian seems to be too old for this Python code to work. So you need to pip install the latest hid module into the users environment (I prefer a virtual environment). Then running the code as a user is nice and then the hidraw rule helps.

root@asl-tf3hr:~# pip install hid
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.

It might be nice to have the ASL packages help prepare the environment for those who want to use an AIOC to build a node. This rule could be installed by default or commented out with an explanation like the USB VID:PID for AIOC is in res_usbradio.conf.

Thanks and 73
Hrafnkell TF3HR

I have no problem adding the udev rule. But we're not going to install non-Debian Python libraries. That leads to madness.

Update 90-asl3.rules · AllStarLink/asl3-asterisk@fb0c39d

Sounds good to me. I wasn't expecting the hid python lib to be installed. I was mainly documenting what it took for me to get this to work if others could benefit.