[PATCH 5/5] thor: add support for the dfu_alt_info reintialization from the flashed script
Marek Szyprowski
m.szyprowski at samsung.com
Thu Dec 17 13:10:30 CET 2020
Reinitialize dfu_env_entities 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 at samsung.com>
---
cmd/thordown.c | 19 ++++++++++++-------
drivers/usb/gadget/f_thor.c | 3 +++
include/thor.h | 2 ++
3 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/cmd/thordown.c b/cmd/thordown.c
index ae20dddfdd..838764ccef 100644
--- a/cmd/thordown.c
+++ b/cmd/thordown.c
@@ -52,13 +52,18 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
goto exit;
}
- ret = thor_handle();
- if (ret) {
- pr_err("THOR failed: %d\n", ret);
- ret = CMD_RET_FAILURE;
- goto exit;
- }
-
+ do {
+ ret = thor_handle();
+ if (ret == THOR_DFU_REINIT_NEEDED) {
+ dfu_free_entities();
+ ret = dfu_init_env_entities(interface, devstring);
+ }
+ if (ret) {
+ pr_err("THOR failed: %d\n", ret);
+ ret = CMD_RET_FAILURE;
+ goto exit;
+ }
+ } while (ret == 0);
exit:
g_dnl_unregister();
usb_gadget_release(controller_index);
diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
index 88fc87f2e9..3e69746ee6 100644
--- a/drivers/usb/gadget/f_thor.c
+++ b/drivers/usb/gadget/f_thor.c
@@ -30,6 +30,7 @@
#include <linux/usb/cdc.h>
#include <g_dnl.h>
#include <dfu.h>
+#include <thor.h>
#include "f_thor.h"
@@ -735,6 +736,8 @@ int thor_handle(void)
printf("%s: No data received!\n", __func__);
break;
}
+ if (dfu_reinit_needed)
+ return THOR_DFU_REINIT_NEEDED;
}
return 0;
diff --git a/include/thor.h b/include/thor.h
index 62501bda17..ee67ab0a27 100644
--- a/include/thor.h
+++ b/include/thor.h
@@ -12,6 +12,8 @@
#include <linux/usb/composite.h>
+#define THOR_DFU_REINIT_NEEDED 0xFFFFFFFE
+
int thor_handle(void);
int thor_init(void);
int thor_add(struct usb_configuration *c);
--
2.17.1
More information about the U-Boot
mailing list