dfu: Introduce CONFIG_BOOT_WAIT_FOR_USB_DFU

This Kconfig parameter makes MCUboot wait for a prescribed duration
of time to allow for USB DFU to be invoked.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
This commit is contained in:
Rajavardhan Gundi 2019-02-20 14:08:52 +05:30 committed by Andrzej Puzdrowski
parent 048168aa37
commit 51c9d707fb
2 changed files with 21 additions and 0 deletions

View File

@ -122,6 +122,17 @@ config BOOT_ERASE_PROGRESSIVELY
on some hardware that has long erase times, to prevent long wait on some hardware that has long erase times, to prevent long wait
times at the beginning of the DFU process. times at the beginning of the DFU process.
config BOOT_WAIT_FOR_USB_DFU
bool "Wait for a prescribed duration to see if USB DFU is invoked"
default n
select USB
select USB_DFU_CLASS
select IMG_MANAGER
help
If y, MCUboot waits for a prescribed duration of time to allow
for USB DFU to be invoked. Please note DFU always updates the
slot1 image.
config ZEPHYR_TRY_MASS_ERASE config ZEPHYR_TRY_MASS_ERASE
bool "Try to mass erase flash when flashing MCUboot image" bool "Try to mass erase flash when flashing MCUboot image"
default y default y

View File

@ -40,6 +40,10 @@ const struct boot_uart_funcs boot_funcs = {
}; };
#endif #endif
#ifdef CONFIG_BOOT_WAIT_FOR_USB_DFU
#include <usb/class/usb_dfu.h>
#endif
MCUBOOT_LOG_MODULE_REGISTER(mcuboot); MCUBOOT_LOG_MODULE_REGISTER(mcuboot);
void os_heap_init(void); void os_heap_init(void);
@ -197,6 +201,12 @@ void main(void)
} }
#endif #endif
#ifdef CONFIG_BOOT_WAIT_FOR_USB_DFU
BOOT_LOG_INF("Waiting for USB DFU");
wait_for_usb_dfu();
BOOT_LOG_INF("USB DFU wait time elapsed");
#endif
rc = boot_go(&rsp); rc = boot_go(&rsp);
if (rc != 0) { if (rc != 0) {
BOOT_LOG_ERR("Unable to find bootable image"); BOOT_LOG_ERR("Unable to find bootable image");