Skip to content

Commit f05c640

Browse files
authored
Merge pull request #2552 from fpistm/fix_h7_ld
fix(h7): linker script
2 parents c43d779 + 350a546 commit f05c640

File tree

2 files changed

+17
-28
lines changed
  • variants/STM32H7xx
    • H742V(G-I)(H-T)_H743V(G-I)(H-T)_H750VBT_H753VI(H-T)
    • H742X(G-I)H_H743X(G-I)H_H745X(G-I)H_H747X(G-I)H_H750XBH_H753XIH_H755XIH_H757XIH

2 files changed

+17
-28
lines changed

Diff for: variants/STM32H7xx/H742V(G-I)(H-T)_H743V(G-I)(H-T)_H750VBT_H753VI(H-T)/ldscript.ld

+5-6
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ ENTRY(Reset_Handler)
3838
/* Highest address of the user mode stack */
3939
_estack = ORIGIN(RAM_D1) + LENGTH(RAM_D1); /* end of RAM_D1 */
4040
/* Generate a link error if heap and stack don't fit into RAM_D1 */
41-
_Min_Heap_Size = 0x200 ; /* required amount of heap */
42-
_Min_Stack_Size = 0x400 ; /* required amount of stack */
41+
_Min_Heap_Size = 0x200; /* required amount of heap */
42+
_Min_Stack_Size = 0x400; /* required amount of stack */
4343

4444
/* Specify the memory areas */
4545
MEMORY
4646
{
47-
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K
47+
FLASH (rx) : ORIGIN = 0x08000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET
4848
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
49-
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K
49+
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = LD_MAX_DATA_SIZE
5050
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
5151
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K
5252
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
@@ -117,7 +117,7 @@ SECTIONS
117117
PROVIDE_HIDDEN (__fini_array_end = .);
118118
} >FLASH
119119

120-
/* used by the startup to initialize data */
120+
/* Used by the startup to initialize data */
121121
_sidata = LOADADDR(.data);
122122

123123
/* Initialized data sections goes into RAM_D1, load LMA copy after code */
@@ -172,4 +172,3 @@ SECTIONS
172172
.ARM.attributes 0 : { *(.ARM.attributes) }
173173
}
174174

175-

Diff for: variants/STM32H7xx/H742X(G-I)H_H743X(G-I)H_H745X(G-I)H_H747X(G-I)H_H750XBH_H753XIH_H755XIH_H757XIH/ldscript.ld

+12-22
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
**
44
** File : LinkerScript.ld
55
**
6-
** Author : STM32CubeIDE & Mathieu CHOPLAIN
6+
** Author : STM32CubeIDE
77
**
88
** Abstract : Linker script for STM32H7XIHx series
99
** 2048Kbytes FLASH
1010
** 512Kbytes RAM_D1
11-
** 288Kbytes RAM_D2 (stack)
11+
** 288Kbytes RAM_D2 (unused)
1212
** 64Kbytes RAM_D3 (unused)
1313
** 128Kbytes ITCMRAM (unused)
1414
** 64Kbytes DTCMRAM (unused)
@@ -21,7 +21,7 @@
2121
**
2222
** Target : STMicroelectronics STM32
2323
**
24-
** Distribution: The file is distributed as is without any warranty
24+
** Distribution: The file is distributed as is, without any warranty
2525
** of any kind.
2626
**
2727
*****************************************************************************
@@ -42,31 +42,20 @@
4242
ENTRY(Reset_Handler)
4343

4444
/* Highest address of the user mode stack */
45-
_estack = ORIGIN(RAM_D2) + LENGTH(RAM_D2); /* Use the otherwise wasted RAM_D2 region for stack */
45+
_estack = ORIGIN(RAM_D1) + LENGTH(RAM_D1); /* end of RAM_D1 */
46+
/* Generate a link error if heap and stack don't fit into RAM_D1 */
47+
_Min_Heap_Size = 0x200; /* required amount of heap */
48+
_Min_Stack_Size = 0x400; /* required amount of stack */
4649

47-
/* Special value for CRT to prevent heap overflow into address space hole:
48-
_sbrk assumes the RAM between _end and _estack is contiguous and prevents
49-
heap overflowing into the stack by checking that the heap end pointer is
50-
never going past (_estack - _Min_Stack_Size).
51-
52-
By setting _Min_Stack_Size to this value, we ensure that _sbrk considers the
53-
end of RAM_D1 as the heap's upper limit, preventing reserved memory space from
54-
being used as heap memory improperly.
55-
*/
56-
_Min_Stack_Size = _estack - (ORIGIN(RAM_D1) + LENGTH(RAM_D1));
57-
_Min_Heap_Size = 0x200; /* required amount of heap */
58-
59-
60-
/* Memories definition */
50+
/* Specify the memory areas */
6151
MEMORY
6252
{
63-
FLASH (rx) : ORIGIN = 0x08000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET
64-
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
53+
FLASH (rx) : ORIGIN = 0x08000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET
6554
DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
6655
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = LD_MAX_DATA_SIZE
6756
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
6857
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K
69-
58+
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
7059
}
7160

7261
/* Sections */
@@ -189,7 +178,7 @@ SECTIONS
189178
PROVIDE ( end = . );
190179
PROVIDE ( _end = . );
191180
. = . + _Min_Heap_Size;
192-
/* . = . + _Min_Stack_Size; - stack is in a separate SRAM region, no need to check its size */
181+
. = . + _Min_Stack_Size;
193182
. = ALIGN(8);
194183
} >RAM_D1
195184

@@ -203,3 +192,4 @@ SECTIONS
203192

204193
.ARM.attributes 0 : { *(.ARM.attributes) }
205194
}
195+

0 commit comments

Comments
 (0)