diff options
author | Roman D <me@iamroman.org> | 2013-01-18 10:53:43 +0400 |
---|---|---|
committer | Spencer Oliver <spen@spen-soft.co.uk> | 2013-01-18 09:19:21 +0000 |
commit | 3ad078cb60760a5a716c1ede0689540e9d01132a (patch) | |
tree | bd30c377de0f7cb39ba760b9ab624da60da4a2f8 /src/flash/nor/efm32.c | |
parent | df7a6b08a69cdf13d4a0adc9b6fc9e56cdcaa18e (diff) | |
download | riscv-openocd-3ad078cb60760a5a716c1ede0689540e9d01132a.zip riscv-openocd-3ad078cb60760a5a716c1ede0689540e9d01132a.tar.gz riscv-openocd-3ad078cb60760a5a716c1ede0689540e9d01132a.tar.bz2 |
flash: EFM32 GG/LG page size detection fix
Fixed flash page size detection according to EFM32 GG/LG errata.
MEM_INFO_PAGE_SIZE register containts invalid value in devices with
revision number lower than 18 and should not be used.
Change-Id: Idb2832246efcbbec2fd98a5c458f72a36df386fb
Signed-off-by: Roman D <me@iamroman.org>
Reviewed-on: http://openocd.zylin.com/1116
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Diffstat (limited to 'src/flash/nor/efm32.c')
-rw-r--r-- | src/flash/nor/efm32.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/flash/nor/efm32.c b/src/flash/nor/efm32.c index 5756649..37cb79b 100644 --- a/src/flash/nor/efm32.c +++ b/src/flash/nor/efm32.c @@ -169,14 +169,22 @@ static int efm32x_read_info(struct flash_bank *bank, efm32_info->page_size = 512; else if (EFM_FAMILY_ID_GIANT_GECKO == efm32_info->part_family || EFM_FAMILY_ID_LEOPARD_GECKO == efm32_info->part_family) { - uint8_t pg_size = 0; - - ret = target_read_u8(bank->target, EFM32_MSC_DI_PAGE_SIZE, - &pg_size); - if (ERROR_OK != ret) - return ret; - - efm32_info->page_size = (1 << ((pg_size+10) & 0xff)); + if (efm32_info->prod_rev >= 18) { + uint8_t pg_size = 0; + ret = target_read_u8(bank->target, EFM32_MSC_DI_PAGE_SIZE, + &pg_size); + if (ERROR_OK != ret) + return ret; + + efm32_info->page_size = (1 << ((pg_size+10) & 0xff)); + } else { + /* EFM32 GG/LG errata: MEM_INFO_PAGE_SIZE is invalid + for MCUs with PROD_REV < 18 */ + if (efm32_info->flash_sz_kib < 512) + efm32_info->page_size = 2048; + else + efm32_info->page_size = 4096; + } if ((2048 != efm32_info->page_size) && (4096 != efm32_info->page_size)) { |