Skip to content

Commit 34d7644

Browse files
gumulkarlubos
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 29646ac commit 34d7644

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

boot/zephyr/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,12 @@ config BOOT_USB_DFU_DETECT_DELAY
748748

749749
endif # BOOT_USB_DFU_GPIO
750750

751+
config BOOT_USB_DFU_NO_APPLICATION
752+
bool "Stay in bootloader if no application"
753+
help
754+
Allows for entering USB DFU recovery mode if there is no bootable
755+
application that the bootloader can jump to.
756+
751757
config BOOT_USE_BENCH
752758
bool "Enable benchmark code"
753759
default n

boot/zephyr/main.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,14 @@ int main(void)
566566
* recovery mode
567567
*/
568568
boot_serial_enter();
569+
#elif defined(CONFIG_BOOT_USB_DFU_NO_APPLICATION)
570+
rc = usb_enable(NULL);
571+
if (rc && rc != -EALREADY) {
572+
BOOT_LOG_ERR("Cannot enable USB");
573+
} else {
574+
BOOT_LOG_INF("Waiting for USB DFU");
575+
wait_for_usb_dfu(K_FOREVER);
576+
}
569577
#endif
570578

571579
FIH_PANIC;

0 commit comments

Comments
 (0)