Skip to content

Commit 8c214ed

Browse files
bikeNomaddpgeorge
authored andcommitted
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 <[email protected]>
1 parent 782d5b2 commit 8c214ed

File tree

4 files changed

+31
-21
lines changed

4 files changed

+31
-21
lines changed

ports/stm32/boards/NUCLEO_H743ZI/mpconfigboard.mk

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ MICROPY_FLOAT_IMPL = double
77
AF_FILE = boards/stm32h743_af.csv
88

99
ifeq ($(USE_MBOOT),1)
10-
# When using Mboot all the text goes together after the filesystem
11-
LD_FILES = boards/stm32h743.ld boards/common_blifs.ld
12-
TEXT0_ADDR = 0x08040000
10+
# When using Mboot everything goes after the bootloader
11+
LD_FILES = boards/stm32h743.ld boards/common_bl.ld
12+
TEXT0_ADDR = 0x08020000
1313
else
14-
# When not using Mboot the ISR text goes first, then the rest after the filesystem
15-
LD_FILES = boards/stm32h743.ld boards/common_ifs.ld
14+
# When not using Mboot everything goes at the start of flash
15+
LD_FILES = boards/stm32h743.ld boards/common_basic.ld
1616
TEXT0_ADDR = 0x08000000
17-
TEXT1_ADDR = 0x08040000
1817
endif
1918

2019
# MicroPython settings

ports/stm32/boards/VCC_GND_H743VI/mpconfigboard.mk

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ MICROPY_FLOAT_IMPL = double
77
AF_FILE = boards/stm32h743_af.csv
88

99
ifeq ($(USE_MBOOT),1)
10-
# When using Mboot all the text goes together after the filesystem
11-
LD_FILES = boards/stm32h743.ld boards/common_blifs.ld
12-
TEXT0_ADDR = 0x08040000
10+
# When using Mboot everything goes after the bootloader
11+
LD_FILES = boards/stm32h743.ld boards/common_bl.ld
12+
TEXT0_ADDR = 0x08020000
1313
else
14-
# When not using Mboot the ISR text goes first, then the rest after the filesystem
15-
LD_FILES = boards/stm32h743.ld boards/common_ifs.ld
14+
# When not using Mboot everything goes at the start of flash
15+
LD_FILES = boards/stm32h743.ld boards/common_basic.ld
1616
TEXT0_ADDR = 0x08000000
17-
TEXT1_ADDR = 0x08040000
1817
endif
1918

2019
# MicroPython settings

ports/stm32/boards/stm32h743.ld

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
/* Specify the memory areas */
66
MEMORY
77
{
8-
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K
9-
FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 128K /* sector 0, 128K */
10-
FLASH_FS (r) : ORIGIN = 0x08020000, LENGTH = 128K /* sector 1, 128K */
11-
FLASH_TEXT (rx) : ORIGIN = 0x08040000, LENGTH = 1792K /* sectors 6*128 + 8*128 */
8+
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1536K /* sectors (0-7) + (0-3) */
9+
FLASH_APP (rx) : ORIGIN = 0x08020000, LENGTH = 1408K /* sectors (1-7) + (0-3) */
10+
FLASH_FS (r) : ORIGIN = 0x08180000, LENGTH = 512K /* sectors (4-7) */
1211
DTCM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K /* Used for storage cache */
1312
RAM (xrw) : ORIGIN = 0x24000000, LENGTH = 512K /* AXI SRAM */
1413
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
@@ -29,6 +28,14 @@ _ram_end = ORIGIN(RAM) + LENGTH(RAM);
2928
_heap_start = _ebss; /* heap starts just after statically allocated memory */
3029
_heap_end = _sstack;
3130

31+
/* Location of filesystem RAM cache */
32+
_ram_fs_cache_start = ORIGIN(DTCM);
33+
_ram_fs_cache_end = ORIGIN(DTCM) + LENGTH(DTCM);
34+
35+
/* Location of filesystem flash storage */
36+
_flash_fs_start = ORIGIN(FLASH_FS);
37+
_flash_fs_end = ORIGIN(FLASH_FS) + LENGTH(FLASH_FS);
38+
3239
/* Define output sections */
3340
SECTIONS
3441
{

ports/stm32/flashbdev.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,16 @@ STATIC byte flash_cache_mem[0x4000] __attribute__((aligned(4))); // 16k
104104

105105
#elif defined(STM32H743xx)
106106

107-
// The STM32H743 flash sectors are 128K
108-
#define CACHE_MEM_START_ADDR (0x20000000) // DTCM data RAM, 128k
109-
#define FLASH_SECTOR_SIZE_MAX (0x20000) // 128k max
110-
#define FLASH_MEM_SEG1_START_ADDR (0x08020000) // sector 1
111-
#define FLASH_MEM_SEG1_NUM_BLOCKS (256) // Sector 1: 128k / 512b = 256 blocks
107+
// The STM32H743 flash sectors are 128K, with locations defined in the linker script
108+
extern uint8_t _flash_fs_start;
109+
extern uint8_t _flash_fs_end;
110+
extern uint8_t _ram_fs_cache_start[];
111+
extern uint8_t _ram_fs_cache_end[];
112+
113+
#define CACHE_MEM_START_ADDR ((uintptr_t)&_ram_fs_cache_start[0])
114+
#define FLASH_SECTOR_SIZE_MAX (&_ram_fs_cache_end[0] - &_ram_fs_cache_start[0])
115+
#define FLASH_MEM_SEG1_START_ADDR ((long)&_flash_fs_start)
116+
#define FLASH_MEM_SEG1_NUM_BLOCKS ((&_flash_fs_end - &_flash_fs_start) / 512)
112117

113118
#elif defined(STM32L432xx) || \
114119
defined(STM32L451xx) || defined(STM32L452xx) || defined(STM32L462xx) || \

0 commit comments

Comments
 (0)