Skip to content

Commit 14cf91f

Browse files
chrismas9dpgeorge
authored andcommitted
stm32: In link script, define start of stack separately from heap end.
Previously the end of the heap was the start (lowest address) of the stack. With the changes in this commit these addresses are now independent, allowing a board to place the heap and stack in separate locations.
1 parent 8b18cfe commit 14cf91f

26 files changed

+92
-86
lines changed

ports/stm32/boards/PYBD_SF2/f722_qspi.ld

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ MEMORY
2929
_minimum_stack_size = 2K;
3030
_minimum_heap_size = 16K;
3131

32-
/* Define tho top end of the stack. The stack is full descending so begins just
33-
above last byte of RAM. Note that EABI requires the stack to be 8-byte
34-
aligned for a call. */
32+
/* Define the stack. The stack is full descending so begins just above last byte
33+
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
3534
_estack = ORIGIN(RAM) + LENGTH(RAM);
35+
_sstack = _estack - 16K;
3636

3737
/* RAM extents for the garbage collector */
3838
_ram_start = ORIGIN(RAM);
3939
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
4040
_heap_start = _ebss; /* heap starts just after statically allocated memory */
41-
_heap_end = _ram_end - 16K; /* 16k stack */
41+
_heap_end = _sstack;
4242

4343
ENTRY(Reset_Handler)
4444

ports/stm32/boards/PYBD_SF6/f767.ld

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ MEMORY
2828
_minimum_stack_size = 2K;
2929
_minimum_heap_size = 16K;
3030

31-
/* Define tho top end of the stack. The stack is full descending so begins just
32-
above last byte of RAM. Note that EABI requires the stack to be 8-byte
33-
aligned for a call. */
31+
/* Define the stack. The stack is full descending so begins just above last byte
32+
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
3433
_estack = ORIGIN(RAM) + LENGTH(RAM);
34+
_sstack = _estack - 24K;
3535

3636
/* RAM extents for the garbage collector */
3737
_ram_start = ORIGIN(RAM);
3838
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
3939
_heap_start = _ebss; /* heap starts just after statically allocated memory */
40-
_heap_end = _ram_end - 24K; /* 24k stack */
40+
_heap_end = _sstack;
4141

4242
ENTRY(Reset_Handler)
4343

ports/stm32/boards/STM32F769DISC/f769_qspi.ld

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@ MEMORY
2727
_minimum_stack_size = 2K;
2828
_minimum_heap_size = 16K;
2929

30-
/* Define tho top end of the stack */
30+
/* Define the stack. The stack is full descending so begins just above last byte
31+
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
3132
_estack = ORIGIN(RAM) + LENGTH(RAM);
33+
_sstack = _estack - 32K; /* tunable */
3234

3335
/* RAM extents for the garbage collector */
3436
_ram_start = ORIGIN(RAM);
3537
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
3638
_heap_start = _ebss; /* heap starts just after statically allocated memory */
37-
_heap_end = 0x20078000; /* tunable */
39+
_heap_end = _sstack;
3840

3941
ENTRY(Reset_Handler)
4042

ports/stm32/boards/stm32f091xc.ld

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ MEMORY
1414
_minimum_stack_size = 2K;
1515
_minimum_heap_size = 16K;
1616

17-
/* Define tho top end of the stack. The stack is full descending so begins just
18-
above last byte of RAM. Note that EABI requires the stack to be 8-byte
19-
aligned for a call. */
17+
/* Define the stack. The stack is full descending so begins just above last byte above last byte
18+
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
2019
_estack = ORIGIN(RAM) + LENGTH(RAM);
20+
_sstack = _estack - 6K; /* tunable */
2121

2222
/* RAM extents for the garbage collector */
2323
_ram_start = ORIGIN(RAM);
2424
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
2525
_heap_start = _ebss; /* heap starts just after statically allocated memory */
26-
_heap_end = 0x20006800; /* room for a 6k stack */
26+
_heap_end = _sstack;

ports/stm32/boards/stm32f401xd.ld

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ MEMORY
1414

1515
/* produce a link error if there is not this amount of RAM for these sections */
1616
_minimum_stack_size = 2K;
17-
_minimum_heap_size = 16K;
17+
_minimum_heap_size = 16K; /* tunable */
1818

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. */
19+
/* Define the stack. The stack is full descending so begins just above last byte
20+
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
2221
_estack = ORIGIN(RAM) + LENGTH(RAM);
22+
_sstack = _estack - 16K;
2323

2424
/* RAM extents for the garbage collector */
2525
_ram_start = ORIGIN(RAM);
2626
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
2727
_heap_start = _ebss; /* heap starts just after statically allocated memory */
28-
_heap_end = 0x20014000; /* tunable */
28+
_heap_end = _sstack;

ports/stm32/boards/stm32f401xe.ld

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ MEMORY
1616
_minimum_stack_size = 2K;
1717
_minimum_heap_size = 16K;
1818

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. */
19+
/* Define the stack. The stack is full descending so begins just above last byte
20+
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
2221
_estack = ORIGIN(RAM) + LENGTH(RAM);
22+
_sstack = _estack - 16K; /* tunable */
2323

2424
/* RAM extents for the garbage collector */
2525
_ram_start = ORIGIN(RAM);
2626
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
2727
_heap_start = _ebss; /* heap starts just after statically allocated memory */
28-
_heap_end = 0x20014000; /* tunable */
28+
_heap_end = _sstack;

ports/stm32/boards/stm32f405.ld

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ MEMORY
1717
_minimum_stack_size = 2K;
1818
_minimum_heap_size = 16K;
1919

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. */
20+
/* Define the stack. The stack is full descending so begins just above last byte
21+
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
2322
_estack = ORIGIN(RAM) + LENGTH(RAM);
23+
_sstack = _estack - 16K; /* tunable */
2424

2525
/* RAM extents for the garbage collector */
2626
_ram_start = ORIGIN(RAM);
2727
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
2828
_heap_start = _ebss; /* heap starts just after statically allocated memory */
29-
_heap_end = 0x2001c000; /* tunable */
29+
_heap_end = _sstack;

ports/stm32/boards/stm32f411.ld

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ MEMORY
1616
_minimum_stack_size = 2K;
1717
_minimum_heap_size = 16K;
1818

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. */
19+
/* Define the stack. The stack is full descending so begins just above last byte
20+
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
2221
_estack = ORIGIN(RAM) + LENGTH(RAM);
22+
_sstack = _estack - 16K; /* tunable */
2323

2424
/* RAM extents for the garbage collector */
2525
_ram_start = ORIGIN(RAM);
2626
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
2727
_heap_start = _ebss; /* heap starts just after statically allocated memory */
28-
_heap_end = 0x2001c000; /* tunable */
28+
_heap_end = _sstack;

ports/stm32/boards/stm32f413xg.ld

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ MEMORY
1919
_minimum_stack_size = 2K;
2020
_minimum_heap_size = 16K;
2121

22-
/* Define tho 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. */
22+
/* Define the stack. The stack is full descending so begins just above last byte
23+
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
2524
_estack = ORIGIN(RAM) + LENGTH(RAM);
25+
_sstack = _estack - 16K; /* tunable */
2626

2727
/* RAM extents for the garbage collector */
2828
_ram_start = ORIGIN(RAM);
2929
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
3030
_heap_start = _ebss; /* heap starts just after statically allocated memory */
31-
_heap_end = _ram_end - 16K; /* 240K, tunable */
31+
_heap_end = _sstack;

ports/stm32/boards/stm32f413xh.ld

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ MEMORY
1919
_minimum_stack_size = 2K;
2020
_minimum_heap_size = 16K;
2121

22-
/* Define tho 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. */
22+
/* Define the stack. The stack is full descending so begins just above last byte
23+
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
2524
_estack = ORIGIN(RAM) + LENGTH(RAM);
25+
_sstack = _estack - 16K; /* tunable */
2626

2727
/* RAM extents for the garbage collector */
2828
_ram_start = ORIGIN(RAM);
2929
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
3030
_heap_start = _ebss; /* heap starts just after statically allocated memory */
31-
_heap_end = _ram_end - 16K; /* 240K, tunable */
31+
_heap_end = _sstack;

ports/stm32/boards/stm32f429.ld

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ MEMORY
1717
_minimum_stack_size = 2K;
1818
_minimum_heap_size = 16K;
1919

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. */
20+
/* Define the stack. The stack is full descending so begins just above last byte
21+
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
2322
_estack = ORIGIN(RAM) + LENGTH(RAM);
23+
_sstack = _estack - 16K; /* tunable */
2424

2525
/* RAM extents for the garbage collector */
2626
_ram_start = ORIGIN(RAM);
2727
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
2828
_heap_start = _ebss; /* heap starts just after statically allocated memory */
29-
_heap_end = 0x2002c000; /* tunable */
29+
_heap_end = _sstack;

ports/stm32/boards/stm32f439.ld

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ MEMORY
1818
_minimum_stack_size = 2K;
1919
_minimum_heap_size = 16K;
2020

21-
/* top end of the stack */
21+
/* Define the stack. The stack is full descending so begins just above last byte
22+
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
2223
_estack = ORIGIN(RAM) + LENGTH(RAM);
24+
_sstack = _estack - 16K; /* tunable */
2325

2426
/* RAM extents for the garbage collector */
2527
_ram_start = ORIGIN(RAM);
2628
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
2729
_heap_start = _ebss; /* heap starts just after statically allocated memory */
28-
_heap_end = 0x2002c000; /* tunable */
30+
_heap_end = _sstack;

ports/stm32/boards/stm32f722.ld

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ MEMORY
1515
_minimum_stack_size = 2K;
1616
_minimum_heap_size = 16K;
1717

18-
/* Define tho top end of the stack. The stack is full descending so begins just
19-
above last byte of RAM. Note that EABI requires the stack to be 8-byte
20-
aligned for a call. */
18+
/* Define the stack. The stack is full descending so begins just above last byte
19+
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
2120
_estack = ORIGIN(RAM) + LENGTH(RAM);
21+
_sstack = _estack - 32K; /* tunable */
2222

2323
/* RAM extents for the garbage collector */
2424
_ram_start = ORIGIN(RAM);
2525
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
2626
_heap_start = _ebss; /* heap starts just after statically allocated memory */
27-
_heap_end = 0x20038000; /* tunable */
27+
_heap_end = _sstack;

ports/stm32/boards/stm32f746.ld

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
GNU linker script for STM32F405
2+
GNU linker script for STM32F746
33
*/
44

55
/* Specify the memory areas */
@@ -17,13 +17,13 @@ MEMORY
1717
_minimum_stack_size = 2K;
1818
_minimum_heap_size = 16K;
1919

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. */
20+
/* Define the stack. The stack is full descending so begins just above last byte
21+
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
2322
_estack = ORIGIN(RAM) + LENGTH(RAM);
23+
_sstack = _estack - 16K; /* tunable */
2424

2525
/* RAM extents for the garbage collector */
2626
_ram_start = ORIGIN(RAM);
2727
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
2828
_heap_start = _ebss; /* heap starts just after statically allocated memory */
29-
_heap_end = 0x2004c000; /* tunable */
29+
_heap_end = _sstack;

ports/stm32/boards/stm32f767.ld

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ MEMORY
1818
_minimum_stack_size = 2K;
1919
_minimum_heap_size = 16K;
2020

21-
/* Define tho top end of the stack. The stack is full descending so begins just
22-
above last byte of RAM. Note that EABI requires the stack to be 8-byte
23-
aligned for a call. */
21+
/* Define the stack. The stack is full descending so begins just above last byte
22+
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
2423
_estack = ORIGIN(RAM) + LENGTH(RAM);
24+
_sstack = _estack - 32K; /* tunable */
2525

2626
/* RAM extents for the garbage collector */
2727
_ram_start = ORIGIN(RAM);
2828
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
2929
_heap_start = _ebss; /* heap starts just after statically allocated memory */
30-
_heap_end = 0x20078000; /* tunable */
30+
_heap_end = _sstack;

ports/stm32/boards/stm32f769.ld

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ MEMORY
1717
_minimum_stack_size = 2K;
1818
_minimum_heap_size = 16K;
1919

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. */
20+
/* Define the stack. The stack is full descending so begins just above last byte
21+
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
2322
_estack = ORIGIN(RAM) + LENGTH(RAM);
23+
_sstack = _estack - 32K; /* tunable */
2424

2525
/* RAM extents for the garbage collector */
2626
_ram_start = ORIGIN(RAM);
2727
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
2828
_heap_start = _ebss; /* heap starts just after statically allocated memory */
29-
_heap_end = 0x20078000; /* tunable */
29+
_heap_end = _sstack;

ports/stm32/boards/stm32h743.ld

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ MEMORY
1717
_minimum_stack_size = 2K;
1818
_minimum_heap_size = 16K;
1919

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. */
20+
/* Define the stack. The stack is full descending so begins just above last byte
21+
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
2322
_estack = ORIGIN(RAM) + LENGTH(RAM);
23+
_sstack = _estack - 16K; /* tunable */
2424

2525
/* RAM extents for the garbage collector */
2626
_ram_start = ORIGIN(RAM);
2727
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
2828
_heap_start = _ebss; /* heap starts just after statically allocated memory */
29-
_heap_end = 0x2407C000; /* tunable */
29+
_heap_end = _sstack;

ports/stm32/boards/stm32l432.ld

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ MEMORY
1515
_minimum_stack_size = 2K;
1616
_minimum_heap_size = 16K;
1717

18-
/* Define the top end of the stack. The stack is full descending so begins just
19-
above last byte of RAM. Note that EABI requires the stack to be 8-byte
20-
aligned for a call. */
18+
/* Define the stack. The stack is full descending so begins just above last byte
19+
of RAM. Note that EABI requires the stack to be 8-byte aligned for a call. */
2120
_estack = ORIGIN(RAM) + LENGTH(RAM);
21+
_sstack = _estack - 6K; /* tunable */
2222

2323
/* RAM extents for the garbage collector */
2424
_ram_start = ORIGIN(RAM);
2525
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
2626
_heap_start = _ebss; /* heap starts just after statically allocated memory */
27-
_heap_end = 0x2000A800; /* room for a 6k stack */
27+
_heap_end = _sstack;

ports/stm32/boards/stm32l476xe.ld

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ MEMORY
1818
_minimum_stack_size = 2K;
1919
_minimum_heap_size = 16K;
2020

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

2626
/* RAM extents for the garbage collector */
2727
_ram_fs_cache_start = ORIGIN(FS_CACHE);
2828
_ram_fs_cache_end = ORIGIN(FS_CACHE) + LENGTH(FS_CACHE);
2929
_ram_start = ORIGIN(RAM);
3030
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
3131
_heap_start = _ebss; /* heap starts just after statically allocated memory */
32-
_heap_end = 0x20014000; /* tunable */
32+
_heap_end = _sstack;
3333

3434
_flash_fs_start = ORIGIN(FLASH_FS);
3535
_flash_fs_end = ORIGIN(FLASH_FS) + LENGTH(FLASH_FS);

ports/stm32/boards/stm32l476xg.ld

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ MEMORY
1818
_minimum_stack_size = 2K;
1919
_minimum_heap_size = 16K;
2020

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

2626
/* RAM extents for the garbage collector */
2727
_ram_fs_cache_start = ORIGIN(FS_CACHE);
2828
_ram_fs_cache_end = ORIGIN(FS_CACHE) + LENGTH(FS_CACHE);
2929
_ram_start = ORIGIN(RAM);
3030
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
3131
_heap_start = _ebss; /* heap starts just after statically allocated memory */
32-
_heap_end = 0x20014000; /* tunable */
32+
_heap_end = _sstack;
3333

3434
_flash_fs_start = ORIGIN(FLASH_FS);
3535
_flash_fs_end = ORIGIN(FLASH_FS) + LENGTH(FLASH_FS);

0 commit comments

Comments
 (0)