Hi
first: thank you for your precious support.
second: I do not need an answer
I will avoid the problem I describe below
third: I'm definitely not an expert
don't trust my findings, I might be just wrong
I have an application based on nrf52840 which announces itself as composite USB device providing 3 USB class instances:
CDC ACM, CDC NCM, HID
this worked fine and I did not expect real trouble migrating this to nrf54LM20A
I use NCS version 3.4.0 with Zephyr 4.4
Switching to NCS 3.4.1 did not help
the problem:
the nrf54LM20A board failed to properly register as USB device
on Linux dmesg shows
[ 1304.194658] usb 1-2: new full-speed USB device number 10 using xhci_hcd
[ 1304.354379] usb 1-2: New USB device found, idVendor=4321, idProduct=5678, bcdDevice= 4.04
[ 1304.354393] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1304.354399] usb 1-2: Product: myTestProduct
[ 1304.354404] usb 1-2: Manufacturer: acme.com
[ 1304.354408] usb 1-2: SerialNumber: 4BF4A854D69EF5F7
[ 1309.603708] usb 1-2: can't set config #1, error -110
I tried to reduce complexity and concentrated on FULL SPEED only
prj.conf contains
CONFIG_USB_DEVICE_STACK_NEXT=y
CONFIG_UDC_DRIVER_HIGH_SPEED_SUPPORT_ENABLED=n
CONFIG_USBD_MAX_SPEED_FULL=y
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
CONFIG_CDC_ACM_SERIAL_INITIALIZE_AT_BOOT=n
source code, devicetree and prj.conf are identical for both builds nrf52840 and nrf54LM20A
one of my tests revealed in the debug trace
[00:01:12.531,765] <inf> udc_dwc2: Set FIFO1 (ep 0x81) addr 0x0320 depth 4 size 128
[00:01:12.531,791] <inf> udc_dwc2: Set FIFO2 (ep 0x82) addr 0x0324 depth 16 size 128
[00:01:12.531,828] <inf> udc_dwc2: Set FIFO3 (ep 0x83) addr 0x0334 depth 16 size 128
[00:01:12.531,842] <inf> usbd_iface: No endpoints, skip interface
[00:01:12.531,872] <err> usbd_iface: Failed to handle op 1, ep 0x85, bm 0x00000000, -12
[00:01:12.531,881] <err> usbd_ch9: Failed to set configuration 1, -12
[00:01:12.531,894] <err> usbd_core: Unrecoverable error -12, ep 0x00, buf 0x200177c8
I found the following suspicious:
[00:01:12.531,842] <inf> usbd_iface: No endpoints, skip interface
then configuring ep 0x85 fails
turns out the CDC NCM seems to have an inactive/unused endpoint 0x84
my impression:
for nrf52840 the NRF driver is used which handles this unused endpoint correctly.
but for nrf54LM20A the Zephyr driver is used which fails to handle this situation properly.
the Zephyr driver file ncs/v3.4.0/zephyr/drivers/usb/udc/udc_dwc2.c
contains in line 1099 a function
dwc2_set_dedicated_fifo(...) which can dynamically assign FIFO
this function checks the required FIFO size at line 1162:
txfdep = dwc2_get_txfdep(dev, ep_idx - 1);
txfaddr = dwc2_get_txfaddr(dev, ep_idx - 1);
if (reqdep > txfdep) {
return -ENOMEM;
}
hypothesis:
this check uses the previous endpoints values (ep_idx - 1) to calculate the available FIFO size.
In case the previous endpoint is not used this calculation fails and -ENOMEM is returned.
I managed to proof this code actually returns said error at exactly this point.
my solution/workaround:
instead of using usbd_register_all_classes(&BaseDeviceUSB, USBD_SPEED_FS, 1, blocklist)
I explicitly call usbd_register_class(..) for each class to make sure NCM with its unused endpoint is registered last.
chatGPT claims the Zephyr driver is being improved and this problem will be solved in future releases.
So I just wait and I expect my workaround to be working fine with future versions too.
best regards
Peter