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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60CF0C433F5 for ; Fri, 1 Oct 2021 05:06:57 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D936961353 for ; Fri, 1 Oct 2021 05:06:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D936961353 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 280D783405; Fri, 1 Oct 2021 07:04:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="lkYT87s+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 42CE883326; Fri, 1 Oct 2021 07:04:08 +0200 (CEST) Received: from mail-vs1-xe31.google.com (mail-vs1-xe31.google.com [IPv6:2607:f8b0:4864:20::e31]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 813608316B for ; Fri, 1 Oct 2021 07:04:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@google.com Received: by mail-vs1-xe31.google.com with SMTP id n17so9981210vsr.10 for ; Thu, 30 Sep 2021 22:04:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dFRCSa3HBww5mElG40AguXUjMUer8KBN5q5qgjPbyeI=; b=lkYT87s+fwref3YyoFpGpeMIUv+B4NIFZCDlZPyvnAp6fmicrYZwqNE842mRJK11aw 9tDU59UdDvbZ20uEq5Swg/9xRvQdnG3XH1qaushfP2rcNSZcqtl0GsMfLFvU832nZxq2 IIHiY1vOu/skro/rUDXLJCdP/FA9YH8q4gmI4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dFRCSa3HBww5mElG40AguXUjMUer8KBN5q5qgjPbyeI=; b=S6yBXy1ezFA0XTjdfHihM2dwEdaWDxeQ6p8pw58x2UsYm+50zHK2jg7ykEd5bvDKrt 3O5prj9M1JWKpQFlQqR5EpVxAae4+t1uoRXrXCQX00mx0kwr6lHltLzqXFlakSwlNfFp vQ5Jtvih6MlKE39/G4cw266/jIMXq4z3us6I0N+Ouizm82Wo6dSkF0fvT6xA6ER0GS8d GZUF/gUQKBQHwcjWF5S9AnvPbqcr3I/H54fAUuWyrDLG9LR57vyVvsJgKKcsrovNASNz o9aHygDjcNe+pMAJ/Izi87t9C0YwXrNCyxgqM0sfnPWZR8mOKiF9iontrI8QFgIA6Xhr z3LA== X-Gm-Message-State: AOAM531UXdOX1Wttw7wn9sdl2xeLNAzYLnyhyRgHnZGxH9iMzzb6YXI3 RyGrrGK/a55SOWHDjeUsW1AWS/w72cVVMlnwy3j05A== X-Google-Smtp-Source: ABdhPJxdLQsbvJ8txrQ6ghWU29An42rBVkmNxWTKTGiw+gpJJjSUJhqZoSIgCUTXeTom39SMPE0yM3vKXa70Xr8lPUA= X-Received: by 2002:a67:f801:: with SMTP id l1mr2628243vso.59.1633064638745; Thu, 30 Sep 2021 22:03:58 -0700 (PDT) MIME-Version: 1.0 References: <20210930161926.2748887-1-frieder@fris.de> In-Reply-To: <20210930161926.2748887-1-frieder@fris.de> From: Simon Glass Date: Thu, 30 Sep 2021 23:03:47 -0600 Message-ID: Subject: Re: [PATCH] cmd: sf: Support unaligned flash updates with 'sf update' To: Frieder Schrempf Cc: U-Boot Mailing List , Heiko Thiery , Michael Walle , Frieder Schrempf , Bin Meng , Jagan Teki , Pratyush Yadav , Sean Anderson Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean Hi Frieder, On Thu, 30 Sept 2021 at 10:20, Frieder Schrempf wrote: > > From: Frieder Schrempf > > Currently 'sf update' supports only offsets that are aligned to the > erase block size of the serial flash. Unaligned offsets result in > something like: > > => sf update ${kernel_addr_r} 0x400 ${filesize} > device 0 offset 0x400, size 0x11f758 > SPI flash failed in erase step > > In order to support unaligned updates, we simply read the first full > block and check only the requested part of the block for changes. If > necessary, the block is erased, the first (unchanged) part of the block > is written back together with the second part of the block (updated data). > > Signed-off-by: Frieder Schrempf > --- > cmd/sf.c | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) > Regards, Simon