From 1acfa1c9178c1943124d9dd5275cb1063ba4cbd7 Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Fri, 16 Oct 2020 10:35:57 +0000 Subject: [PATCH] stm32l1: desig: handle flash size footnotes from refman Some of the chipid variants have some footnotes on reading the flash size register, make sure we report things nicely. --- lib/stm32/l1/desig.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/stm32/l1/desig.c b/lib/stm32/l1/desig.c index 0bdf98b4..80a12500 100644 --- a/lib/stm32/l1/desig.c +++ b/lib/stm32/l1/desig.c @@ -23,15 +23,20 @@ uint16_t desig_get_flash_size(void) { + uint32_t v; uint32_t device_id = DBGMCU_IDCODE & DBGMCU_IDCODE_DEV_ID_MASK; switch (device_id) { case 0x416: - case 0x429: return *(uint32_t*)DESIG_FLASH_SIZE_BASE_CAT12; + case 0x429: + v = *(uint32_t*)DESIG_FLASH_SIZE_BASE_CAT12; + return v & 0xff; case 0x427: - case 0x436: case 0x437: return *(uint32_t*)DESIG_FLASH_SIZE_BASE_CAT3456; + case 0x436: + v = *(uint32_t*)DESIG_FLASH_SIZE_BASE_CAT3456; + return v ? 256 : 384; } cm3_assert_not_reached();