dfu: add support for dfu_alt_info reintialization from the flashed script 42/248842/2
authorMarek Szyprowski <m.szyprowski@samsung.com>
Wed, 2 Dec 2020 12:56:19 +0000 (13:56 +0100)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Thu, 3 Dec 2020 16:53:18 +0000 (17:53 +0100)
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>
Change-Id: Ia5025c765c83defc96da17b8c059dff833ec257b

cmd/dfu.c
common/dfu.c

index 52240db..5188981 100644 (file)
--- a/cmd/dfu.c
+++ b/cmd/dfu.c
@@ -34,6 +34,7 @@ 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
+       bool retry = false;
 
        if (argc >= 4) {
                interface = argv[2];
@@ -94,7 +95,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);
 
-       run_usb_dnl_gadget(controller_index, "usb_dnl_dfu");
+       do {
+               retry = false;
+               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();
index d23cf67..16bd1ba 100644 (file)
@@ -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);
        }