diff options
author | kevin <software@klystron.com> | 2016-10-17 12:46:26 +0100 |
---|---|---|
committer | Paul Fertser <fercerpav@gmail.com> | 2016-12-08 13:30:24 +0000 |
commit | c37a88c92f0234df6206a4b58c23d20563a22afc (patch) | |
tree | d4c3871c9cce3ecc25af940c0e275b6a89ed39e8 | |
parent | 1039ed3ff2138c9d0d820b143159738f8a73cb2e (diff) |
flash/nor/efm32: Support flash size smaller than 32k
The current implementation fails on devices with less than 32k of
flash (such as several devices in the Zero Gecko family) because
the 'assert' assumes (incorrectly) that the number of flash banks
will always be >= 32.
This change ensures that at least one word of lock bits is always read
in order to support devices with less than 32k of flash.
Signed-off-by: Kevlar Harness <software@klystron.com>
Change-Id: I59febe2cb690c893a5057a5f72918e146cf2afe4
Reviewed-on: http://openocd.zylin.com/3806
Tested-by: jenkins
Reviewed-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
-rw-r--r-- | src/flash/nor/efm32.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/flash/nor/efm32.c b/src/flash/nor/efm32.c index 0b33829b..81c1a379 100644 --- a/src/flash/nor/efm32.c +++ b/src/flash/nor/efm32.c @@ -456,10 +456,10 @@ static int efm32x_read_lock_data(struct flash_bank *bank) uint32_t *ptr = NULL; int ret = 0; - assert(!(bank->num_sectors & 0x1f)); + assert(bank->num_sectors > 0); - data_size = bank->num_sectors / 8; /* number of data bytes */ - data_size /= 4; /* ...and data dwords */ + /* calculate the number of 32-bit words to read (one lock bit per sector) */ + data_size = (bank->num_sectors + 31) / 32; ptr = efm32x_info->lb_page; |