diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2018-01-23 14:04:22 +0100 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-02-26 14:10:02 -0800 |
commit | 36679bb544f84307e9d93a36bf729c1b25ce3db2 (patch) | |
tree | 9d632aea6e0ce8ed6b5357e10bc1d9c1e8b39aba | |
parent | fb8e3f922b2b0c72c1f26e140dc3733b9efbf24c (diff) | |
download | chrome-ec-36679bb544f84307e9d93a36bf729c1b25ce3db2.tar.gz |
stm32mon: skip empty blocks
Skip the empty blocks when writing even if they are in the middle of the
firmware.
This greatly improves flashing speed when the firmware contains a
signature at the end of the RW.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=none
BUG=b:36125319
TEST=./util/flash_ec --board=meowth_fp
Change-Id: I3cd1c1bd2670be23d3d9daf9b87d9af0bdfc8963
Reviewed-on: https://chromium-review.googlesource.com/880956
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
-rw-r--r-- | util/stm32mon.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/util/stm32mon.c b/util/stm32mon.c index c4c5de4fbf..8e7c8b31da 100644 --- a/util/stm32mon.c +++ b/util/stm32mon.c @@ -568,7 +568,8 @@ int command_read_mem(int fd, uint32_t address, uint32_t size, uint8_t *buffer) int command_write_mem(int fd, uint32_t address, uint32_t size, uint8_t *buffer) { - int res; + int res = 0; + int i; uint32_t remaining = size; uint32_t addr_be; uint32_t cnt; @@ -580,17 +581,22 @@ int command_write_mem(int fd, uint32_t address, uint32_t size, uint8_t *buffer) while (remaining) { cnt = (remaining > PAGE_SIZE) ? PAGE_SIZE : remaining; - addr_be = htonl(address); - outbuf[0] = cnt - 1; - loads[1].size = cnt + 1; - memcpy(outbuf + 1, buffer, cnt); - - draw_spinner(remaining, size); - fflush(stdout); - res = send_command(fd, CMD_WRITEMEM, loads, 2, NULL, 0, 1); - if (res < 0) - return -EIO; - + /* skip empty blocks to save time */ + for (i = 0; i < cnt && buffer[i] == 0xff; i++) + ; + if (i != cnt) { + addr_be = htonl(address); + outbuf[0] = cnt - 1; + loads[1].size = cnt + 1; + memcpy(outbuf + 1, buffer, cnt); + + draw_spinner(remaining, size); + fflush(stdout); + res = send_command(fd, CMD_WRITEMEM, loads, 2, + NULL, 0, 1); + if (res < 0) + return -EIO; + } buffer += cnt; address += cnt; remaining -= cnt; |