diff options
author | Tom Rini <trini@konsulko.com> | 2022-10-25 09:54:59 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-10-25 09:54:59 -0400 |
commit | f9d16f2c0daf68dcb963c08c927f5f0a07cf75e4 (patch) | |
tree | 25237e7268de1d018aa9ac9eda20ac63e124c7bf /cmd | |
parent | 3eebbd866bfa8e889e52d1734b574a585e076a5a (diff) | |
parent | 622b5d356136f9172db7fe7ba240cd9e45097a19 (diff) | |
download | u-boot-f9d16f2c0daf68dcb963c08c927f5f0a07cf75e4.tar.gz u-boot-f9d16f2c0daf68dcb963c08c927f5f0a07cf75e4.tar.bz2 u-boot-f9d16f2c0daf68dcb963c08c927f5f0a07cf75e4.zip |
Merge https://source.denx.de/u-boot/custodians/u-boot-spi
- Add s28hl512t, s28hl01gt (Takahiro)
- Rework s25hx_t_post_bfpt_fixup() (Takahiro)
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/sf.c | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -179,16 +179,18 @@ static const char *spi_flash_update_block(struct spi_flash *flash, u32 offset, size_t len, const char *buf, char *cmp_buf, size_t *skipped) { char *ptr = (char *)buf; + u32 start_offset = offset % flash->sector_size; + u32 read_offset = offset - start_offset; - debug("offset=%#x, sector_size=%#x, len=%#zx\n", - offset, flash->sector_size, len); + debug("offset=%#x+%#x, sector_size=%#x, len=%#zx\n", + read_offset, start_offset, flash->sector_size, len); /* Read the entire sector so to allow for rewriting */ - if (spi_flash_read(flash, offset, flash->sector_size, cmp_buf)) + if (spi_flash_read(flash, read_offset, flash->sector_size, cmp_buf)) return "read"; /* Compare only what is meaningful (len) */ - if (memcmp(cmp_buf, buf, len) == 0) { - debug("Skip region %x size %zx: no change\n", - offset, len); + if (memcmp(cmp_buf + start_offset, buf, len) == 0) { + debug("Skip region %x+%x size %zx: no change\n", + start_offset, read_offset, len); *skipped += len; return NULL; } @@ -197,7 +199,7 @@ static const char *spi_flash_update_block(struct spi_flash *flash, u32 offset, return "erase"; /* If it's a partial sector, copy the data into the temp-buffer */ if (len != flash->sector_size) { - memcpy(cmp_buf, buf, len); + memcpy(cmp_buf + start_offset, buf, len); ptr = cmp_buf; } /* Write one complete sector */ @@ -238,6 +240,8 @@ static int spi_flash_update(struct spi_flash *flash, u32 offset, for (; buf < end && !err_oper; buf += todo, offset += todo) { todo = min_t(size_t, end - buf, flash->sector_size); + todo = min_t(size_t, end - buf, + flash->sector_size - (offset % flash->sector_size)); if (get_timer(last_update) > 100) { printf(" \rUpdating, %zu%% %lu B/s", 100 - (end - buf) / scale, |