Skip to content

Commit 5c38bc8

Browse files
committed
fix issue nrf52840 not reset properly when upgrading bootloader+sd combo
- root cause tusb_task()/cdc task is called when usb is not inited (in case of sd upgrade)
1 parent fc13287 commit 5c38bc8

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ SD_HEX = $(SD_PATH)/$(SD_FILENAME)_softdevice.hex
2828
LD_FILE = $(SRC_PATH)/linker/$(SD_NAME)_v$(SD_VER1).ld
2929

3030
MERGED_FNAME = $(OUTPUT_FILENAME)_$(SD_NAME)_$(SD_VERSION)
31-
RELEASE_DIR = bin/$(BOARD)/$(SD_VERSION)
31+
RELEASE_DIR = bin/$(BOARD)
3232

3333

3434
MK_DIS_FIRMWARE = "$(SD_NAME) $(SD_VERSION)"

lib/sdk11/components/libraries/bootloader_dfu/bootloader.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ static void wait_for_events(void)
128128
app_sched_execute();
129129

130130
#ifdef NRF52840_XXAA
131-
// usb is not enabled in OTA
132-
if ( !is_ota() )
131+
// skip if usb is not inited ( e.g OTA / finializing sd/bootloader )
132+
extern bool usb_inited(void);
133+
if ( usb_inited() )
133134
{
134135
tusb_task();
135136
tud_cdc_write_flush();

src/usb/usb.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,20 @@ extern void tusb_hal_nrf_power_event(uint32_t event);
6565

6666

6767
//------------- IMPLEMENTATION -------------//
68+
static bool _inited = false;
69+
70+
bool usb_inited(void)
71+
{
72+
return _inited;
73+
}
74+
6875
void usb_init(bool cdc_only)
6976
{
77+
// skipped if already inited
78+
if ( _inited ) return;
79+
80+
_inited = true;
81+
7082
// USB power may already be ready at this time -> no event generated
7183
// We need to invoke the handler based on the status initially
7284
uint32_t usb_reg;

0 commit comments

Comments
 (0)