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 <fabian.pflug@gumulka.eu>
diff --git a/boot/zephyr/main.c b/boot/zephyr/main.c
index ccabc28..fe0016c 100644
--- a/boot/zephyr/main.c
+++ b/boot/zephyr/main.c
@@ -531,6 +531,14 @@
* 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;