diff --git a/lib/sdk11/components/libraries/bootloader_dfu/bootloader.c b/lib/sdk11/components/libraries/bootloader_dfu/bootloader.c index 72d8d1b..cf9072e 100644 --- a/lib/sdk11/components/libraries/bootloader_dfu/bootloader.c +++ b/lib/sdk11/components/libraries/bootloader_dfu/bootloader.c @@ -128,8 +128,9 @@ static void wait_for_events(void) app_sched_execute(); #ifdef NRF52840_XXAA - // usb is not enabled in OTA - if ( !is_ota() ) + // skip if usb is not inited ( e.g OTA / finializing sd/bootloader ) + extern bool usb_inited(void); + if ( usb_inited() ) { tusb_task(); tud_cdc_write_flush(); diff --git a/src/usb/usb.c b/src/usb/usb.c index f49e6c0..aaebdf4 100644 --- a/src/usb/usb.c +++ b/src/usb/usb.c @@ -65,8 +65,20 @@ extern void tusb_hal_nrf_power_event(uint32_t event); //------------- IMPLEMENTATION -------------// +static bool _inited = false; + +bool usb_inited(void) +{ + return _inited; +} + void usb_init(bool cdc_only) { + // skipped if already inited + if ( _inited ) return; + + _inited = true; + // USB power may already be ready at this time -> no event generated // We need to invoke the handler based on the status initially uint32_t usb_reg;