From patchwork Tue Aug 30 18:51:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fei, Yiyang" X-Patchwork-Id: 112375 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 6BFC8B6F7B for ; Wed, 31 Aug 2011 04:52:27 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 66A4128091; Tue, 30 Aug 2011 20:52:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gIGL+akI4Alb; Tue, 30 Aug 2011 20:52:23 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6781528089; Tue, 30 Aug 2011 20:52:20 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E0E1328089 for ; Tue, 30 Aug 2011 20:52:13 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CdOsJXzrZ3jk for ; Tue, 30 Aug 2011 20:52:10 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail28.messagelabs.com (mail28.messagelabs.com [216.82.249.131]) by theia.denx.de (Postfix) with SMTP id 6958F28088 for ; Tue, 30 Aug 2011 20:52:08 +0200 (CEST) X-Env-Sender: yife@beaswelnx01.barco.com X-Msg-Ref: server-6.tower-28.messagelabs.com!1314730326!92718915!1 X-Originating-IP: [12.71.251.134] X-StarScan-Version: 6.3.6; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15946 invoked from network); 30 Aug 2011 18:52:06 -0000 Received: from unknown (HELO DULFEX01.barco.com) (12.71.251.134) by server-6.tower-28.messagelabs.com with SMTP; 30 Aug 2011 18:52:06 -0000 Thread-Index: AcxnReoJYNU72zX1SYeFx+2o7nbSpQ== X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4862 Content-class: urn:content-classes:message Importance: normal Priority: normal Received: from BEASWELNX01.barco.com ([150.158.46.42]) by DULFEX01.barco.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 30 Aug 2011 14:52:06 -0400 Received: from yife by BEASWELNX01.barco.com with local (Exim 4.72) (envelope-from ) id 1QyTPp-0000pU-7A; Tue, 30 Aug 2011 11:52:05 -0700 From: "Yiyang Fei" To: Date: Tue, 30 Aug 2011 11:51:58 -0700 Message-ID: <1314730318-3070-1-git-send-email-yiyang.fei@barco.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: References: X-OriginalArrivalTime: 30 Aug 2011 18:52:06.0332 (UTC) FILETIME=[EA0237C0:01CC6745] Cc: Yiyang Fei Subject: [U-Boot] [PATCH] Fix fw_env bug for multi-sector environments on NOR flash X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de When storing u-boot environment variables on a NOR flash using multiple sectors, the following error occurs when writing changes using fw_setenv. /etc # cat fw_env.config /dev/mtd12 0x0000 0x20000 0x10000 2 /etc # fw_setenv test test End of range reached, aborting Error: can't write fw_env to flash The reason for the error is that although both sectors are written in one pass, the loop for the write is executed twice because the "processed" variable is incremented by the incorrect amount. Signed-off-by: Yiyang Fei --- tools/env/fw_env.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) if (write_total > count) diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c index ed6b53f..e6b2cae 100644 --- a/tools/env/fw_env.c +++ b/tools/env/fw_env.c @@ -880,9 +880,8 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count, ioctl (fd, MEMLOCK, &erase); - processed += blocklen; - block_seek = 0; - blockstart += blocklen; + processed += erasesize; + blockstart += erasesize; }