diff options
author | Ned Konz <ned@bike-nomad.com> | 2021-08-19 08:12:19 -0700 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2021-09-21 18:02:14 +1000 |
commit | 8c214ed2000fd6334c8f03589f36c6fd2286f2c8 (patch) | |
tree | bc4908cd204844f32cd971f4295d92d423580ed6 | |
parent | 782d5b2e534c96f4668443efe37c0514e8fcfe91 (diff) | |
download | micropython-8c214ed2000fd6334c8f03589f36c6fd2286f2c8.tar.gz micropython-8c214ed2000fd6334c8f03589f36c6fd2286f2c8.zip |
stm32: Extended flash filesystem space to 512K on H743 boards.
The H743 has equal sized pages of 128k, which means the filesystem doesn't
need to be near the beginning. This commit moves the filesystem to the
very end of flash, and extends it to 512k (4 pages).
Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r-- | ports/stm32/boards/NUCLEO_H743ZI/mpconfigboard.mk | 11 | ||||
-rw-r--r-- | ports/stm32/boards/VCC_GND_H743VI/mpconfigboard.mk | 11 | ||||
-rw-r--r-- | ports/stm32/boards/stm32h743.ld | 15 | ||||
-rw-r--r-- | ports/stm32/flashbdev.c | 15 |
4 files changed, 31 insertions, 21 deletions
diff --git a/ports/stm32/boards/NUCLEO_H743ZI/mpconfigboard.mk b/ports/stm32/boards/NUCLEO_H743ZI/mpconfigboard.mk index ce8f83e57d..be9e56e4e1 100644 --- a/ports/stm32/boards/NUCLEO_H743ZI/mpconfigboard.mk +++ b/ports/stm32/boards/NUCLEO_H743ZI/mpconfigboard.mk @@ -7,14 +7,13 @@ MICROPY_FLOAT_IMPL = double AF_FILE = boards/stm32h743_af.csv ifeq ($(USE_MBOOT),1) -# When using Mboot all the text goes together after the filesystem -LD_FILES = boards/stm32h743.ld boards/common_blifs.ld -TEXT0_ADDR = 0x08040000 +# When using Mboot everything goes after the bootloader +LD_FILES = boards/stm32h743.ld boards/common_bl.ld +TEXT0_ADDR = 0x08020000 else -# When not using Mboot the ISR text goes first, then the rest after the filesystem -LD_FILES = boards/stm32h743.ld boards/common_ifs.ld +# When not using Mboot everything goes at the start of flash +LD_FILES = boards/stm32h743.ld boards/common_basic.ld TEXT0_ADDR = 0x08000000 -TEXT1_ADDR = 0x08040000 endif # MicroPython settings diff --git a/ports/stm32/boards/VCC_GND_H743VI/mpconfigboard.mk b/ports/stm32/boards/VCC_GND_H743VI/mpconfigboard.mk index 1f5fa32a1b..8860829484 100644 --- a/ports/stm32/boards/VCC_GND_H743VI/mpconfigboard.mk +++ b/ports/stm32/boards/VCC_GND_H743VI/mpconfigboard.mk @@ -7,14 +7,13 @@ MICROPY_FLOAT_IMPL = double AF_FILE = boards/stm32h743_af.csv ifeq ($(USE_MBOOT),1) -# When using Mboot all the text goes together after the filesystem -LD_FILES = boards/stm32h743.ld boards/common_blifs.ld -TEXT0_ADDR = 0x08040000 +# When using Mboot everything goes after the bootloader +LD_FILES = boards/stm32h743.ld boards/common_bl.ld +TEXT0_ADDR = 0x08020000 else -# When not using Mboot the ISR text goes first, then the rest after the filesystem -LD_FILES = boards/stm32h743.ld boards/common_ifs.ld +# When not using Mboot everything goes at the start of flash +LD_FILES = boards/stm32h743.ld boards/common_basic.ld TEXT0_ADDR = 0x08000000 -TEXT1_ADDR = 0x08040000 endif # MicroPython settings diff --git a/ports/stm32/boards/stm32h743.ld b/ports/stm32/boards/stm32h743.ld index 72d915b2bb..13fa0c52c0 100644 --- a/ports/stm32/boards/stm32h743.ld +++ b/ports/stm32/boards/stm32h743.ld @@ -5,10 +5,9 @@ /* Specify the memory areas */ MEMORY { - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K - FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 128K /* sector 0, 128K */ - FLASH_FS (r) : ORIGIN = 0x08020000, LENGTH = 128K /* sector 1, 128K */ - FLASH_TEXT (rx) : ORIGIN = 0x08040000, LENGTH = 1792K /* sectors 6*128 + 8*128 */ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1536K /* sectors (0-7) + (0-3) */ + FLASH_APP (rx) : ORIGIN = 0x08020000, LENGTH = 1408K /* sectors (1-7) + (0-3) */ + FLASH_FS (r) : ORIGIN = 0x08180000, LENGTH = 512K /* sectors (4-7) */ DTCM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K /* Used for storage cache */ RAM (xrw) : ORIGIN = 0x24000000, LENGTH = 512K /* AXI SRAM */ RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K @@ -29,6 +28,14 @@ _ram_end = ORIGIN(RAM) + LENGTH(RAM); _heap_start = _ebss; /* heap starts just after statically allocated memory */ _heap_end = _sstack; +/* Location of filesystem RAM cache */ +_ram_fs_cache_start = ORIGIN(DTCM); +_ram_fs_cache_end = ORIGIN(DTCM) + LENGTH(DTCM); + +/* Location of filesystem flash storage */ +_flash_fs_start = ORIGIN(FLASH_FS); +_flash_fs_end = ORIGIN(FLASH_FS) + LENGTH(FLASH_FS); + /* Define output sections */ SECTIONS { diff --git a/ports/stm32/flashbdev.c b/ports/stm32/flashbdev.c index 6ed891300d..6be0cfee8a 100644 --- a/ports/stm32/flashbdev.c +++ b/ports/stm32/flashbdev.c @@ -104,11 +104,16 @@ STATIC byte flash_cache_mem[0x4000] __attribute__((aligned(4))); // 16k #elif defined(STM32H743xx) -// The STM32H743 flash sectors are 128K -#define CACHE_MEM_START_ADDR (0x20000000) // DTCM data RAM, 128k -#define FLASH_SECTOR_SIZE_MAX (0x20000) // 128k max -#define FLASH_MEM_SEG1_START_ADDR (0x08020000) // sector 1 -#define FLASH_MEM_SEG1_NUM_BLOCKS (256) // Sector 1: 128k / 512b = 256 blocks +// The STM32H743 flash sectors are 128K, with locations defined in the linker script +extern uint8_t _flash_fs_start; +extern uint8_t _flash_fs_end; +extern uint8_t _ram_fs_cache_start[]; +extern uint8_t _ram_fs_cache_end[]; + +#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]) +#define FLASH_MEM_SEG1_START_ADDR ((long)&_flash_fs_start) +#define FLASH_MEM_SEG1_NUM_BLOCKS ((&_flash_fs_end - &_flash_fs_start) / 512) #elif defined(STM32L432xx) || \ defined(STM32L451xx) || defined(STM32L452xx) || defined(STM32L462xx) || \ |