aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Szyprowski2020-12-22 11:32:23 +0100
committerMarek Vasut2021-01-31 14:08:56 +0100
commit9129f2f16488e95f8a71bb87937397aaf333bc1b (patch)
tree418451b37dd45ec8b6878d7a6f18b8170301e1cc
parentc533f94c102127b94abda206dbe41fe026bcde76 (diff)
dfu: add support for the dfu_alt_info reintialization from the flashed script
Reinitialize DFU USB gadget after flashing the 'SCRIPT' entity to ensure that the potential changes to the 'dfu_alt_info' environment variable are applied. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> [lukma - I've moved the bool retry to avoid build (CI) errors]
-rw-r--r--cmd/dfu.c13
-rw-r--r--common/dfu.c3
2 files changed, 14 insertions, 2 deletions
diff --git a/cmd/dfu.c b/cmd/dfu.c
index 7310595a027..ef4f897ce07 100644
--- a/cmd/dfu.c
+++ b/cmd/dfu.c
@@ -34,7 +34,6 @@ static int do_dfu(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
#if defined(CONFIG_DFU_TIMEOUT) || defined(CONFIG_DFU_OVER_TFTP)
unsigned long value = 0;
#endif
-
if (argc >= 4) {
interface = argv[2];
devstring = argv[3];
@@ -67,8 +66,18 @@ static int do_dfu(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
}
int controller_index = simple_strtoul(usb_controller, NULL, 0);
+ bool retry = false;
+ do {
+ run_usb_dnl_gadget(controller_index, "usb_dnl_dfu");
- run_usb_dnl_gadget(controller_index, "usb_dnl_dfu");
+ if (dfu_reinit_needed) {
+ dfu_free_entities();
+ ret = dfu_init_env_entities(interface, devstring);
+ if (ret)
+ goto done;
+ retry = true;
+ }
+ } while (retry);
done:
dfu_free_entities();
diff --git a/common/dfu.c b/common/dfu.c
index d23cf67f194..16bd1ba588a 100644
--- a/common/dfu.c
+++ b/common/dfu.c
@@ -98,6 +98,9 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
}
#endif
+ if (dfu_reinit_needed)
+ goto exit;
+
WATCHDOG_RESET();
usb_gadget_handle_interrupts(usbctrl_index);
}