Skip to content

Commit

Permalink
debug: tracing: Add Segger RTT linker section options
Browse files Browse the repository at this point in the history
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 <giancarlo.stasi.co@gmail.com>
  • Loading branch information
giansta authored and carlescufi committed Aug 12, 2024
1 parent 5107320 commit 711ed08
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/segger/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ if(CONFIG_USE_SEGGER_RTT)
SEGGER_RTT_zephyr.c
)
zephyr_library_sources_ifdef(CONFIG_SEGGER_SYSTEMVIEW ${SEGGER_DIR}/SEGGER/SEGGER_SYSVIEW.c)
# Using sort key AAA to ensure that we are placed at start of RAM
zephyr_linker_sources_ifdef(CONFIG_SEGGER_RTT_SECTION_CUSTOM RAM_SECTIONS SORT_KEY aaa segger_rtt.ld)
endif()

if(CONFIG_SEGGER_DEBUGMON)
Expand Down
19 changes: 19 additions & 0 deletions modules/segger/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ config SEGGER_RTT_MEMCPY_USE_BYTELOOP

choice SEGGER_RTT_SECTION
prompt "Choose RTT data linker section"
default SEGGER_RTT_SECTION_CUSTOM

config SEGGER_RTT_SECTION_NONE
bool "Place RTT data in the default linker section"
Expand All @@ -82,6 +83,24 @@ config SEGGER_RTT_SECTION_DTCM
config SEGGER_RTT_SECTION_CCM
bool "Place RTT data in the CCM linker section"

if CPU_CORTEX_M

config SEGGER_RTT_SECTION_CUSTOM
bool "Place RTT data in custom linker section at RAM start"

config SEGGER_RTT_SECTION_CUSTOM_DTS_REGION
bool "Place RTT data in custom linker section defined by a memory region in DTS"

endif

endchoice

if SEGGER_RTT_SECTION_CUSTOM || SEGGER_RTT_SECTION_CUSTOM_DTS_REGION

config SEGGER_RTT_SECTION_CUSTOM_NAME
string "Name of RTT data custom linker section"
default ".rtt_buff_data"

endif

endif
7 changes: 7 additions & 0 deletions modules/segger/segger_rtt.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SECTION_DATA_PROLOGUE(_RTT_SECTION_NAME,(NOLOAD),)
{
__rtt_buff_data_start = .;
*(CONFIG_SEGGER_RTT_SECTION_CUSTOM_NAME)
__rtt_buff_data_end = ALIGN(4);
} GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
__rtt_buff_data_size = __rtt_buff_data_end - __rtt_buff_data_start;

0 comments on commit 711ed08

Please sign in to comment.