diff options
author | Andreas Fenkart <andreas.fenkart@digitalstrom.com> | 2016-08-29 21:17:00 (GMT) |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-10-07 00:57:35 (GMT) |
commit | 24307d6337e69c277e8f70ae9af97ef331dc39c5 (patch) | |
tree | 6cc8cd73ab87adec3789117aa37564da9984bda8 /tools/env/fw_env.c | |
parent | ff95e579cf53b9d621e0754ea869a703eec6cdd1 (diff) | |
download | u-boot-24307d6337e69c277e8f70ae9af97ef331dc39c5.tar.xz |
Suspected Spam: Do not open attachements![PATCH 4/6] tools/env: flash_write_buf: enforce offset to be start of environment
This allows to take advantage of the environment being block aligned.
This is not a new constraint. Writes always start at the begin of the
environment, since the header with CRC/length as there.
Every environment modification requires updating the header
Signed-off-by: Andreas Fenkart <andreas.fenkart@digitalstrom.com>
Diffstat (limited to 'tools/env/fw_env.c')
-rw-r--r-- | tools/env/fw_env.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c index 0f0eaa4..3dc0d53 100644 --- a/tools/env/fw_env.c +++ b/tools/env/fw_env.c @@ -765,12 +765,12 @@ static int flash_read_buf (int dev, int fd, void *buf, size_t count, } /* - * Write count bytes at offset, but stay within ENVSECTORS (dev) sectors of + * Write count bytes from begin of environment, but stay within + * ENVSECTORS(dev) sectors of * DEVOFFSET (dev). Similar to the read case above, on NOR and dataflash we * erase and write the whole data at once. */ -static int flash_write_buf (int dev, int fd, void *buf, size_t count, - off_t offset) +static int flash_write_buf(int dev, int fd, void *buf, size_t count) { void *data; struct erase_info_user erase; @@ -796,20 +796,21 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count, if (DEVTYPE(dev) == MTD_ABSENT) { blocklen = count; erase_len = blocklen; - blockstart = offset; + blockstart = DEVOFFSET(dev); block_seek = 0; write_total = blocklen; } else { blocklen = DEVESIZE(dev); - erase_offset = (offset / blocklen) * blocklen; + erase_offset = DEVOFFSET(dev); /* Maximum area we may use */ erase_len = environment_end(dev) - erase_offset; blockstart = erase_offset; + /* Offset inside a block */ - block_seek = offset - erase_offset; + block_seek = DEVOFFSET(dev) - erase_offset; /* * Data size we actually write: from the start of the block @@ -1007,7 +1008,7 @@ static int flash_write (int fd_current, int fd_target, int dev_target) #endif rc = flash_write_buf(dev_target, fd_target, environment.image, - CUR_ENVSIZE, DEVOFFSET(dev_target)); + CUR_ENVSIZE); if (rc < 0) return rc; |