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 8616BC54EBD for ; Fri, 6 Jan 2023 17:52:13 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EA49A853E0; Fri, 6 Jan 2023 18:52:10 +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="clgngPmZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 42CC0853E0; Fri, 6 Jan 2023 18:52:09 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) (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 2D96085358 for ; Fri, 6 Jan 2023 18:52:05 +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 BAEBEB81E40; Fri, 6 Jan 2023 17:52:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4747CC433EF; Fri, 6 Jan 2023 17:52:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673027523; bh=wO7OGp/H0D5VZJfeOY85aebuAxDovcY9i8If7+xfpMU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=clgngPmZIpN/jgAFs/baGkDIKQ/bghjHSplHutnZaCmr+AaE1gZ7Hf1HEJoiIofzj zWVcqYnQQ7SO1akvqw13BKGADaU7l+NYf19Hpadp/HarUEXkl8Ulrbmt8aNd2i/S7P 3wiEereUc4Wt71xlT67N6frq6H/ZI9lCKnVjXwFBmT//1u/AuBe3JEqkENjB2rwqWA Tdaet9l0U5L275WmJPrS9/faGlIUJG86pkihvJLdCjwpYRfn7Bu5rMNtX0GC8ATPES ZBnzJEehiYNhbUE5fL0OvaIdGPIWh90lwM5gt2tMssu5ErwALgizGL9uD6dEgmhNAj mG669NlknHMTg== Received: by pali.im (Postfix) id 85FF9A3A; Fri, 6 Jan 2023 18:52:00 +0100 (CET) Date: Fri, 6 Jan 2023 18:52:00 +0100 From: Pali =?utf-8?B?Um9ow6Fy?= To: SC Cc: Marek =?utf-8?B?QmVow7pu?= , Stefan Roese , Tony Dinh , u-boot@lists.denx.de Subject: Re: kwboot : bug when board stops acking Message-ID: <20230106175200.cfoqchlewkkpwrtp@pali> References: <30037bdd-67c4-2245-9b12-b41401c64be6@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <30037bdd-67c4-2245-9b12-b41401c64be6@gmail.com> User-Agent: NeoMutt/20180716 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.6 at phobos.denx.de X-Virus-Status: Clean Hello Stephane! On Wednesday 08 January 2020 15:21:12 SC wrote: > Hi list, > > I think there's a bug in kwboot. > I have a faulty board that stops acking xmodem frames after a certain number of packets and kwboot > instead of exiting continues to send frames up to 100%. > With the one second retry timer it's very long! More than 2 hours :-( I saw very similar bugs in kwboot and together with Marek we fixed lot of issues in kwboot. Could you test if last version of kwboot from U-Boot git master branch has still same or similar issue? > The bug is in the kwboot_xm_sendblock() fonction : > https://gitlab.denx.de/u-boot/u-boot/blob/master/tools/kwboot.c#L375 > kwboot_tty_recv detects the timeout but the return value is based on the last character received > (line 403) > The variable c is not initialized so if it keeps the previous value which is ACK => rc=0 => infinite > loop > > There are several ways to fix the bug: > * Surround the "switch(c)" with a test: >  if ( !((rc == -1) && (errno == ETIMEDOUT)) ) { >         rc = -1; >         switch (c) { >         case ACK: >             rc = 0; >             break; >         case NAK: >             errno = EBADMSG; >             break; >         case CAN: >             errno = ECANCELED; >             break; >         default: >             errno = EPROTO; >             break; >         } >     } >     return rc; > * In the case of a TIMEOUT set c to a specific value and add the case in the switch > > Do you agree with my diagnosis? > What is the best solution to fix this bug? > Should I provide a patch? > > Thank you, > Stephane