Skip to content

Commit 5bbaa3b

Browse files
committed
feat(swan_r5): the upper 1MB of flash (bank 2) is made available for the filesystem
1 parent b607631 commit 5bbaa3b

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

ports/stm/boards/STM32L4R5_boot.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ MEMORY
88
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K /* entire flash */
99
FLASH_ISR (rx) : ORIGIN = 0x08010000, LENGTH = 4K /* ISR vector. Kind of wasteful. */
1010
FLASH_FIRMWARE (rx) : ORIGIN = 0x08011000, LENGTH = 1024K-128K-64K-4K /* For now, limit to 1MB so that bank switching is still possible. */
11-
FLASH_FS (rw) : ORIGIN = 0x080e0000, LENGTH = 128K
11+
FLASH_FS (rw) : ORIGIN = 0x08100000, LENGTH = 1024K
1212
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 640K
1313
}
1414

ports/stm/boards/STM32L4R5_default.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ MEMORY
88
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K /* entire flash */
99
FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 4K /* ISR vector. Kind of wasteful. */
1010
FLASH_FIRMWARE (rx) : ORIGIN = 0x08001000, LENGTH = 1024K-128K-4K /* For now, limit to 1MB so that bank switching is still possible. */
11-
FLASH_FS (rw) : ORIGIN = 0x080e0000, LENGTH = 128K
11+
FLASH_FS (rw) : ORIGIN = 0x08100000, LENGTH = 1024K
1212
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 640K
1313
}
1414

ports/stm/supervisor/internal_flash.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,8 @@ STATIC const flash_layout_t flash_layout[] = {
9595
STATIC uint8_t _flash_cache[0x20000] __attribute__((aligned(4)));
9696

9797
#elif defined(STM32L4)
98-
// todo - the L4 devices can have different flash sizes and different page sizes
99-
// depending upon the dual bank configuration
100-
// This is hardcoded for the Swan R5. When support for other devices is needed more conditionals will be required
101-
// to differentiate.
10298
STATIC const flash_layout_t flash_layout[] = {
103-
{ 0x08000000, 0x1000, 256 },
99+
{ 0x08100000, 0x1000, 256 },
104100
};
105101
STATIC uint8_t _flash_cache[0x1000] __attribute__((aligned(4)));
106102

@@ -174,6 +170,9 @@ uint32_t flash_get_sector_info(uint32_t addr, uint32_t *start_addr, uint32_t *si
174170
}
175171

176172
void supervisor_flash_init(void) {
173+
#ifdef STM32L4
174+
// todo - check that the device is in dual bank mode
175+
#endif
177176
}
178177

179178
uint32_t supervisor_flash_get_block_size(void) {
@@ -202,7 +201,7 @@ void port_internal_flash_flush(void) {
202201
FLASH_EraseInitTypeDef EraseInitStruct = {};
203202
#if CPY_STM32L4
204203
EraseInitStruct.TypeErase = TYPEERASE_PAGES;
205-
EraseInitStruct.Banks = FLASH_BANK_1;
204+
EraseInitStruct.Banks = FLASH_BANK_2; // filesystem stored in upper 1MB of flash in dual bank mode
206205
#else
207206
EraseInitStruct.TypeErase = TYPEERASE_SECTORS;
208207
EraseInitStruct.VoltageRange = VOLTAGE_RANGE_3; // voltage range needs to be 2.7V to 3.6V

ports/stm/supervisor/internal_flash.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@
9797
#endif
9898

9999
#ifdef STM32L4R5xx
100-
#define STM32_FLASH_SIZE 0x100000 // 1MB // for now just use the first bank
101-
#define INTERNAL_FLASH_FILESYSTEM_SIZE 0x20000 // 128KiB
102-
#define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x080e0000
100+
#define STM32_FLASH_SIZE 0x200000 // 2MB
101+
#define INTERNAL_FLASH_FILESYSTEM_SIZE 0x100000 // 1024KiB
102+
#define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x08100000
103103
#endif
104104

105105
#define INTERNAL_FLASH_FILESYSTEM_NUM_BLOCKS (INTERNAL_FLASH_FILESYSTEM_SIZE / FILESYSTEM_BLOCK_SIZE)

0 commit comments

Comments
 (0)