Skip to contentSkip to conversation

Fix fw_env bug for multi-sector environments on NOR flash

PATCH New Fei 3 participants 4 messages Aug 26, 2011 – Sep 7, 2011

lore
Share & tools
lore

Fei

#0 lore raw

PATCH 1/1 Fix fw_env bug for multi-sector environments on NOR flash

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.

---

 tools/env/fw_env.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
tools/env/fw_env.c index renamed from tools/env/fw_env.c +0 -0

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;

}

if (write_total > count)

--

1.7.2.5

Sorry for the disclaimer...it is out of my control.

Yiyang Fei

#1 lore raw

PATCH 1/1 Fix fw_env bug for multi-sector environments on NOR flash

Dear "Fei, Yiyang",

Please make sure to send your patches as plain text, NOT as HTML!

In message <[email protected]> you wrote:
...

Quoted 15 lines
 tools/env/fw_env.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
tools/env/fw_env.c index renamed from tools/env/fw_env.c +0 -0

ed6b53f..e6b2cae 100644

--- a/tools/env/fw_env.c

+++ b/tools/env/fw_env.c

tools/env/fw_env.c index static int flash_write_buf (int dev, int fd, void · line 880

Quoted 1 line
tools/env/fw_env.c index renamed from tools/env/fw_env.c +0 -0
@@ -880,9 +880,8 @@ static int flash_write_buf (int dev, int fd, void
 *buf, size_t count,

Sorry, but this patch is totally corrupted - long lines are wrapped, white space is mangled, and additional empty lines have been inserted.

This does not apply.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
We, the unwilling, led by the unknowing, are doing the impossible for
the ungrateful. We have done so much, for so long, with so little, we
are now qualified to do anything with nothing.
#2 lore raw

PATCH 1/1 Fix fw_env bug for multi-sector environments on NOR flash

In reply to Fei

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.

---
 tools/env/fw_env.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
tools/env/fw_env.c +0 -0
index ed6b53f..e6b2cae 100644
@@ -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;
}

if (write_total > count)

Signature · 16 lines
1.7.2.5



DISCLAIMER:
Unless indicated otherwise, the information contained in this message is 
privileged and confidential, and is intended only for the use of the 
addressee(s) named above and others who have been specifically authorized 
to receive it. If you are not the intended recipient, you are hereby 
notified that any dissemination, distribution or copying of this message 
and/or attachments is strictly prohibited. The company accepts no 
liability for any damage caused by any virus transmitted by this email. 
Furthermore, the company does not warrant a proper and complete 
transmission of this information, nor does it accept liability for any 
delays. If you have received this message in error, please contact the 
sender and delete the message. Thank you.
#3 lore raw

PATCH 1/1 Fix fw_env bug for multi-sector environments on NOR flash

Dear "Yiyang Fei",

Quoted 25 lines · In message <[email protected]> you wrote:

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.

---
 tools/env/fw_env.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
tools/env/fw_env.c +0 -0
index ed6b53f..e6b2cae 100644

tools/env/fw_env.c static int flash_write_buf (int dev, int fd, void · line 880

Quoted 1 line
tools/env/fw_env.c +0 -0
@@ -880,9 +880,8 @@ static int flash_write_buf (int dev, int fd, void 
 *buf, size_t count,

Line wrapped and does not apply.

Please fix your mailer and resubmit.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"I may be synthetic, but I'm not stupid"  -  the  artificial  person,
from _Aliens_