From: Pali Rohár <pali@kernel.org>
Date: Mon, 7 Mar 2022 18:03:07 +0000 (+0100)
Subject: tools: kwboot: Allow to specify custom baudrate only in supported operations
X-Git-Tag: v2025.01-rc5-pxa1908~1507^2~3
X-Git-Url: http://git.dujemihanovic.xyz/%22mailto:Murray.Jensen%40csiro.au/static/%7B%7B?a=commitdiff_plain;h=a79dea29127d2840277e6edc0f5c71dc1daec82b;p=u-boot.git

tools: kwboot: Allow to specify custom baudrate only in supported operations

Custom baudrate different than 115200 may be specified only when kwboot is
not going to send boot/debug message pattern or when it is going to send
boot message pattern with image file (in which case baudrate change happens
after sending kwbimage header). BootROM detects boot/debug message pattern
only at baudrate 115200.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
---

diff --git a/tools/kwboot.c b/tools/kwboot.c
index 69d1be0f48..986f27c201 100644
--- a/tools/kwboot.c
+++ b/tools/kwboot.c
@@ -2133,6 +2133,12 @@ main(int argc, char **argv)
 	if (optind != argc)
 		goto usage;
 
+	/* boot and debug message use baudrate 115200 */
+	if (((bootmsg && !imgpath) || debugmsg) && baudrate != 115200) {
+		fprintf(stderr, "Baudrate other than 115200 cannot be used for this operation.\n");
+		goto usage;
+	}
+
 	tty = kwboot_open_tty(ttypath, imgpath ? 115200 : baudrate);
 	if (tty < 0) {
 		perror(ttypath);