diff options
author | Ting Shen <phoenixshen@google.com> | 2021-03-25 18:40:16 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-04-01 07:12:13 +0000 |
commit | 8488f6002b134ec7fd62d00a47d2fd68a23c91e9 (patch) | |
tree | 66fbc3ef881b79bafc864c1a86364018b933e7ad | |
parent | 02fe8da69ac711c45e55a8b69d50d4ae4ae5fba8 (diff) | |
download | chrome-ec-8488f6002b134ec7fd62d00a47d2fd68a23c91e9.tar.gz |
Reland "iteflash: speed up data write"
This is a reland of 3430629ed4e993594d83e9ea22f984f2cf5fce76
Original change's description:
> 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>
Bug: none
Change-Id: Icce2ffc404d0e83fa710a5fd1c201e7fbbf10101
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2796376
Tested-by: Ting Shen <phoenixshen@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
-rw-r--r-- | util/iteflash.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/util/iteflash.c b/util/iteflash.c index bf87c2dfb7..ba6ba21159 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,18 @@ failed_read: return res; } +static bool is_empty_page(uint8_t *buffer, int size) +{ + int i; + + for (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 +1806,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; } |