All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: "Stefan Roese" <sr@denx.de>, "Marek Behún" <marek.behun@nic.cz>,
	"Marcel Ziswiler" <marcel@ziswiler.com>,
	"Tony Dinh" <mibodhi@gmail.com>
Cc: u-boot@lists.denx.de
Subject: [PATCH v2 2/3] tools: kwboot: Check if baudrate value is supported before sending image
Date: Mon,  7 Mar 2022 19:03:08 +0100	[thread overview]
Message-ID: <20220307180309.31275-2-pali@kernel.org> (raw)
In-Reply-To: <20220307180309.31275-1-pali@kernel.org>

Call kwboot_open_tty() which baudrate value which was specified at the
command line by option -B. This function returns error if baudrate is not
supported by selected tty device.

Initial baudrate for image transfer is always 115200, so call
kwboot_tty_change_baudrate() with value 115200 immediately after
kwboot_open_tty() if baudrate specified by option -B is different than
115200.

This makes kwboot fail immediately, informing that baudrate is unsupported,
instead of failing only after the first part of image is already sent.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 tools/kwboot.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/kwboot.c b/tools/kwboot.c
index 986f27c2012a..3b45e19a30aa 100644
--- a/tools/kwboot.c
+++ b/tools/kwboot.c
@@ -2139,12 +2139,24 @@ main(int argc, char **argv)
 		goto usage;
 	}
 
-	tty = kwboot_open_tty(ttypath, imgpath ? 115200 : baudrate);
+	tty = kwboot_open_tty(ttypath, baudrate);
 	if (tty < 0) {
 		perror(ttypath);
 		goto out;
 	}
 
+	/*
+	 * initial baudrate for image transfer is always 115200,
+	 * the change to different baudrate is done only after the header is sent
+	 */
+	if (imgpath && baudrate != 115200) {
+		rc = kwboot_tty_change_baudrate(tty, 115200);
+		if (rc) {
+			perror(ttypath);
+			goto out;
+		}
+	}
+
 	if (baudrate == 115200)
 		/* do not change baudrate during Xmodem to the same value */
 		baudrate = 0;
-- 
2.20.1


  reply	other threads:[~2022-03-07 18:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-07 18:03 [PATCH v2 1/3] tools: kwboot: Allow to specify custom baudrate only in supported operations Pali Rohár
2022-03-07 18:03 ` Pali Rohár [this message]
2022-03-08 12:15   ` [PATCH v2 2/3] tools: kwboot: Check if baudrate value is supported before sending image Stefan Roese
2022-03-07 18:03 ` [PATCH v2 3/3] tools: kwboot: Allow to mix positional arguments with option -b Pali Rohár
2022-03-08  5:23   ` Tony Dinh
2022-03-08 19:22     ` Pali Rohár
2022-03-09  5:51       ` Stefan Roese
2022-03-08 12:15   ` Stefan Roese
2022-03-14 15:23   ` Stefan Roese
2022-03-08 12:14 ` [PATCH v2 1/3] tools: kwboot: Allow to specify custom baudrate only in supported operations Stefan Roese
2022-03-14 15:19 ` Stefan Roese
  -- strict thread matches above, loose matches on Subject: below --
2022-03-06 23:12 [PATCH] arm: kirkwood: Sheevaplug : Use Marvell uclass mvgbe and PHY driver for Ethernet Tony Dinh
2022-03-14 15:19 ` [PATCH v2 2/3] tools: kwboot: Check if baudrate value is supported before sending image Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220307180309.31275-2-pali@kernel.org \
    --to=pali@kernel.org \
    --cc=marcel@ziswiler.com \
    --cc=marek.behun@nic.cz \
    --cc=mibodhi@gmail.com \
    --cc=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.