From: Alexander Koch Date: Thu, 11 Jun 2026 22:48:34 +0000 (+0200) Subject: env: Avoid mixing of environment and driver prints on env load X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a51f24ac31fbb910afc66824e8299a417b297536;p=thirdparty%2Fu-boot.git env: Avoid mixing of environment and driver prints on env load The current environment loading code prints a partial string "Loading Environment from %s..." and then triggers env driver loading function. That env driver loading function may trigger further prints, either from the env driver itself or from any other driver that gets probed at that time. The result is a print which mixed environment loading code prints and driver code prints, as follows: " Environment code print _________________________ vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv vv Loading Environment from SPIFlash... SF: Detected w25q128jw... OK ^^^^^^^^^^^^^^^^^^^^^^ Driver code print " Adjust the environment loading code print such, that it places CR at the end of the line. This way, when the driver code prints something, it overwrites the previous "Loading Environment from %s" output and the result is not mixed. Furthermore, in case the env was loaded correctly, print the "Loading Environment from %s ... OK" in full again. This either overwrites the "Loading Environment from" message and appends the print with "OK", or, it prints the line in full after all the driver code prints. This is not ideal, but it is the best we can do with only CR and without ANSI control sequences. The result looks as follows: " SF: Detected w25q128jw with page size 256 Bytes, erase size 4 KiB, total 16 MiB Loading Environment from SPIFlash... OK " Signed-off-by: Alexander Koch Signed-off-by: Marek Vasut --- diff --git a/env/env.c b/env/env.c index 7a9c96b4078..404e8b7a26c 100644 --- a/env/env.c +++ b/env/env.c @@ -189,7 +189,7 @@ int env_load(void) if (!env_has_inited(drv->location)) continue; - printf("Loading Environment from %s... ", drv->name); + printf("Loading Environment from %s...\r", drv->name); /* * In error case, the error message must be printed during * drv->load() in some underlying API, and it must be exactly @@ -197,7 +197,7 @@ int env_load(void) */ ret = drv->load(); if (!ret) { - printf("OK\n"); + printf("Loading Environment from %s... OK\n", drv->name); gd->env_load_prio = prio; return 0; @@ -206,7 +206,7 @@ int env_load(void) if (best_prio == -1) best_prio = prio; } else { - debug("Failed (%d)\n", ret); + debug("Loading Environment from %s... Failed (%d)\n", drv->name, ret); } }