altos/stm32f1: For some reason the DBG registers aren't always available
authorKeith Packard <keithp@keithp.com>
Sun, 28 Jan 2024 00:01:20 +0000 (16:01 -0800)
committerKeith Packard <keithp@keithp.com>
Thu, 1 Feb 2024 01:50:19 +0000 (17:50 -0800)
Attempts to discover the device model during flash loading appear to fail
for unknown reasons. Switch to basing the memory page size on the total
memory size, which should be just as reliable.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/stm32f1/ao_flash_stm.c

index 103e83a5e4b1df5892992736bbfe7d6aa124ef23..1e35545cffa5783c3478c6286473546edf55fe55 100644 (file)
@@ -69,19 +69,18 @@ _ao_flash_erase_page(uint32_t *page)
 static uint32_t
 stm_flash_page_size(void)
 {
-       uint16_t        dev_id = stm_dev_id();
+       uint16_t        f_size = stm_flash_data.f_size;
 
-       switch (dev_id) {
-       case 0x412:     /* low-density devices */
-       case 0x410:     /* medium-density devices */
+       if (f_size <= 128) {
+               /* low-density and medium-density devices */
                return 1024;
-       case 0x414:     /* high-density devices */
-       case 0x430:     /* XL-density devices */
-       case 0x418:     /* Connectivity devices */
+       } else {
+               /*
+                * high-density devices, XL-density devices and
+                * Connectivity devices
+                */
                return 2048;
        }
-       ao_panic(AO_PANIC_FLASH);
-       return 0;
 }
 
 void