public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] dfu: Prevent set_dfu_alt_info() from overwriting a previous value
@ 2024-12-17 20:48 Jonathan Humphreys
  2024-12-18  4:54 ` Siddharth Vadapalli
  2024-12-18 12:28 ` Mattijs Korpershoek
  0 siblings, 2 replies; 12+ messages in thread
From: Jonathan Humphreys @ 2024-12-17 20:48 UTC (permalink / raw)
  To: Rasmus Villemoes, Caleb Connolly, Tom Rini, Mattijs Korpershoek,
	Lukasz Majewski, s-vadapalli
  Cc: u-boot, Jonathan Humphreys

If CONFIG_SET_DFU_ALT_INFO is enabled, the dfu_alt_info environment
variable is dynamically set when initializing the DFU entities, which is
done as part of normal flow of a DFU operation.

The USB DFU boot support will set it's own specific value for dfu_alt_info
before performing the DFU operation. This means that if
CONFIG_SET_DFU_ALT_INFO is enabled, the dfu_alt_info environment variable
that the USB DFU boot path had set is overwritten, causing USB DFU boot to
fail.

Likewise, if the user sets their own value for dfu_alt_info, say at the
U-Boot prompt, it get's overwritten if CONFIG_SET_DFU_ALT_INFO is enabled.

This patch will first check that dfu_alt_info isn't already set before
calling set_dfu_alt_info(), when CONFIG_SET_DFU_ALT_INFO is enabled.

Signed-off-by: Jonathan Humphreys <j-humphreys@ti.com>
---
 drivers/dfu/dfu.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 756569217bb..ab8abae1d89 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -169,10 +169,13 @@ int dfu_init_env_entities(char *interface, char *devstr)
 	dfu_reinit_needed = false;
 	dfu_alt_info_changed = false;
 
+	str_env = env_get("dfu_alt_info");
 #ifdef CONFIG_SET_DFU_ALT_INFO
-	set_dfu_alt_info(interface, devstr);
+	if (!str_env) {
+		set_dfu_alt_info(interface, devstr);
+		str_env = env_get("dfu_alt_info");
+	}
 #endif
-	str_env = env_get("dfu_alt_info");
 	if (!str_env) {
 		pr_err("\"dfu_alt_info\" env variable not defined!\n");
 		return -EINVAL;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-02-04 14:31 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-17 20:48 [PATCH] dfu: Prevent set_dfu_alt_info() from overwriting a previous value Jonathan Humphreys
2024-12-18  4:54 ` Siddharth Vadapalli
2024-12-18 12:28 ` Mattijs Korpershoek
2024-12-18 23:09   ` Jon Humphreys
2025-01-16  8:37     ` Mattijs Korpershoek
2025-01-16  9:35       ` Ilias Apalodimas
2025-01-16  9:39       ` Sughosh Ganu
2025-01-16 22:02         ` Jon Humphreys
2025-01-17 10:47           ` Ilias Apalodimas
2025-02-03 21:38             ` Jon Humphreys
2025-02-04 12:57               ` Ilias Apalodimas
2025-02-04 14:31               ` Mattijs Korpershoek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox