summaryrefslogtreecommitdiff
path: root/tools/env
diff options
context:
space:
mode:
authorDustin Byford <dustin@cumulusnetworks.com>2014-03-06 20:48:23 -0800
committerTom Rini <trini@ti.com>2014-03-12 17:04:29 -0400
commit4b774ff114201175ea9c05dfa12eef3ff1704753 (patch)
tree2aacf5076cbafc8387458a2f432e244d586d85b4 /tools/env
parent23869bf80b68af9ef1802b9e556f4fd0e9e57fe5 (diff)
downloadu-boot-imx-4b774ff114201175ea9c05dfa12eef3ff1704753.zip
u-boot-imx-4b774ff114201175ea9c05dfa12eef3ff1704753.tar.gz
u-boot-imx-4b774ff114201175ea9c05dfa12eef3ff1704753.tar.bz2
fw_env: correct writes to devices with small erase blocks
Some NOR flash devices have a small erase block size. For example, the Micron N25Q512 can erase in 4K blocks. These devices expose a bug in fw_env.c where flash_write_buf() incorrectly calculates bytes written and attempts to write past the environment sectors. Luckily, a range check prevents any real damage, but this does cause fw_setenv to fail with an error. This change corrects the write length calculation. The bug was introduced with commit 56086921 from 2008 and only affects configurations where the erase block size is smaller than the total environment data size. Signed-off-by: Dustin Byford <dustin@cumulusnetworks.com>
Diffstat (limited to 'tools/env')
-rw-r--r--tools/env/fw_env.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 649db04..d228cc3 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -863,9 +863,9 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count,
if (mtd_type != MTD_ABSENT)
ioctl(fd, MEMLOCK, &erase);
- processed += blocklen;
+ processed += erasesize;
block_seek = 0;
- blockstart += blocklen;
+ blockstart += erasesize;
}
if (write_total > count)