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 45DF4C433EF for ; Mon, 7 Mar 2022 18:04:31 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CEB0681520; Mon, 7 Mar 2022 19:04:16 +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="qdLZwV7T"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 72D3983041; Mon, 7 Mar 2022 19:04:07 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::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 00E9481DD0 for ; Mon, 7 Mar 2022 19:03:59 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 9CAE0612C5; Mon, 7 Mar 2022 18:03:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC838C340EB; Mon, 7 Mar 2022 18:03:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646676238; bh=XuhiYep2nlj0PdWfo3daEw/1diyauUUi4PeV7jM00g4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qdLZwV7TCwGKxhMwNRcPBgS9SffDn998So9vZs0GGB/kAnsw8lo52kTwiXx36dlkC Ydqdl3YUFjOdBCX7Cq1n7SjMaG80pzq/Oznnf7gLtLyZYuRBNaN6OpA+WH4mMq2ZxB Xc7NAYz+tC5Ekbsh6hbUM6XTTZTHrDcIi2yUqGXQRp7B2xHagDiJVpe0/ANxjlb5Ii oY/hYRO0F13X8gtHBsAxGDCQQqt9hU4yyU50HcCReZX/YQkesCOEOY4tENHsumVSRX K34hnRKOWAtsPgPBsTYpqKloNQFoYHJaQkvP+PObWU9wf831XYzfw2vbqdLLH5QSXw 4CSiNYeZyaAIA== Received: by pali.im (Postfix) id 903472087; Mon, 7 Mar 2022 19:03:55 +0100 (CET) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Stefan Roese , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Marcel Ziswiler , Tony Dinh 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 Message-Id: <20220307180309.31275-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220307180309.31275-1-pali@kernel.org> References: <20220307180309.31275-1-pali@kernel.org> 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 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 --- 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