summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/dfu.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/common/dfu.c b/common/dfu.c
index 44d1484d3d..da6289b218 100644
--- a/common/dfu.c
+++ b/common/dfu.c
@@ -35,6 +35,10 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
return CMD_RET_FAILURE;
}
+#ifdef CONFIG_DFU_TIMEOUT
+ unsigned long start_time = get_timer(0);
+#endif
+
while (1) {
if (g_dnl_detach()) {
/*
@@ -79,6 +83,19 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
}
}
+#ifdef CONFIG_DFU_TIMEOUT
+ unsigned long wait_time = dfu_get_timeout();
+
+ if (wait_time) {
+ unsigned long current_time = get_timer(start_time);
+
+ if (current_time > wait_time) {
+ debug("Inactivity timeout, abort DFU\n");
+ goto exit;
+ }
+ }
+#endif
+
WATCHDOG_RESET();
usb_gadget_handle_interrupts(usbctrl_index);
}