Skip to content

Commit ca06b9f

Browse files
gumulkanordicjm
authored andcommitted
boot: zephyr: Add fallback to USB DFU
Allow bootloader to fallback to USB DFU if no application is present, that can be booted from. Similar to config BOOT_SERIAL_NO_APPLICATION. Signed-off-by: Fabian Pflug <[email protected]>
1 parent 84b56b6 commit ca06b9f

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

boot/zephyr/Kconfig

+6
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,12 @@ config BOOT_USB_DFU_DETECT_DELAY
573573

574574
endif # BOOT_USB_DFU_GPIO
575575

576+
config BOOT_USB_DFU_NO_APPLICATION
577+
bool "Stay in bootloader if no application"
578+
help
579+
Allows for entering USB DFU recovery mode if there is no bootable
580+
application that the bootloader can jump to.
581+
576582
config BOOT_USE_BENCH
577583
bool "Enable benchmark code"
578584
default n

boot/zephyr/main.c

+8
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,14 @@ int main(void)
531531
* recovery mode
532532
*/
533533
boot_serial_enter();
534+
#elif defined(CONFIG_BOOT_USB_DFU_NO_APPLICATION)
535+
rc = usb_enable(NULL);
536+
if (rc && rc != -EALREADY) {
537+
BOOT_LOG_ERR("Cannot enable USB");
538+
} else {
539+
BOOT_LOG_INF("Waiting for USB DFU");
540+
wait_for_usb_dfu(K_FOREVER);
541+
}
534542
#endif
535543

536544
FIH_PANIC;

0 commit comments

Comments
 (0)