Skip to content

Commit

Permalink
boot: zephyr: Add fallback to USB DFU
Browse files Browse the repository at this point in the history
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 <fabian.pflug@gumulka.eu>
  • Loading branch information
gumulka authored and nordicjm committed Sep 12, 2024
1 parent 84b56b6 commit ca06b9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions boot/zephyr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,12 @@ config BOOT_USB_DFU_DETECT_DELAY

endif # BOOT_USB_DFU_GPIO

config BOOT_USB_DFU_NO_APPLICATION
bool "Stay in bootloader if no application"
help
Allows for entering USB DFU recovery mode if there is no bootable
application that the bootloader can jump to.

config BOOT_USE_BENCH
bool "Enable benchmark code"
default n
Expand Down
8 changes: 8 additions & 0 deletions boot/zephyr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,14 @@ int main(void)
* recovery mode
*/
boot_serial_enter();
#elif defined(CONFIG_BOOT_USB_DFU_NO_APPLICATION)
rc = usb_enable(NULL);
if (rc && rc != -EALREADY) {
BOOT_LOG_ERR("Cannot enable USB");
} else {
BOOT_LOG_INF("Waiting for USB DFU");
wait_for_usb_dfu(K_FOREVER);
}
#endif

FIH_PANIC;
Expand Down

0 comments on commit ca06b9f

Please sign in to comment.