aboutsummaryrefslogtreecommitdiff
path: root/ports/stm32/flashbdev.c
diff options
context:
space:
mode:
Diffstat (limited to 'ports/stm32/flashbdev.c')
-rw-r--r--ports/stm32/flashbdev.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/ports/stm32/flashbdev.c b/ports/stm32/flashbdev.c
index 5ae67d1ec..2b633cf16 100644
--- a/ports/stm32/flashbdev.c
+++ b/ports/stm32/flashbdev.c
@@ -95,14 +95,15 @@ STATIC byte flash_cache_mem[0x4000] __attribute__((aligned(4))); // 16k
#elif defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L496xx)
+// The STM32L475/6 doesn't have CCRAM, so we use the 32K SRAM2 for this, although
+// actual location and size is defined by the linker script.
extern uint8_t _flash_fs_start;
extern uint8_t _flash_fs_end;
-extern uint32_t _ram_fs_cache_start[2048 / 4];
-extern uint32_t _ram_fs_cache_block_size;
+extern uint8_t _ram_fs_cache_start[]; // size determined by linker file
+extern uint8_t _ram_fs_cache_end[];
-// The STM32L475/6 doesn't have CCRAM, so we use the 32K SRAM2 for this.
-#define CACHE_MEM_START_ADDR (&_ram_fs_cache_start) // End of SRAM2 RAM segment-2k
-#define FLASH_SECTOR_SIZE_MAX (_ram_fs_cache_block_size) // 2k max
+#define CACHE_MEM_START_ADDR ((uintptr_t)&_ram_fs_cache_start[0])
+#define FLASH_SECTOR_SIZE_MAX (&_ram_fs_cache_end[0] - &_ram_fs_cache_start[0]) // 2k max
#define FLASH_MEM_SEG1_START_ADDR ((long)&_flash_fs_start)
#define FLASH_MEM_SEG1_NUM_BLOCKS ((&_flash_fs_end - &_flash_fs_start) / 512)