Skip to content

Commit 665b851

Browse files
committed
enable file system on the internal flash
1 parent 1f857a8 commit 665b851

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

ports/stm/boards/daisy_seed_with_sdram/mpconfigboard.mk

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ USB_PID = 0x5740
33
USB_PRODUCT = "Daisy Seed"
44
USB_MANUFACTURER = "STMicroelectronics"
55

6-
# INTERNAL_FLASH_FILESYSTEM = 1
7-
QSPI_FLASH_FILESYSTEM = 1
8-
# EXTERNAL_FLASH_DEVICES = N25Q128A
6+
# Small FS created on half of the internal flash -- other half is reserved for the H750 bootloader
7+
INTERNAL_FLASH_FILESYSTEM = 1
98

109
MCU_SERIES = H7
1110
MCU_VARIANT = STM32H750xx

ports/stm/supervisor/internal_flash.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,15 @@ static uint8_t _flash_cache[0x8000] __attribute__((aligned(4)));
6464
#endif
6565
#elif defined(STM32H7)
6666

67+
#if defined(STM32H750xx)
68+
static const flash_layout_t flash_layout[] = {
69+
{ 0x08000000, 0x20000, 1 },
70+
};
71+
#else
6772
static const flash_layout_t flash_layout[] = {
6873
{ 0x08000000, 0x20000, 16 },
6974
};
75+
#endif
7076
static uint8_t _flash_cache[0x20000] __attribute__((aligned(4)));
7177

7278
#elif defined(STM32L4)
@@ -80,18 +86,17 @@ static uint8_t _flash_cache[0x1000] __attribute__((aligned(4)));
8086
#endif
8187

8288
#define NO_CACHE 0xffffffff
83-
#define MAX_CACHE 0x4000
8489

8590

8691
static uint32_t _cache_flash_addr = NO_CACHE;
8792

8893
#if defined(STM32H7)
8994
// get the bank of a given flash address
90-
9195
static uint32_t get_bank(uint32_t addr) {
9296
#if defined(STM32H750xx) // H750 only has 1 bank
93-
return FLASH_BANK_1;
97+
return FLASH_BANK_1;
9498
#else
99+
95100
if (READ_BIT(FLASH->OPTCR, FLASH_OPTCR_SWAP_BANK) == 0) {
96101
// no bank swap
97102
if (addr < (FLASH_BASE + FLASH_BANK_SIZE)) {
@@ -106,9 +111,9 @@ static uint32_t get_bank(uint32_t addr) {
106111
} else {
107112
return FLASH_BANK_1;
108113
}
109-
}
114+
}
110115
#endif
111-
}
116+
}
112117
#endif
113118

114119
uint32_t flash_get_sector_info(uint32_t addr, uint32_t *start_addr, uint32_t *size) {
@@ -191,6 +196,9 @@ void port_internal_flash_flush(void) {
191196
uint32_t sector_start_addr = 0xffffffff;
192197
#if defined(STM32H7)
193198
EraseInitStruct.Banks = get_bank(_cache_flash_addr);
199+
#if defined(STM32H750xx)
200+
EraseInitStruct.NbSectors = 1;
201+
#endif
194202
#endif
195203
#if CPY_STM32L4
196204
EraseInitStruct.Page = flash_get_sector_info(_cache_flash_addr, &sector_start_addr, &sector_size);

ports/stm/supervisor/internal_flash.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@
8181
#define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x08020000
8282
#endif
8383

84-
#ifdef STM32H750xx // todo
85-
#define STM32_FLASH_SIZE 0x200000 // 2MB
86-
#define INTERNAL_FLASH_FILESYSTEM_SIZE 0x60000 // 384KiB
87-
#define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x08020000
84+
#ifdef STM32H750xx
85+
#define STM32_FLASH_SIZE 0x20000
86+
#define INTERNAL_FLASH_FILESYSTEM_SIZE 0x10000
87+
#define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x8010000
8888
#endif
8989

9090
#ifdef STM32L4R5xx

0 commit comments

Comments
 (0)