undefined reference to usbd_enable

I been trying to figure this out but to no avail. I get these errors on build.

:/ncs/toolchains/b620d30767/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(main.c.obj): in function `main':
main.c:3499: undefined reference to `usbd_add_descriptor'
c:/ncs/toolchains/b620d30767/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: main.c:3506: undefined reference to `usbd_add_descriptor'
c:/ncs/toolchains/b620d30767/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: main.c:3513: undefined reference to `usbd_add_descriptor'
c:/ncs/toolchains/b620d30767/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: main.c:3548: undefined reference to `usbd_enable'
c:/ncs/toolchains/b620d30767/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(main.c.obj):(._usbd_context.static.usbdev_+0x18): undefined reference to `__device_dts_ord_133'
collect2.exe: error: ld returned 1 exit status

In my Kconfig file:

#for physical usb connection
CONFIG_NRF_USBD_COMMON=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_BOS=y
I am using sdk v2.9.0.
I have tried everything I could find; any help would be appreciated.
Parents
  • It is a bit difficult to say the exact reason without having your build folder, but if you look in the file:

    build\<app_name>\zephyr\include\generated\zephyr\devicetree_generated.h, you can look up the node number and names. What matches your node number 133? (it may have changed, so check the build log in your latest build). 

    I assume it is something like /soc/usbd@40027000 or /soc/usbd@40027000/cdc_acm_uart0, or something like that, since it points to the usbd_enable(). 

    Then compare your prj.conf to the prj.conf of a working usb application, such as the NCS\zephyr\samples\subsys\usb\cdc_acm. Are there any definitions missing? 

    Have the usb been enabled in the devicetree?

    Try adding an nrf52840dk_nrf52840.devicetree (or <board_name>.devicetree, if you are not building for the nrf52840dk_nrf52840). In that, try adding:

    &zephyr_udc0 {
    	cdc_acm_uart0 {
    		compatible = "zephyr,cdc-acm-uart";
    	};
    };
    

    (in fact, if you are building for the nRF52840 DK, you can add this in a file called app.overlay in your application's root folder.)

    If that doesn't work, please let me know what board you are building for, and also consider .zipping and uploading your application folder here, so that I can try to replicate it on my end.

    Best regards,

    Edvin

  • Thanks for your help Edvin. The solution turned out to be a disabling CONFIG_USB_DEVICE_STACK and enabling CONFIG_USB_DEVICE_STACK_NEXT. I could not finding anything in the zephyr documentation that mentioned this and am pretty frustrated that this was not documented appropriately. Anyways the problem is now solved, Thank you for your help.

Reply
  • Thanks for your help Edvin. The solution turned out to be a disabling CONFIG_USB_DEVICE_STACK and enabling CONFIG_USB_DEVICE_STACK_NEXT. I could not finding anything in the zephyr documentation that mentioned this and am pretty frustrated that this was not documented appropriately. Anyways the problem is now solved, Thank you for your help.

Children
No Data
Related