Skip to content

Commit 711ed08

Browse files
gianstacarlescufi
authored andcommitted
debug: tracing: Add Segger RTT linker section options
Allows optionally placing Segger RTT data either in a specific linker section that is located at RAM start, or in a specific linker section defined by a memory region in DTS, as third and fourth alternative to the DTCM section or the default data section. This is useful to share the fixed address for different programs, typically bootloader and application, and have seamless logging. Signed-off-by: Giancarlo Stasi <[email protected]>
1 parent 5107320 commit 711ed08

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

modules/segger/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ if(CONFIG_USE_SEGGER_RTT)
1010
SEGGER_RTT_zephyr.c
1111
)
1212
zephyr_library_sources_ifdef(CONFIG_SEGGER_SYSTEMVIEW ${SEGGER_DIR}/SEGGER/SEGGER_SYSVIEW.c)
13+
# Using sort key AAA to ensure that we are placed at start of RAM
14+
zephyr_linker_sources_ifdef(CONFIG_SEGGER_RTT_SECTION_CUSTOM RAM_SECTIONS SORT_KEY aaa segger_rtt.ld)
1315
endif()
1416

1517
if(CONFIG_SEGGER_DEBUGMON)

modules/segger/Kconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ config SEGGER_RTT_MEMCPY_USE_BYTELOOP
7272

7373
choice SEGGER_RTT_SECTION
7474
prompt "Choose RTT data linker section"
75+
default SEGGER_RTT_SECTION_CUSTOM
7576

7677
config SEGGER_RTT_SECTION_NONE
7778
bool "Place RTT data in the default linker section"
@@ -82,6 +83,24 @@ config SEGGER_RTT_SECTION_DTCM
8283
config SEGGER_RTT_SECTION_CCM
8384
bool "Place RTT data in the CCM linker section"
8485

86+
if CPU_CORTEX_M
87+
88+
config SEGGER_RTT_SECTION_CUSTOM
89+
bool "Place RTT data in custom linker section at RAM start"
90+
91+
config SEGGER_RTT_SECTION_CUSTOM_DTS_REGION
92+
bool "Place RTT data in custom linker section defined by a memory region in DTS"
93+
94+
endif
95+
8596
endchoice
8697

98+
if SEGGER_RTT_SECTION_CUSTOM || SEGGER_RTT_SECTION_CUSTOM_DTS_REGION
99+
100+
config SEGGER_RTT_SECTION_CUSTOM_NAME
101+
string "Name of RTT data custom linker section"
102+
default ".rtt_buff_data"
103+
104+
endif
105+
87106
endif

modules/segger/segger_rtt.ld

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
SECTION_DATA_PROLOGUE(_RTT_SECTION_NAME,(NOLOAD),)
2+
{
3+
__rtt_buff_data_start = .;
4+
*(CONFIG_SEGGER_RTT_SECTION_CUSTOM_NAME)
5+
__rtt_buff_data_end = ALIGN(4);
6+
} GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
7+
__rtt_buff_data_size = __rtt_buff_data_end - __rtt_buff_data_start;

0 commit comments

Comments
 (0)