From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AB108C433EF for ; Sun, 6 Mar 2022 12:39:27 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AF3A883836; Sun, 6 Mar 2022 13:39:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="rLzdqYv+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 653F3837EC; Sun, 6 Mar 2022 13:39:24 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4BE1583BBF for ; Sun, 6 Mar 2022 13:39:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D6795B80E95; Sun, 6 Mar 2022 12:39:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B1CBC340EC; Sun, 6 Mar 2022 12:39:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646570358; bh=OFmvCk7g5qXBB6P1BhehmqH7Y5plZyHge3juYojPxV4=; h=From:To:Cc:Subject:Date:From; b=rLzdqYv+B4d52x0LLPObVZfN1KIITmhIaiQvYpOYqRhFR/uEO7hNj5/OfPMQf3bAi IbjtD6N4tUBma+GuUARAwHe9/7OliHZ8OalhqNVdGadVEv9XRcSMulsjQuBaN15ELP QVORjzU1zRxlwboqCPZI5sP4dhhYnlgdx8IJi/HYOHs2JORPdz6P/Vx6aGvVcoEEYX D1aFmYrxUtyeL1PAWPLEN4TL+noqZN8aPitKPvEgE7I2ApyOw5a/vCvex7TrkgA0t5 IPiw0iH3L/w/15uB+UYFrurtx8iO0BwGhMXuwO4L8FMEMlh7RXN6lJoXhXDddSmOJj XrYb01tgHHvQg== Received: by pali.im (Postfix) id C75BD830; Sun, 6 Mar 2022 13:39:15 +0100 (CET) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Stefan Roese , =?UTF-8?q?Marek=20Beh=C3=BAn?= Cc: u-boot@lists.denx.de Subject: [PATCH] tools: kwboot: Check if baudrate value is supported before sending image Date: Sun, 6 Mar 2022 13:39:07 +0100 Message-Id: <20220306123907.24798-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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 help user to see error message about unsupported baudrate value by local tty device immediately after starting kwboot. Before this change, kwboot sent kwbimage header (at 115200 Bd) and then validated that selected baudrate if is supported by tty device. It consumed too much time (need to send kwbimage again and again) until some supported baudrate by local tty device was guessed. Signed-off-by: Pali Rohár --- tools/kwboot.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/kwboot.c b/tools/kwboot.c index f975c4a6c6ca..d9498af8fc02 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -2137,12 +2137,24 @@ main(int argc, char **argv) if (optind != argc) 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, + * change to different baudrate is done after sending header + */ + 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