[U-Boot] [PATCH] 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.
Signed-off-by: Yiyang Fei yiyang.fei@barco.com
---
tools/env/fw_env.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
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;
}
if (write_total > count)
--
1.7.2.5
Sorry for the disclaimer...it is out of my control.
Yiyang Fei

Dear "Fei, Yiyang",
Please make sure to send your patches as plain text, NOT as HTML!
In message C2A5D1386C6DB94198F2A5C8368EAE6C1465A286@DULMEX02.barco.com you wrote: ...
tools/env/fw_env.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
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,
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

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 yiyang.fei@barco.com --- tools/env/fw_env.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
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; }
if (write_total > count)

Dear "Yiyang Fei",
In message 1314730318-3070-1-git-send-email-yiyang.fei@barco.com 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.
Signed-off-by: Yiyang Fei yiyang.fei@barco.com
tools/env/fw_env.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
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,
Line wrapped and does not apply.
Please fix your mailer and resubmit.
Best regards,
Wolfgang Denk
participants (3)
-
Fei, Yiyang
-
Wolfgang Denk
-
Yiyang Fei