Skip to content

Commit 947c224

Browse files
committed
add feather bootloader settings, cleanup
1 parent 3c86005 commit 947c224

File tree

6 files changed

+26
-46
lines changed

6 files changed

+26
-46
lines changed

ports/stm32f4/boards/STM32F401_boot.ld

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
/* Specify the memory areas */
66
MEMORY
77
{
8-
FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 512K - 64K /* entire flash */
9-
FLASH_ISR (rx) : ORIGIN = 0x08010000, LENGTH = 64K
10-
FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 384K /* sector 4 is 64K, sectors 5,6,7 are 128K */
8+
FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 512K - 64K /* entire flash, sans bootloader region */
9+
FLASH_ISR (rx) : ORIGIN = 0x08010000, LENGTH = 64K /* sector 4 */
10+
FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 384K /* sectors 5,6,7 are 128K */
1111
RAM (xrw) : ORIGIN = 0x20000194, LENGTH = 96K - 0x194
1212
}
1313

ports/stm32f4/boards/STM32F401.ld renamed to ports/stm32f4/boards/STM32F405_boot.ld

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,30 @@
11
/*
2-
GNU linker script for STM32F401 with bootloader (from Meowbit Micropython)
3-
Doesn't work:
4-
5-
Traceback (most recent call last):
6-
File "../../tools/build_memory_info.py", line 64, in <module>
7-
regions[region] = int(eval(space))
8-
File "<string>", line 1, in <module>
9-
NameError: name 'FLASH_ISR' is not defined
2+
GNU linker script for STM32F405 with bootloader
3+
Based on Micropython
104
*/
115

126
/* Specify the memory areas */
13-
/* FLASH_FS (rx) : ORIGIN = 0x08020000, LENGTH = 128K */
14-
/* sectors 5 128K */
157
MEMORY
168
{
17-
FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 512K - 64K /* entire flash */
18-
FLASH_ISR (rx) : ORIGIN = 0x08010000, LENGTH = 64K /* sector 4, sec 0~3 reserved for booloader */
19-
FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 384K /* sectors 5, 6,7 are 128K */
20-
RAM (xrw) : ORIGIN = 0x20000194, LENGTH = 96K - 0x194
9+
FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 1024K - 64K /* entire flash, sans bootloader region */
10+
FLASH_ISR (rx) : ORIGIN = 0x08010000, LENGTH = 64K /* sector 0 */
11+
FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 1024K - 64K - 64K /* sectors 5+ */
12+
CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K
13+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
2114
}
2215

2316
/* produce a link error if there is not this amount of RAM for these sections */
2417
_minimum_stack_size = 2K;
2518
_minimum_heap_size = 16K;
2619

27-
/* Define the stack. The stack is full descending so begins just above last byte
28-
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
29-
_estack = ORIGIN(RAM) + LENGTH(RAM) - _estack_reserve;
30-
_sstack = _estack - 16K; /* tunable */
20+
/* Define tho top end of the stack. The stack is full descending so begins just
21+
above last byte of RAM. Note that EABI requires the stack to be 8-byte
22+
aligned for a call. */
23+
_estack = ORIGIN(RAM) + LENGTH(RAM);
3124

3225
/* RAM extents for the garbage collector */
3326
_ram_start = ORIGIN(RAM);
3427
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
35-
_heap_start = _ebss; /* heap starts just after statically allocated memory */
36-
_heap_end = _sstack;
3728

3829
ENTRY(Reset_Handler)
3930

@@ -47,25 +38,8 @@ SECTIONS
4738
KEEP(*(.isr_vector)) /* Startup code */
4839

4940
/* This first flash block is 16K annd the isr vectors only take up
50-
about 400 bytes. So we pull in a couple of object files to pad it
51-
out. */
52-
53-
. = ALIGN(4);
54-
55-
/* NOTE: If you update the list of files contained in .isr_vector,
56-
then be sure to also update smhal/Makefile where it forcibly
57-
builds each of these files with -Os */
58-
59-
*/ff.o(.text*)
60-
*/vfs_fat_*.o(.text*)
61-
*/py/formatfloat.o(.text*)
62-
*/py/parsenum.o(.text*)
63-
*/py/mpprint.o(.text*)
64-
65-
*/py/compile.o(.text*)
66-
*/py/objset.o(.text*)
67-
*/py/mpz.o(.text*)
68-
*/py/vm.o(.text*)
41+
about 400 bytes. Micropython pads this with files, but this didn't
42+
work with the size of Circuitpython's ff object. */
6943

7044
. = ALIGN(4);
7145
} >FLASH_ISR
@@ -130,3 +104,5 @@ SECTIONS
130104

131105
.ARM.attributes 0 : { *(.ARM.attributes) }
132106
}
107+
108+

ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
#define SPI_FLASH_SCK_PIN (&pin_PB03)
4141
#define SPI_FLASH_CS_PIN (&pin_PA15)
4242

43+
// Bootloader only
44+
#define BOARD_VTOR_DEFER //Leave VTOR relocation to bootloader
45+
4346
#define DEFAULT_I2C_BUS_SCL (&pin_PB06)
4447
#define DEFAULT_I2C_BUS_SDA (&pin_PB07)
4548

ports/stm32f4/boards/feather_stm32f405_express/mpconfigboard.mk

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1
99
EXTERNAL_FLASH_DEVICES = GD25Q16C
1010
LONGINT_IMPL = MPZ
1111

12+
BOOTLOADER_OFFSET = 0x8010000
13+
1214
MCU_SERIES = m4
1315
MCU_VARIANT = stm32f4
1416
MCU_SUB_VARIANT = stm32f405xx
1517
MCU_PACKAGE = 64
1618
CMSIS_MCU = STM32F405xx
17-
LD_FILE = boards/STM32F405.ld
18-
TEXT0_ADDR = 0x08000000
19-
TEXT1_ADDR = 0x08010000
19+
LD_FILE = boards/STM32F405_boot.ld # use for bootloader (external fs only)
20+
# LD_FILE = boards/STM32F405_fs.ld # use for internal filesystem

ports/stm32f4/boards/meowbit_v121/mpconfigboard.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ MCU_SUB_VARIANT = stm32f401xe
2020
MCU_PACKAGE = 64
2121
CMSIS_MCU = STM32F401xE
2222
LD_FILE = boards/STM32F401_boot.ld
23-
# LD_FILE = boards/STM32F401_fs.ld #use for internal flash
23+
# LD_FILE = boards/STM32F401_fs.ld # use for internal flash

0 commit comments

Comments
 (0)