summaryrefslogtreecommitdiff
path: root/cmd/dfu.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2019-11-27 19:12:15 +0300
committerMarek Vasut <marek.vasut+renesas@gmail.com>2020-01-07 16:37:50 +0300
commit98a8f445fd6b93988340d845c96fd47ff454e895 (patch)
treee1452a58cfedbce315b95651ce9908c721b904ba /cmd/dfu.c
parent2b1f8c2bdfe5f874233df221f037e1494bb8f875 (diff)
downloadu-boot-98a8f445fd6b93988340d845c96fd47ff454e895.tar.xz
dfu: Add optional timeout parameter
When the `dfu` command is called from the U-Boot environment, it now accepts an optional parameter that specifies a timeout (in seconds). If a DFU connection is not made within that time the `dfu` command exits (as it would if Ctrl+C was pressed). If the timeout is left empty or being zero the `dfu` command behaves as it does now. This is useful for allowing U-Boot to check to see if anything wants to upload new firmware before continuing to boot. The patch is based on the commit https://github.com/01org/edison-u-boot/commit/5e966ccc3c65c18c9783741fa04e0c45e021780c by Sebastien Colleur, which has been heavily reworked due to U-Boot changes in the past. Signed-off-by: Brad Campbell <bradjc5@gmail.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Diffstat (limited to 'cmd/dfu.c')
-rw-r--r--cmd/dfu.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/cmd/dfu.c b/cmd/dfu.c
index 14a8ec879e..b30f8a5667 100644
--- a/cmd/dfu.c
+++ b/cmd/dfu.c
@@ -30,7 +30,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#if defined(CONFIG_DFU_OVER_USB) || defined(CONFIG_DFU_OVER_TFTP)
char *interface = NULL;
char *devstring = NULL;
-#if defined(CONFIG_DFU_OVER_TFTP)
+#if defined(CONFIG_DFU_TIMEOUT) || defined(CONFIG_DFU_OVER_TFTP)
unsigned long value = 0;
#endif
@@ -39,7 +39,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
devstring = argv[3];
}
-#if defined(CONFIG_DFU_OVER_TFTP)
+#if defined(CONFIG_DFU_TIMEOUT) || defined(CONFIG_DFU_OVER_TFTP)
if (argc == 5 || argc == 3)
value = simple_strtoul(argv[argc - 1], NULL, 0);
#endif
@@ -55,6 +55,10 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (ret)
goto done;
+#ifdef CONFIG_DFU_TIMEOUT
+ dfu_set_timeout(value * 1000);
+#endif
+
ret = CMD_RET_SUCCESS;
if (strcmp(argv[argc - 1], "list") == 0) {
dfu_show_entities();
@@ -75,10 +79,17 @@ U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,
"Device Firmware Upgrade",
""
#ifdef CONFIG_DFU_OVER_USB
+#ifdef CONFIG_DFU_TIMEOUT
+ "<USB_controller> [<interface> <dev>] [<timeout>] [list]\n"
+#else
"<USB_controller> [<interface> <dev>] [list]\n"
+#endif
" - device firmware upgrade via <USB_controller>\n"
" on device <dev>, attached to interface\n"
" <interface>\n"
+#ifdef CONFIG_DFU_TIMEOUT
+ " [<timeout>] - specify inactivity timeout in seconds\n"
+#endif
" [list] - list available alt settings\n"
#endif
#ifdef CONFIG_DFU_OVER_TFTP