Skip to content

Commit 7a9c183

Browse files
dhylandsdpgeorge
authored andcommitted
stmhal: Fix ESPRUINO_PICO by adding ld scripts with correct flash size.
1 parent cecf6be commit 7a9c183

File tree

7 files changed

+55
-14
lines changed

7 files changed

+55
-14
lines changed

stmhal/Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,15 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_USBDEV:.c=.o))
261261
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
262262
OBJ += $(BUILD)/pins_$(BOARD).o
263263

264-
# We put ff.o and stm32f4xx_hal_sd.o into the first 16K section with the ISRs.
264+
# We put several files into the first 16K section with the ISRs.
265265
# If we compile these using -O0 then it won't fit. So if you really want these
266-
# to be compiled with -O0, then edit stm32f405.ld (in the .isr_vector section)
267-
# and comment out the following 2 lines.
266+
# to be compiled with -O0, then edit boards/common.ld (in the .isr_vector section)
267+
# and comment out the following lines.
268268
$(BUILD)/$(FATFS_DIR)/ff.o: COPT += -Os
269-
$(BUILD)/$(HAL_DIR)/src/stm32$(MCU_SERIES)xx_hal_sd.o: COPT += -Os
269+
$(filter $(PY_BUILD)/../extmod/vfs_fat_%.o, $(PY_O)): COPT += -Os
270+
$(PY_BUILD)/formatfloat.o: COPT += -Os
271+
$(PY_BUILD)/parsenum.o: COPT += -Os
272+
$(PY_BUILD)/mpprint.o: COPT += -Os
270273

271274
all: $(BUILD)/firmware.dfu $(BUILD)/firmware.hex
272275

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
MCU_SERIES = f4
22
CMSIS_MCU = STM32F401xE
33
AF_FILE = boards/stm32f401_af.csv
4-
LD_FILE = boards/stm32f401.ld
4+
LD_FILE = boards/stm32f401xd.ld

stmhal/boards/ESPRUINO_PICO/stm32f4xx_hal_conf.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
*/
5555
#define HAL_MODULE_ENABLED
5656
#define HAL_ADC_MODULE_ENABLED
57-
#define HAL_CAN_MODULE_ENABLED
57+
/* #define HAL_CAN_MODULE_ENABLED */
5858
/* #define HAL_CRC_MODULE_ENABLED */
5959
/* #define HAL_CRYP_MODULE_ENABLED */
60-
#define HAL_DAC_MODULE_ENABLED
60+
/* #define HAL_DAC_MODULE_ENABLED */
6161
/* #define HAL_DCMI_MODULE_ENABLED */
6262
#define HAL_DMA_MODULE_ENABLED
6363
/* #define HAL_DMA2D_MODULE_ENABLED */
@@ -79,7 +79,7 @@
7979
#define HAL_RNG_MODULE_ENABLED
8080
#define HAL_RTC_MODULE_ENABLED
8181
/* #define HAL_SAI_MODULE_ENABLED */
82-
#define HAL_SD_MODULE_ENABLED
82+
/* #define HAL_SD_MODULE_ENABLED */
8383
#define HAL_SPI_MODULE_ENABLED
8484
#define HAL_TIM_MODULE_ENABLED
8585
#define HAL_UART_MODULE_ENABLED
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
MCU_SERIES = f4
22
CMSIS_MCU = STM32F401xE
33
AF_FILE = boards/stm32f401_af.csv
4-
LD_FILE = boards/stm32f401.ld
4+
LD_FILE = boards/stm32f401xe.ld

stmhal/boards/common.ld

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,16 @@ SECTIONS
1414
out. */
1515

1616
. = ALIGN(4);
17+
18+
/* NOTE: If you update the list of files contained in .isr_vector,
19+
then be sure to also update smhal/Makefile where it forcibly
20+
builds each of these files with -Os */
21+
1722
*/ff.o(.text*)
18-
*/stm32f4xx_hal_sd.o(.text*)
23+
*/vfs_fat_*.o(.text*)
24+
*/py/formatfloat.o(.text*)
25+
*/py/parsenum.o(.text*)
26+
*/py/mpprint.o(.text*)
1927

2028
. = ALIGN(4);
2129
} >FLASH_ISR

stmhal/boards/stm32f401xd.ld

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
GNU linker script for STM32F401xD
3+
*/
4+
5+
/* Specify the memory areas */
6+
MEMORY
7+
{
8+
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0x060000 /* entire flash, 384 KiB */
9+
FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 0x004000 /* sector 0, 16 KiB */
10+
FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 0x01C000 /* sectors 1,2,3 are 16K, 4 is 64K */
11+
FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 0x040000 /* sectors 5,6 2*128KiB = 256 KiB */
12+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 0x018000 /* 96 KiB */
13+
}
14+
15+
/* produce a link error if there is not this amount of RAM for these sections */
16+
_minimum_stack_size = 2K;
17+
_minimum_heap_size = 16K;
18+
19+
/* Define tho top end of the stack. The stack is full descending so begins just
20+
above last byte of RAM. Note that EABI requires the stack to be 8-byte
21+
aligned for a call. */
22+
_estack = ORIGIN(RAM) + LENGTH(RAM);
23+
24+
/* define common sections and symbols */
25+
INCLUDE common.ld
26+
27+
/* RAM extents for the garbage collector */
28+
_ram_start = ORIGIN(RAM);
29+
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
30+
_heap_start = _ebss; /* heap starts just after statically allocated memory */
31+
_heap_end = 0x20014000; /* tunable */

stmhal/boards/stm32f401.ld renamed to stmhal/boards/stm32f401xe.ld

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
/*
2-
GNU linker script for STM32F401
2+
GNU linker script for STM32F401xE
33
*/
44

55
/* Specify the memory areas */
6-
/* TODO verify these regions */
76
MEMORY
87
{
98
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0x080000 /* entire flash, 512 KiB */
109
FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 0x004000 /* sector 0, 16 KiB */
11-
/* sectors 1,2,3 are 16K, 4 is 64K (for filesystem) */
12-
FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 0x080000 /* sectors 5,6,7 3*128KiB = 384 KiB */
10+
FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 0x01C000 /* sectors 1,2,3 are 16K, 4 is 64K */
11+
FLASH_TEXT (rx) : ORIGIN = 0x08020000, LENGTH = 0x060000 /* sectors 5,6,7 3*128KiB = 384 KiB */
1312
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 0x018000 /* 96 KiB */
1413
}
1514

0 commit comments

Comments
 (0)