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
5e966ccc3c
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>
This commit is contained in:
committed by
Marek Vasut
parent
2b1f8c2bdf
commit
98a8f445fd
15
cmd/dfu.c
15
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
|
||||
|
||||
Reference in New Issue
Block a user