Skip to contentSkip to conversation

spl: avoid printf when we might be doing Ymodem with CONFIG_SPL_FIT_SIGNATURE

PATCH In review Alex Kiernan 3 participants 6 messages Mar 20, 2019 – Apr 22, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spl: avoid printf when we might be doing Ymodem with CONFIG_SPL_FIT_SIGNATURE

If CONFIG_SPL_FIT_SIGNATURE is enabled and U-Boot is being loaded from UART over Ymodem then we can't emit messages using printf() without causing errors like:

Sending: u-boot-dtb.img
Ymodem sectors/kbytes sent: 3009/376kRetry 0: Got 23 for sector ACK Retry 0: NAK on sector
Retry 0: Got 68 for sector ACK
Retry 0: NAK on sector
Ymodem sectors/kbytes sent: 3273/409kRetry 0: Got 23 for sector ACK Retry 0: NAK on sector
Retry 0: Got 68 for sector ACK
Retry 0: NAK on sector

Use debug() rather than printf() to avoid sending messages on the serial port.

---

 common/spl/spl_fit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
common/spl/spl_fit.c +3 -3
index db436268cbcd..08faf2c1b058 100644
@@ -240,12 +240,12 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 	}
 
 #ifdef CONFIG_SPL_FIT_SIGNATURE
-	printf("## Checking hash(es) for Image %s ... ",
-	       fit_get_name(fit, node, NULL));
+	debug("## Checking hash(es) for Image %s ... ",
+	      fit_get_name(fit, node, NULL));
 	if (!fit_image_verify_with_data(fit, node,
 					 src, length))
 		return -EPERM;
-	puts("OK\n");
+	debug("OK\n");
 #endif
 
 #ifdef CONFIG_SPL_FIT_IMAGE_POST_PROCESS
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 spl: avoid printf when we might be doing Ymodem with CONFIG_SPL_FIT_SIGNATURE

Quoted 31 lines · Alex Kiernan

If CONFIG_SPL_FIT_SIGNATURE is enabled and U-Boot is being loaded from UART over Ymodem then we can't emit messages using printf() without causing errors like:

Sending: u-boot-dtb.img
Ymodem sectors/kbytes sent: 3009/376kRetry 0: Got 23 for sector ACK Retry 0: NAK on sector
Retry 0: Got 68 for sector ACK
Retry 0: NAK on sector
Ymodem sectors/kbytes sent: 3273/409kRetry 0: Got 23 for sector ACK Retry 0: NAK on sector
Retry 0: Got 68 for sector ACK
Retry 0: NAK on sector

Use debug() rather than printf() to avoid sending messages on the serial port.

---

 common/spl/spl_fit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
common/spl/spl_fit.c +0 -0
index db436268cbcd..08faf2c1b058 100644
@@ -240,12 +240,12 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 	}
 
 #ifdef CONFIG_SPL_FIT_SIGNATURE

common/spl/spl_fit.c static int spl_load_fit_image(struct spl_load_info *info, ulong sector, · line 249

Quoted 10 lines
common/spl/spl_fit.c +3 -3
-	printf("## Checking hash(es) for Image %s ... ",
-	       fit_get_name(fit, node, NULL));
+	debug("## Checking hash(es) for Image %s ... ",
+	      fit_get_name(fit, node, NULL));
 	if (!fit_image_verify_with_data(fit, node,
 					 src, length))
 		return -EPERM;
-	puts("OK\n");
+	debug("OK\n");
 #endif

Checking printf("Signature failed") to debug() is probably not what you want to do. It'd be hiding some pretty important output.

Signature · 2 lines
Best regards,
Marek Vasut
#2 lore raw

PATCH 1/1 spl: avoid printf when we might be doing Ymodem with CONFIG_SPL_FIT_SIGNATURE

Quoted 32 lines · Marek Vasut
Quoted 30 lines · Alex Kiernan

If CONFIG_SPL_FIT_SIGNATURE is enabled and U-Boot is being loaded from UART over Ymodem then we can't emit messages using printf() without causing errors like:

Sending: u-boot-dtb.img
Ymodem sectors/kbytes sent: 3009/376kRetry 0: Got 23 for sector ACK Retry 0: NAK on sector
Retry 0: Got 68 for sector ACK
Retry 0: NAK on sector
Ymodem sectors/kbytes sent: 3273/409kRetry 0: Got 23 for sector ACK Retry 0: NAK on sector
Retry 0: Got 68 for sector ACK
Retry 0: NAK on sector

Use debug() rather than printf() to avoid sending messages on the serial port.

---

 common/spl/spl_fit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
common/spl/spl_fit.c +0 -0
index db436268cbcd..08faf2c1b058 100644
@@ -240,12 +240,12 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
      }
 
Quoted 15 lines

common/spl/spl_fit.c static int spl_load_fit_image(struct spl_load_info *info, ulong sector, · line 249

Quoted 11 lines
common/spl/spl_fit.c +3 -3
 #ifdef CONFIG_SPL_FIT_SIGNATURE
-     printf("## Checking hash(es) for Image %s ... ",
-            fit_get_name(fit, node, NULL));
+     debug("## Checking hash(es) for Image %s ... ",
+           fit_get_name(fit, node, NULL));
      if (!fit_image_verify_with_data(fit, node,
                                       src, length))
              return -EPERM;
-     puts("OK\n");
+     debug("OK\n");
 #endif

Checking printf("Signature failed") to debug() is probably not what you want to do. It'd be hiding some pretty important output.

I'm not sure what message you do get in that case (since so far I've failed to get keys into the SPL DTB in a way that seem to actually get checked), but I take your point.

I can't see any mechanism for either buffering or discarding console message when Ymodem is active, or am I just missing it, or anything else that would address this problem?

Signature · 1 line
Alex Kiernan
#3 lore raw
In reply to Alex Kiernan
Quoted 33 lines · Alex Kiernan

If CONFIG_SPL_FIT_SIGNATURE is enabled and U-Boot is being loaded from UART over Ymodem then we can't emit messages using printf() without causing errors like:

Sending: u-boot-dtb.img
Ymodem sectors/kbytes sent: 3009/376kRetry 0: Got 23 for sector ACK Retry 0: NAK on sector
Retry 0: Got 68 for sector ACK
Retry 0: NAK on sector
Ymodem sectors/kbytes sent: 3273/409kRetry 0: Got 23 for sector ACK Retry 0: NAK on sector
Retry 0: Got 68 for sector ACK
Retry 0: NAK on sector

Use debug() rather than printf() to avoid sending messages on the serial port.

---

 common/spl/spl_fit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
common/spl/spl_fit.c +0 -2
index db436268cbcd..08faf2c1b058 100644
@@ -240,12 +240,12 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 	}
 
 #ifdef CONFIG_SPL_FIT_SIGNATURE
-	printf("## Checking hash(es) for Image %s ... ",
-	       fit_get_name(fit, node, NULL));

common/spl/spl_fit.c static int spl_load_fit_image(struct spl_load_info *info, ulong sector, · line 251

Quoted 10 lines
common/spl/spl_fit.c +3 -1
+	debug("## Checking hash(es) for Image %s ... ",
+	      fit_get_name(fit, node, NULL));
 	if (!fit_image_verify_with_data(fit, node,
 					 src, length))
 		return -EPERM;
-	puts("OK\n");
+	debug("OK\n");
 #endif
 
 #ifdef CONFIG_SPL_FIT_IMAGE_POST_PROCESS

I think in this case we want to have that bit of "garbage" happen as the protocol handles them correctly and if there is a problem it's visible "on the line" to be seen at least and can be dug at. The other alternative here would be to re-work the code to only printf anything on the error case and debug that we're checking at all.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190422/3796151a/attachment.sig>
#4 lore raw
Quoted 43 lines · Tom Rini
Quoted 42 lines · Alex Kiernan

If CONFIG_SPL_FIT_SIGNATURE is enabled and U-Boot is being loaded from UART over Ymodem then we can't emit messages using printf() without causing errors like:

Sending: u-boot-dtb.img
Ymodem sectors/kbytes sent: 3009/376kRetry 0: Got 23 for sector ACK Retry 0: NAK on sector
Retry 0: Got 68 for sector ACK
Retry 0: NAK on sector
Ymodem sectors/kbytes sent: 3273/409kRetry 0: Got 23 for sector ACK Retry 0: NAK on sector
Retry 0: Got 68 for sector ACK
Retry 0: NAK on sector

Use debug() rather than printf() to avoid sending messages on the serial port.

---

 common/spl/spl_fit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
common/spl/spl_fit.c +3 -3
index db436268cbcd..08faf2c1b058 100644
@@ -240,12 +240,12 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 	}
 
 #ifdef CONFIG_SPL_FIT_SIGNATURE
-	printf("## Checking hash(es) for Image %s ... ",
-	       fit_get_name(fit, node, NULL));
+	debug("## Checking hash(es) for Image %s ... ",
+	      fit_get_name(fit, node, NULL));
 	if (!fit_image_verify_with_data(fit, node,
 					 src, length))
 		return -EPERM;
-	puts("OK\n");
+	debug("OK\n");
 #endif
 
Quoted 7 lines

common/spl/spl_fit.c static int spl_load_fit_image(struct spl_load_info *info, ulong sector, · line 251

Quoted 1 line
common/spl/spl_fit.c +0 -0
 #ifdef CONFIG_SPL_FIT_IMAGE_POST_PROCESS

I think in this case we want to have that bit of "garbage" happen as the protocol handles them correctly and if there is a problem it's visible "on the line" to be seen at least and can be dug at. The other alternative here would be to re-work the code to only printf anything on the error case and debug that we're checking at all.

Can we do something similar to this ?
https://patchwork.ozlabs.org/patch/1055047/

Signature · 2 lines
Best regards,
Marek Vasut
#5 lore raw
Quoted 52 lines · Marek Vasut
Quoted 43 lines · Tom Rini
Quoted 42 lines · Alex Kiernan

If CONFIG_SPL_FIT_SIGNATURE is enabled and U-Boot is being loaded from UART over Ymodem then we can't emit messages using printf() without causing errors like:

Sending: u-boot-dtb.img
Ymodem sectors/kbytes sent: 3009/376kRetry 0: Got 23 for sector ACK Retry 0: NAK on sector
Retry 0: Got 68 for sector ACK
Retry 0: NAK on sector
Ymodem sectors/kbytes sent: 3273/409kRetry 0: Got 23 for sector ACK Retry 0: NAK on sector
Retry 0: Got 68 for sector ACK
Retry 0: NAK on sector

Use debug() rather than printf() to avoid sending messages on the serial port.

---

 common/spl/spl_fit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
common/spl/spl_fit.c +3 -3
index db436268cbcd..08faf2c1b058 100644
@@ -240,12 +240,12 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 	}
 
 #ifdef CONFIG_SPL_FIT_SIGNATURE
-	printf("## Checking hash(es) for Image %s ... ",
-	       fit_get_name(fit, node, NULL));
+	debug("## Checking hash(es) for Image %s ... ",
+	      fit_get_name(fit, node, NULL));
 	if (!fit_image_verify_with_data(fit, node,
 					 src, length))
 		return -EPERM;
-	puts("OK\n");
+	debug("OK\n");
 #endif
 
Quoted 7 lines

common/spl/spl_fit.c static int spl_load_fit_image(struct spl_load_info *info, ulong sector, · line 251

Quoted 1 line
common/spl/spl_fit.c +0 -0
 #ifdef CONFIG_SPL_FIT_IMAGE_POST_PROCESS

I think in this case we want to have that bit of "garbage" happen as the protocol handles them correctly and if there is a problem it's visible "on the line" to be seen at least and can be dug at. The other alternative here would be to re-work the code to only printf anything on the error case and debug that we're checking at all.

Quoted 2 lines

Can we do something similar to this ?
https://patchwork.ozlabs.org/patch/1055047/

Another valid approach, yes.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190422/4dd81c73/attachment.sig>