diff options
author | Simon Glass <sjg@chromium.org> | 2012-08-20 07:24:06 +0100 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-08-23 14:40:01 -0700 |
commit | 21c1bf96282e8ac6bf6ff43cb537cbdefd84fc65 (patch) | |
tree | 8de5249392113af1fc42594749df31688bbe309c /include/flash.h | |
parent | a8402a53ea89e69ef6463a5a8bc033c42c163926 (diff) | |
download | chrome-ec-21c1bf96282e8ac6bf6ff43cb537cbdefd84fc65.tar.gz |
flash: Only erase flash block that contain data
It wastes time to erase blocks that are already erased and it is faster
on stm32 to check first. Add a check in flash_physical_erase() on all
chips, using a common flash_is_erased() function.
BUG=none
BRANCH=snow,link
TEST=manual
Do software sync in U-Boot and see that it succeeds. This tests that
we can still erase and then boot a written image. It typically saves
a second on a full sync over i2c.
SMDK5250 # cros_test swsync -f
SF: Detected W25Q32 with page size 4 KiB, total 4 MiB
Flashing RW EC image: erasing, writing, done
Flashing RO EC image: erasing, writing, done
Full software sync completed in 22.949s
SMDK5250 #
Also see that second erase is faster:
SMDK5250 # time mkbp erase rw
time: 0.952 seconds, 952 ticks
SMDK5250 # time mkbp erase rw
time: 0.054 seconds, 54 ticks
SMDK5250 #
Change-Id: I3699577217fdbb2f212d20d150d3ca15fdff03eb
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/30851
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include/flash.h')
-rw-r--r-- | include/flash.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/flash.h b/include/flash.h index 2e31cf0f22..8bf0264c14 100644 --- a/include/flash.h +++ b/include/flash.h @@ -32,6 +32,17 @@ static inline char *flash_physical_dataptr(int offset) } /** + * Check if a region of flash is erased + * + * It is assumed that an erased region has all bits set to 1. + * + * @param offset Flash offset to check + * @param size Number of bytes to check (word-aligned) + * @return 1 if erased, 0 if not erased + */ +int flash_is_erased(uint32_t offset, int size); + +/** * Write to physical flash. * * Offset and size must be a multiple of CONFIG_FLASH_WRITE_SIZE. |