Skip to contentSkip to conversation

cmd: Remove default prompt from output

PATCH In review Daniel Schultz 4 participants 4 messages Aug 15, 2025 – Sep 1, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: Remove default prompt from output

Some commands include the U-Boot prompt (=>) in their output, which can interfere with tools like labgrid that rely on prompt detection to determine when a command has completed. This may cause such tools to misinterpret partial output.

To avoid this issue, it's better to update the command output itself rather than modifying the actual U-Boot prompt. Changing the prompt is not acceptable in many cases, as some boards have used the default prompt (=>) for years, and altering it - especially just for testing - could lead to inconsistencies or unintended side effects. Instead, replace instances of the prompt that appear within command output (not the real prompt) with an alternative like -> to ensure correct parsing by tools that rely on prompt recognition.

---
 cmd/i2c.c      |  2 +-
 cmd/mtdparts.c | 12 ++++++------
 common/hash.c  |  6 +++---
 3 files changed, 10 insertions(+), 10 deletions(-)
cmd/i2c.c +1 -1
index e021067e68a..f7695047629 100644
@@ -715,7 +715,7 @@ static int do_i2c_crc(struct cmd_tbl *cmdtp, int flag, int argc,
 	 */
 	count = hextoul(argv[3], NULL);
 
-	printf ("CRC32 for %08lx ... %08lx ==> ", addr, addr + count - 1);
+	printf("CRC32 for %08lx ... %08lx --> ", addr, addr + count - 1);
 	/*
 	 * CRC a byte at a time.  This is going to be slooow, but hey, the
 	 * memories are small and slow too so hopefully nobody notices.
cmd/mtdparts.c +6 -6
index 571b79f091d..48d06f2e000 100644
@@ -242,7 +242,7 @@ static void index_partitions(void)
 			if (dev == current_mtd_dev) {
 				mtddevnum += current_mtd_partnum;
 				env_set_ulong("mtddevnum", mtddevnum);
-				debug("=> mtddevnum %d,\n", mtddevnum);
+				debug("-> mtddevnum %d,\n", mtddevnum);
 				break;
 			}
 			mtddevnum += dev->num_parts;
@@ -252,17 +252,17 @@ static void index_partitions(void)
 		if (part) {
 			env_set("mtddevname", part->name);
 
-			debug("=> mtddevname %s\n", part->name);
+			debug("-> mtddevname %s\n", part->name);
 		} else {
 			env_set("mtddevname", NULL);
 
-			debug("=> mtddevname NULL\n");
+			debug("-> mtddevname NULL\n");
 		}
 	} else {
 		env_set("mtddevnum", NULL);
 		env_set("mtddevname", NULL);
 
-		debug("=> mtddevnum NULL\n=> mtddevname NULL\n");
+		debug("-> mtddevnum NULL\n-> mtddevname NULL\n");
 	}
 }
 
@@ -282,12 +282,12 @@ static void current_save(void)
 		env_set("partition", buf);
 		strncpy(last_partition, buf, 16);
 
-		debug("=> partition %s\n", buf);
+		debug("-> partition %s\n", buf);
 	} else {
 		env_set("partition", NULL);
 		last_partition[0] = '\0';
 
-		debug("=> partition NULL\n");
+		debug("-> partition NULL\n");
 	}
 	index_partitions();
 }
common/hash.c +3 -3
index 0c45992d5c7..07a4df963ad 100644
@@ -535,7 +535,7 @@ static void hash_show(struct hash_algo *algo, ulong addr, ulong len, uint8_t *ou
 {
 	int i;
 
-	printf("%s for %08lx ... %08lx ==> ", algo->name, addr, addr + len - 1);
+	printf("%s for %08lx ... %08lx --> ", algo->name, addr, addr + len - 1);
 	for (i = 0; i < algo->digest_size; i++)
 		printf("%02x", output[i]);
 }
@@ -621,8 +621,8 @@ int hash_command(const char *algo_name, int flags, struct cmd_tbl *cmdtp,
 
 		crc = crc32_wd(0, (const uchar *)addr, len, CHUNKSZ_CRC32);
 
-		printf("CRC32 for %08lx ... %08lx ==> %08lx\n",
-				addr, addr + len - 1, crc);
+		printf("CRC32 for %08lx ... %08lx --> %08lx\n",
+		       addr, addr + len - 1, crc);
 
 		if (argc >= 3) {
 			ptr = (ulong *)hextoul(argv[0], NULL);
Signature · 1 line
2.25.1
#1 lore raw
Quoted 14 lines · Daniel Schultz

Some commands include the U-Boot prompt (=>) in their output, which can interfere with tools like labgrid that rely on prompt detection to determine when a command has completed. This may cause such tools to misinterpret partial output.

To avoid this issue, it's better to update the command output itself rather than modifying the actual U-Boot prompt. Changing the prompt is not acceptable in many cases, as some boards have used the default prompt (=>) for years, and altering it - especially just for testing - could lead to inconsistencies or unintended side effects. Instead, replace instances of the prompt that appear within command output (not the real prompt) with an alternative like -> to ensure correct parsing by tools that rely on prompt recognition.

Quoted 6 lines
---
 cmd/i2c.c      |  2 +-
 cmd/mtdparts.c | 12 ++++++------
 common/hash.c  |  6 +++---
 3 files changed, 10 insertions(+), 10 deletions(-)

This is two cases, and I'm not sure I like the proposal here, sorry. For cmd/mtdparts.c, it's debug statements. We can change them, but are they also enabled by default in anything? The other cases, we're changing output along the lines of:

cmd/i2c.c static int do_i2c_crc(struct cmd_tbl *cmdtp, int flag, int argc, · line 718

Quoted 2 lines
cmd/i2c.c +1 -1
-	printf ("CRC32 for %08lx ... %08lx ==> ", addr, addr + count - 1);
+	printf("CRC32 for %08lx ... %08lx --> ", addr, addr + count - 1);

In each case, and I'm surprised there's not testing that globs on that today. I see the wget case that uses "==>" and we do have a test that checks it, today. Is your testing framework not able to handle "=>" in the middle of a line? Thanks.

Signature · 1 line
Tom
#2 lore raw

Hi Daniel, Tom,

Quoted 28 lines · Tom Rini
Quoted 14 lines · Daniel Schultz

Some commands include the U-Boot prompt (=>) in their output, which can interfere with tools like labgrid that rely on prompt detection to determine when a command has completed. This may cause such tools to misinterpret partial output.

To avoid this issue, it's better to update the command output itself rather than modifying the actual U-Boot prompt. Changing the prompt is not acceptable in many cases, as some boards have used the default prompt (=>) for years, and altering it - especially just for testing - could lead to inconsistencies or unintended side effects. Instead, replace instances of the prompt that appear within command output (not the real prompt) with an alternative like -> to ensure correct parsing by tools that rely on prompt recognition.

Quoted 6 lines
---
  cmd/i2c.c      |  2 +-
  cmd/mtdparts.c | 12 ++++++------
  common/hash.c  |  6 +++---
  3 files changed, 10 insertions(+), 10 deletions(-)

This is two cases, and I'm not sure I like the proposal here, sorry. For cmd/mtdparts.c, it's debug statements. We can change them, but are they also enabled by default in anything? The other cases, we're changing output along the lines of:

Quoted 8 lines

cmd/i2c.c static int do_i2c_crc(struct cmd_tbl *cmdtp, int flag, int argc, · line 718

Quoted 2 lines
cmd/i2c.c +1 -1
-	printf ("CRC32 for %08lx ... %08lx ==> ", addr, addr + count - 1);
+	printf("CRC32 for %08lx ... %08lx --> ", addr, addr + count - 1);

In each case, and I'm surprised there's not testing that globs on that today. I see the wget case that uses "==>" and we do have a test that checks it, today. Is your testing framework not able to handle "=>" in the middle of a line? Thanks.

In the case of labgrid, I assume this should be possible.

c.f. https://labgrid.readthedocs.io/en/latest/configuration.html#ubootdriver

Arguments:

prompt (regex, default=””): U-Boot prompt to match

I assume you just want to be using

UBootDriver:
prompt: '^=> '

instead of simply using '=> ' ?

While SYS_PROMPT defaults to => for anything but the Zynq architecture, it can be set from defconfigs as well and look what we have here:

configs/brcp150_defconfig
63:CONFIG_SYS_PROMPT="-> "

configs/brcp170_defconfig
62:CONFIG_SYS_PROMPT="-> "

configs/brcp1_1r_defconfig
62:CONFIG_SYS_PROMPT="-> "

configs/brcp1_1r_switch_defconfig
62:CONFIG_SYS_PROMPT="-> "

configs/brcp1_2r_defconfig
62:CONFIG_SYS_PROMPT="-> "

configs/brsmarc2_defconfig
62:CONFIG_SYS_PROMPT="-> "

So now we would be breaking those users instead. I'm not sure it's a good idea for U-Boot to do this, we'll never find a way to have the prompt never repeated in log messages for all supported platforms. You can always fix those in your own fork if you want though. But I fear this will be the beginning of an endless loop of revert commits because it broke one's CI.

Cheers,
Quentin

#3 lore raw
In reply to Tom Rini

Hi Daniel,

Quoted 28 lines · Tom Rini
Quoted 14 lines · Daniel Schultz

Some commands include the U-Boot prompt (=>) in their output, which can interfere with tools like labgrid that rely on prompt detection to determine when a command has completed. This may cause such tools to misinterpret partial output.

To avoid this issue, it's better to update the command output itself rather than modifying the actual U-Boot prompt. Changing the prompt is not acceptable in many cases, as some boards have used the default prompt (=>) for years, and altering it - especially just for testing - could lead to inconsistencies or unintended side effects. Instead, replace instances of the prompt that appear within command output (not the real prompt) with an alternative like -> to ensure correct parsing by tools that rely on prompt recognition.

Quoted 6 lines
---
  cmd/i2c.c      |  2 +-
  cmd/mtdparts.c | 12 ++++++------
  common/hash.c  |  6 +++---
  3 files changed, 10 insertions(+), 10 deletions(-)

This is two cases, and I'm not sure I like the proposal here, sorry. For cmd/mtdparts.c, it's debug statements. We can change them, but are they also enabled by default in anything? The other cases, we're changing output along the lines of:

Quoted 7 lines

cmd/i2c.c static int do_i2c_crc(struct cmd_tbl *cmdtp, int flag, int argc, · line 718

Quoted 2 lines
cmd/i2c.c +1 -1
-	printf ("CRC32 for %08lx ... %08lx ==> ", addr, addr + count - 1);
+	printf("CRC32 for %08lx ... %08lx --> ", addr, addr + count - 1);

In each case, and I'm surprised there's not testing that globs on that today. I see the wget case that uses "==>" and we do have a test that checks it, today. Is your testing framework not able to handle "=>" in the middle of a line? Thanks.

That would be exactly also my question ... fix the tool instead?

Changing this output may breaks automated tests with other tools...

for example tbot handles this case:

https://tbot.tools/modules/machine_channel.html#tbot.machine.channel.Channel.read_until_prompt

bye,
Heiko

Signature · 5 lines
Nabla Software Engineering
HRB 40522 Augsburg
Phone: +49 821 45592596
E-Mail: [email protected]
Geschäftsführer : Stefano Babic