mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-14 08:36:39 +00:00
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>
This commit is contained in:
committed by
chrome-bot
parent
fb8e3f922b
commit
36679bb544
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user