Skip to content

Commit 661c20d

Browse files
committed
Create a new linker script with more space for the firmware.
1 parent fe6e50b commit 661c20d

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
GNU linker script for STM32F411 with nvm and an external flash chip, and reserves
3+
more space for the CircuitPython firmware and less for the filesystem
4+
(since the filesystem will be on the external flash chip).
5+
*/
6+
7+
/* Specify the memory areas */
8+
MEMORY
9+
{
10+
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* entire flash */
11+
FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K /* sector 0 */
12+
FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 32K /* sectors 1,2 are 16K */
13+
FLASH_NVM (rwx) : ORIGIN = 0x0800C000, LENGTH = 16K /* sector 3 is 16K */
14+
FLASH_FIRMWARE (rx) : ORIGIN = 0x08010000, LENGTH = 448K /* sector 4 is 64K, sectors 5,6,7 are 128K */
15+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
16+
}
17+
18+
/* produce a link error if there is not this amount of RAM for these sections */
19+
_minimum_stack_size = 24K;
20+
_minimum_heap_size = 16K;
21+
22+
/* Define the top end of the stack. The stack is full descending so begins just
23+
above last byte of RAM. Note that EABI requires the stack to be 8-byte
24+
aligned for a call. */
25+
_estack = ORIGIN(RAM) + LENGTH(RAM);
26+
27+
/* RAM extents for the garbage collector */
28+
_ram_start = ORIGIN(RAM);
29+
_ram_end = ORIGIN(RAM) + LENGTH(RAM);

ports/stm/boards/thunderpack_v12/mpconfigboard.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@
2828

2929
// Non-volatile memory config
3030
#define CIRCUITPY_INTERNAL_NVM_SIZE (0x4000)
31-
#define CIRCUITPY_INTERNAL_NVM_START_ADDR (0x08010000)
32-
#define CIRCUITPY_INTERNAL_NVM_SECTOR FLASH_SECTOR_4
31+
#define CIRCUITPY_INTERNAL_NVM_START_ADDR (0x0800C000)
32+
#define CIRCUITPY_INTERNAL_NVM_SECTOR FLASH_SECTOR_3
3333
#define NVM_BYTEARRAY_BUFFER_SIZE 512
3434

3535
// Flash config
36-
#define FLASH_SIZE (0x80000)
37-
#define FLASH_PAGE_SIZE (0x4000)
38-
#define BOARD_FLASH_SIZE (FLASH_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE- 0x2000 - 0xC000)
36+
#define FLASH_SIZE (0x80000)
37+
#define FLASH_PAGE_SIZE (0x4000)
38+
#define BOARD_FLASH_SIZE (FLASH_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE- 0x2000 - 0xC000)
39+
#define INTERNAL_FLASH_FILESYSTEM_SIZE 0x8000
40+
#define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x08004000
3941

4042
// On-board flash
4143
#define SPI_FLASH_MOSI_PIN (&pin_PB15)

ports/stm/boards/thunderpack_v12/mpconfigboard.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ MCU_VARIANT = STM32F411xE
1717
MCU_PACKAGE = UFQFPN48
1818

1919
LD_COMMON = boards/common_nvm.ld
20-
LD_FILE = boards/STM32F411_nvm.ld
20+
LD_FILE = boards/STM32F411_nvm_flash.ld

ports/stm/supervisor/internal_flash.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,13 @@
4141

4242
#ifdef STM32F411xE
4343
#define STM32_FLASH_SIZE 0x80000 //512KiB
44+
#ifndef INTERNAL_FLASH_FILESYSTEM_SIZE
4445
#define INTERNAL_FLASH_FILESYSTEM_SIZE 0xC000 //48KiB
46+
#endif
47+
#ifndef INTERNAL_FLASH_FILESYSTEM_START_ADDR
4548
#define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x08004000
4649
#endif
50+
#endif
4751

4852
#ifdef STM32F412Zx
4953
#define STM32_FLASH_SIZE 0x100000 //1MB

0 commit comments

Comments
 (0)