diff options
author | Ting Shen <phoenixshen@google.com> | 2021-03-25 18:40:16 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-30 06:50:21 +0000 |
commit | 3430629ed4e993594d83e9ea22f984f2cf5fce76 (patch) | |
tree | 7f44a51090c500f487bd67cb3d704c3521eb6675 /util | |
parent | d1db895457ac97b5193f75d224e7da16e6a6c8f0 (diff) | |
download | chrome-ec-3430629ed4e993594d83e9ea22f984f2cf5fce76.tar.gz |
iteflash: speed up data write
In Cherry/Asurada, around 60% of the flash is not used. Skip writing
empty contents makes flash_ec runs 2x faster.
BUG=none
TEST=Run `time util/flash_ec --board=cherry --image build/cherry/ec.bin`
Before this patch: 5min 54s
After: 2min 33s
And make sure the content is good.
BRANCH=none
Signed-off-by: Ting Shen <phoenixshen@google.com>
Change-Id: I6aa5c3c00e2494b87a139f7a09aad9734e68c98d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2785510
Reviewed-by: Dino Li <dino.li@ite.corp-partner.google.com>
Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
Tested-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/iteflash.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/util/iteflash.c b/util/iteflash.c index bf87c2dfb7..d9f5d2a035 100644 --- a/util/iteflash.c +++ b/util/iteflash.c @@ -15,6 +15,7 @@ #include <linux/i2c-dev.h> #include <linux/i2c.h> #include <signal.h> +#include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> @@ -1210,6 +1211,16 @@ failed_read: return res; } +static bool is_empty_page(uint8_t *buffer, int size) +{ + for (int i = 0; i < size; i++) { + if (buffer[i] != 0xFF) + return false; + } + + return true; +} + static int command_write_pages(struct common_hnd *chnd, uint32_t address, uint32_t size, uint8_t *buffer) { @@ -1793,7 +1804,10 @@ static int write_flash3(struct common_hnd *chnd, const char *filename, while (res) { cnt = (res > block_write_size) ? block_write_size : res; - if (command_write_pages3(chnd, offset, cnt, &buf[offset]) < 0) { + if (chnd->conf.erase && is_empty_page(&buf[offset], cnt)) { + /* do nothing */ + } else if (command_write_pages3(chnd, offset, cnt, &buf[offset]) + < 0) { ret = -EIO; goto failed_write; } |