Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug: tracing: Add Segger RTT linker section options #53569

Merged
merged 3 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions drivers/console/rtt_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ static int rtt_console_out(int character)
int max_cnt = CONFIG_RTT_TX_RETRY_CNT;

do {
SEGGER_RTT_LOCK();
cnt = SEGGER_RTT_WriteNoLock(0, &c, 1);
SEGGER_RTT_UNLOCK();
cnt = SEGGER_RTT_Write(0, &c, 1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For another PR but could we make the channel configurable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even simple, I agree to do it in another PR :-)


/* There are two possible reasons for not writing any data to
* RTT:
Expand Down
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
38 changes: 38 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,43 @@ 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"
ithinuel marked this conversation as resolved.
Show resolved Hide resolved

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

choice SEGGER_RTT_INIT_MODE
prompt "RTT Initialization mode"
help
RTT inizialization function can avoid re-init of Cntrol Block
if another program (e.g. bootloader) has already initialized it.
default SEGGER_RTT_INIT_MODE_STRONG_CHECK if SEGGER_RTT_SECTION_CUSTOM
default SEGGER_RTT_INIT_MODE_STRONG_CHECK

config SEGGER_RTT_INIT_MODE_ALWAYS
bool "RTT Initialization done without conditions"

config SEGGER_RTT_INIT_MODE_STRONG_CHECK
bool "RTT Initialization done if full check on Control Block ID fails"

config SEGGER_RTT_INIT_MODE_WEAK_CHECK
bool "RTT Initialization done if partial check on Control Block ID fails"

endchoice

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;
Loading