Skip to content

Commit ba46e16

Browse files
committed
hw/h7rs: Update linker to put RTT in DTCM
Signed-off-by: HiFiPhile <[email protected]>
1 parent 7817831 commit ba46e16

File tree

6 files changed

+25
-27
lines changed

6 files changed

+25
-27
lines changed

hw/bsp/stm32h7rs/boards/stm32h7s3nucleo/board.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
set(MCU_VARIANT stm32h7s3xx)
22
set(JLINK_DEVICE stm32h7s3xx)
33

4-
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/stm32h7s3xx_flash.ld)
54
set(LD_FILE_Clang ${LD_FILE_GNU})
6-
set(LD_FILE_IAR ${CMAKE_CURRENT_LIST_DIR}/stm32h7s3xx_flash.icf)
75

86
function(update_board TARGET)
97
target_compile_definitions(${TARGET} PUBLIC

hw/bsp/stm32h7rs/boards/stm32h7s3nucleo/board.mk

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ JLINK_DEVICE = stm32h7s3xx
77
# flash target using on-board stlink
88
flash: flash-stlink
99

10-
# Linker
11-
LD_FILE_GCC = $(BOARD_PATH)/stm32h7s3xx_flash.ld
12-
LD_FILE_IAR = $(BOARD_PATH)/stm32h7s3xx_flash.icf
13-
1410
SRC_C += \
1511
$(ST_TCPP0203)/tcpp0203.c \
1612
$(ST_TCPP0203)/tcpp0203_reg.c \

hw/bsp/stm32h7rs/family.cmake

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ function(add_board_target BOARD_TARGET)
5454
set(STARTUP_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/startup_${MCU_VARIANT}.s)
5555

5656
if(NOT DEFINED LD_FILE_GNU)
57-
set(LD_FILE_GNU ${ST_CMSIS}/Source/Templates/gcc/linker/${MCU_VARIANT}_flash.ld)
57+
set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/${MCU_VARIANT}_flash.ld)
5858
endif()
5959
set(LD_FILE_Clang ${LD_FILE_GNU})
6060
if(NOT DEFINED LD_FILE_IAR)
61-
set(LD_FILE_IAR ${ST_CMSIS}/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf)
61+
set(LD_FILE_IAR ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/${MCU_VARIANT}_flash.icf)
6262
endif()
6363

6464
add_library(${BOARD_TARGET} STATIC
@@ -87,8 +87,7 @@ function(add_board_target BOARD_TARGET)
8787
BOARD_TUD_MAX_SPEED=${RHPORT_DEVICE_SPEED}
8888
BOARD_TUH_RHPORT=${RHPORT_HOST}
8989
BOARD_TUH_MAX_SPEED=${RHPORT_HOST_SPEED}
90-
SEGGER_RTT_SECTION="noncacheable_buffer"
91-
BUFFER_SIZE_UP=0x3000
90+
SEGGER_RTT_SECTION=\"dtcm_data\"
9291
)
9392

9493
update_board(${BOARD_TARGET})

hw/bsp/stm32h7rs/family.mk

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ CFLAGS += \
4343
-DBOARD_TUD_MAX_SPEED=${RHPORT_DEVICE_SPEED} \
4444
-DBOARD_TUH_RHPORT=${RHPORT_HOST} \
4545
-DBOARD_TUH_MAX_SPEED=${RHPORT_HOST_SPEED} \
46-
-DSEGGER_RTT_SECTION=\"noncacheable_buffer\" \
47-
-DBUFFER_SIZE_UP=0x3000 \
46+
-DSEGGER_RTT_SECTION="dtcm_data" \
4847

4948
# GCC Flags
5049
CFLAGS_GCC += \
@@ -91,5 +90,5 @@ SRC_S_GCC += $(ST_CMSIS)/Source/Templates/gcc/startup_$(MCU_VARIANT).s
9190
SRC_S_IAR += $(ST_CMSIS)/Source/Templates/iar/startup_$(MCU_VARIANT).s
9291

9392
# Linker
94-
LD_FILE_GCC ?= $(ST_CMSIS)/Source/Templates/gcc/linker/$(MCU_VARIANT)_flash.ld
95-
LD_FILE_IAR ?= $(ST_CMSIS)/Source/Templates/iar/linker/$(MCU_VARIANT)_flash.icf
93+
LD_FILE_GCC ?= $(FAMILY_PATH)/linker/$(MCU_VARIANT)_flash.ld
94+
LD_FILE_IAR ?= $(FAMILY_PATH)/linker/$(MCU_VARIANT)_flash.icf

hw/bsp/stm32h7rs/boards/stm32h7s3nucleo/stm32h7s3xx_flash.icf renamed to hw/bsp/stm32h7rs/linker/stm32h7s3xx_flash.icf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/*-Specials-*/
55
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
66
/*-Memory Regions-*/
7-
define symbol NONCACHEABLEBUFFER_size = 0x4000;
7+
define symbol NONCACHEABLEBUFFER_size = 0x400;
88
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;
99
define symbol __ICFEDIT_region_ROM_end__ = 0x0800FFFF;
1010
define symbol __ICFEDIT_region_RAM_start__ = 0x24000000;
@@ -14,7 +14,7 @@ define symbol NONCACHEABLEBUFFER_end = __ICFEDIT_region_RAM_end__ + NONCAC
1414

1515

1616
/*-Sizes-*/
17-
define symbol __ICFEDIT_size_cstack__ = 0x800;
17+
define symbol __ICFEDIT_size_cstack__ = 0x400;
1818
define symbol __ICFEDIT_size_heap__ = 0x200;
1919
/**** End of ICF editor section. ###ICF###*/
2020

@@ -51,5 +51,5 @@ place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
5151

5252
place in ROM_region { readonly };
5353
place in RAM_region { readwrite };
54+
place in DTCM_region { block CSTACK, block HEAP, section dtcm_data };
5455
place in NONCACHEABLE_region { section noncacheable_buffer };
55-
place in DTCM_region { block CSTACK, block HEAP };

hw/bsp/stm32h7rs/boards/stm32h7s3nucleo/stm32h7s3xx_flash.ld renamed to hw/bsp/stm32h7rs/linker/stm32h7s3xx_flash.ld

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,19 @@
3535
/* Entry Point */
3636
ENTRY(Reset_Handler)
3737

38+
/* Highest address of the user mode stack */
39+
_estack = ORIGIN(DTCM) + LENGTH(DTCM); /* end of "DTCM" Ram type memory */
40+
3841
_Min_Heap_Size = 0x200; /* required amount of heap */
3942
_Min_Stack_Size = 0x400; /* required amount of stack */
4043

4144
__FLASH_BEGIN = 0x08000000;
4245
__FLASH_SIZE = 0x00010000;
4346

47+
4448
__RAM_BEGIN = 0x24000000;
4549
__RAM_SIZE = 0x4FC00;
46-
__RAM_NONCACHEABLEBUFFER_SIZE = 0x4000;
50+
__RAM_NONCACHEABLEBUFFER_SIZE = 0x400;
4751

4852
/* Memories definition */
4953
MEMORY
@@ -59,9 +63,6 @@ MEMORY
5963
FLASH (xrw) : ORIGIN = __FLASH_BEGIN, LENGTH = __FLASH_SIZE
6064
}
6165

62-
/* Highest address of the user mode stack */
63-
_estack = ORIGIN(DTCM) + LENGTH(DTCM); /* end of "DTCM" Ram type memory */
64-
6566
/* Sections */
6667
SECTIONS
6768
{
@@ -99,14 +100,14 @@ SECTIONS
99100
. = ALIGN(4);
100101
} >FLASH
101102

102-
.ARM.extab :
103+
.ARM.extab (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
103104
{
104105
. = ALIGN(4);
105106
*(.ARM.extab* .gnu.linkonce.armextab.*)
106107
. = ALIGN(4);
107108
} >FLASH
108109

109-
.ARM :
110+
.ARM (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
110111
{
111112
. = ALIGN(4);
112113
__exidx_start = .;
@@ -115,7 +116,7 @@ SECTIONS
115116
. = ALIGN(4);
116117
} >FLASH
117118

118-
.preinit_array :
119+
.preinit_array (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
119120
{
120121
. = ALIGN(4);
121122
PROVIDE_HIDDEN (__preinit_array_start = .);
@@ -124,7 +125,7 @@ SECTIONS
124125
. = ALIGN(4);
125126
} >FLASH
126127

127-
.init_array :
128+
.init_array (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
128129
{
129130
. = ALIGN(4);
130131
PROVIDE_HIDDEN (__init_array_start = .);
@@ -134,7 +135,7 @@ SECTIONS
134135
. = ALIGN(4);
135136
} >FLASH
136137

137-
.fini_array :
138+
.fini_array (READONLY) : /* The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
138139
{
139140
. = ALIGN(4);
140141
PROVIDE_HIDDEN (__fini_array_start = .);
@@ -182,7 +183,7 @@ SECTIONS
182183
{
183184
__NONCACHEABLEBUFFER_BEGIN = .;/* create symbol for start of section */
184185
KEEP(*(noncacheable_buffer))
185-
__NONCACHEABLEBUFFER_END = .; /* create symbol for start of section */
186+
__NONCACHEABLEBUFFER_END = .; /* create symbol for end of section */
186187
} > RAM_NONCACHEABLEBUFFER
187188

188189
/* User_heap_stack section, used to check that there is enough "DTCM" Ram type memory left */
@@ -196,6 +197,11 @@ SECTIONS
196197
. = ALIGN(8);
197198
} >DTCM
198199

200+
.dtcm_data :
201+
{
202+
*(dtcm_data)
203+
} >DTCM
204+
199205
/* Remove information from the compiler libraries */
200206
/DISCARD/ :
201207
{

0 commit comments

Comments
 (0)