Hi,
We are working on a custom bootloader/DFU and is going to use USB CDC to perform DFU and some data transfers for version information. We use the USB CDC library both the bootloader and main application which works when running only the bootloader or only the main application but when starting the main application from the bootloader issues arise with USB CDC.
Specifically when usbd_enable() is called, the stacktrace included below show how we are stuck, waiting for an event. Looking in the source code we are waiting for NRF_USBD_EVENTCAUSE_READY_MASK which never occurs.
0x0002a52a in usbd_eventcause_wait_and_clear (eventcause=<optimized out>) at ../nrf-sdk/modules/nrfx/hal/nrf_usbd.h:1007 (gdb) bt #0 0x0002a52a in usbd_eventcause_wait_and_clear (eventcause=<optimized out>) at ../nrf-sdk/modules/nrfx/hal/nrf_usbd.h:1007 #1 usbd_enable () at ../nrf-sdk/modules/nrfx/drivers/src/nrfx_usbd.c:1577 #2 nrfx_usbd_enable () at ../nrf-sdk/modules/nrfx/drivers/src/nrfx_usbd.c:1720 #3 0x0002d696 in user_event_state_proc (event=APP_USBD_EVT_POWER_DETECTED) at ../nrf-sdk/components/libraries/usbd/app_usbd.c:311 #4 app_usbd_event_execute (p_event=0x30dbc <ev>) at ../nrf-sdk/components/libraries/usbd/app_usbd.c:1300 #5 0x0002e202 in nrfx_power_irq_handler () at ../nrf-sdk/modules/nrfx/drivers/src/nrfx_power.c:304 #6 0x0002e262 in POWER_CLOCK_IRQHandler () at ../nrf-sdk/modules/nrfx/drivers/src/nrfx_power.c:336 #7 <signal handler called> #8 app_usbd_power_events_enable () at ../nrf-sdk/components/libraries/usbd/app_usbd.c:962
Removing "usbd_enable" or even just the wait_and_clear section in the event code makes the program work as expected but it is not a satisfactory solution. We have tried the deinit function (although it has a comment that it is not a supported function) but it does not work.
How is it recommended to initialize usb cdc after using it in a bootloader?
Best Regards