From 4cb76d6c526da009808579b05f8cb7c409ce2ead Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Wed, 20 Dec 2017 10:15:39 +0100 Subject: stm32mon: do not write trailing empty space Add a tweak to get faster flashing: skip writing the empty trailing space at the end of the firmware image. On the STM32H7x3, flashing 2MB of useless bytes over UART can be really slow... Signed-off-by: Vincent Palatin BRANCH=none BUG=b:67081508 TEST=flash_ec --board=meowth_fp Change-Id: Ie396ee7d5b5771e0f6249e38da37ef8329c84ae3 Reviewed-on: https://chromium-review.googlesource.com/856978 Commit-Ready: Vincent Palatin Tested-by: Vincent Palatin Reviewed-by: Gwendal Grignou Reviewed-by: Shawn N --- util/stm32mon.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'util') diff --git a/util/stm32mon.c b/util/stm32mon.c index b9896a00c0..c4c5de4fbf 100644 --- a/util/stm32mon.c +++ b/util/stm32mon.c @@ -858,6 +858,12 @@ int write_flash(int fd, struct stm32_def *chip, const char *filename, } fclose(hnd); + /* faster write: skip empty trailing space */ + while (res && buffer[res - 1] == 0xff) + res--; + /* ensure 'res' is multiple of 4 given 'size' is and res <= size */ + res = (res + 3) & ~3; + printf("Writing %d bytes at 0x%08x\n", res, offset); written = command_write_mem(fd, offset, res, buffer); if (written != res) { -- cgit v1.2.1