Custom NRF52840 USB

Hello,

I am developing a product with the nrf52840 + npm1100 for battery management. I added a usb connection for serial communication, connected as suggested by the reference design of the npm1100 (https://docs.nordicsemi.com/bundle/nwp_040/page/WP/nwp_040/reference_schematic.html).

I am trying to get USB working, but the samples provided by nordic do not even build. Are there any USB samples that work for the nrf52840 (I also have the nrf52840DK board)?

The closest I have gotten is the testusb sample, but it always fails at "error: multiple registrations at table_index 39 for irq 39". I know that this is commonly the case when both the legacy and the new usb drivers are enabled, but this isnt the case in the sample. Here is the proj.conf, where clearly the new usb driver is enabled:

CONFIG_USB_DEVICE_STACK_NEXT=y
CONFIG_USBD_LOOPBACK_CLASS=y
CONFIG_UDC_BUF_POOL_SIZE=4096

CONFIG_LOG=y
CONFIG_USBD_LOG_LEVEL_ERR=y
CONFIG_UDC_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USBD_LOOPBACK_LOG_LEVEL_ERR=y

CONFIG_SAMPLE_USBD_PID=0x0009
CONFIG_SAMPLE_USBD_PRODUCT="Zephyr testusb sample"

Log:

-- Configuring done
-- Generating done
-- Build files have been written to: E:/ncs/v3.1.1/zephyr/samples/subsys/usb/testusb/build/testusb
[170/173] Generating isr_tables.c, isr_tables_vt.ld, isr_tables_swi.ld
FAILED: zephyr/isr_tables.c zephyr/isr_tables_vt.ld zephyr/isr_tables_swi.ld E:/ncs/v3.1.1/zephyr/samples/subsys/usb/testusb/build/testusb/zephyr/isr_tables.c E:/ncs/v3.1.1/zephyr/samples/subsys/usb/t
estusb/build/testusb/zephyr/isr_tables_vt.ld E:/ncs/v3.1.1/zephyr/samples/subsys/usb/testusb/build/testusb/zephyr/isr_tables_swi.ld
cmd.exe /C "cd /D E:\ncs\v3.1.1\zephyr\samples\subsys\usb\testusb\build\testusb\zephyr && E:\ncs\toolchains\c1a76fddb2\opt\bin\python.exe E:/ncs/v3.1.1/zephyr/scripts/build/gen_isr_tables.py --output-
source isr_tables.c --linker-output-files isr_tables_vt.ld isr_tables_swi.ld --kernel E:/ncs/v3.1.1/zephyr/samples/subsys/usb/testusb/build/testusb/zephyr/zephyr_pre0.elf --intlist-section .intList --
intlist-section intList --sw-isr-table --vector-table"
gen_isr_tables.py: error: multiple registrations at table_index 39 for irq 39 (0x27)
Existing handler 0xb3eb, new handler 0xb3eb
Has IRQ_CONNECT or IRQ_DIRECT_CONNECT accidentally been invoked on the same irq multiple times?

Are the samples out of date or am I doing something wrong? I compile using the VS code nRF Connect addon, with sdk version 3.1.1.

Thanks for your help in advance.

BR

Christoph

  • Hi,

     

    I took the subsys/usb/testusb sample, and compiled it with the "npm1100_ek" shield:

    west build -b nrf52840dk/nrf52840 -- -DSHIELD=npm1100_ek

     

    Alternative is to do this in vscode:

    This shall compile out-of-the-box without any errors.

     

    I added a usb connection for serial communication, connected as suggested by the reference design of the npm1100

    Can you share exactly what you added/changed?

     

    Kind regards,

    Håkon

Related