drivers/segger:Add config option to allow defining the macro as variable

we are using segger RTT protocol over shared memory for two core log/trace: one is NuttX another Linux/Windows. But the base address of shared memory can only be known at runtime, so we change SEGGER_RTT_UNCACHED_OFF from macro to global variable, and update to the correct g_segger_offset after the shared memory is initialized by:
g_segger_offset = (uintptr_t)ishmem - (uintptr_t)&_SEGGER_RTT;

Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
This commit is contained in:
liwenxiang1
2025-04-15 22:00:31 +08:00
committed by Donny(董九柱)
parent b0904e7c39
commit 81f27bd602
3 changed files with 17 additions and 1 deletions
+7
View File
@@ -33,9 +33,16 @@ config SEGGER_RTT_CPU_CACHE_LINE_SIZE
---help---
Largest cache line size (in bytes) in the target system.
config SEGGER_RTT_UNCACHED_OFF_VARIABLE
bool
default n
---help---
Converting the macro for Segger RTT uncached offset to variable representation
config SEGGER_RTT_UNCACHED_OFF
int "Segger RTT uncached offset"
default 0
depends on !SEGGER_RTT_UNCACHED_OFF_VARIABLE
---help---
Address alias where RTT CB and buffers can be accessed uncached
+9 -1
View File
@@ -41,6 +41,10 @@
extern struct rspinlock_s g_segger_lock;
#endif
#ifdef CONFIG_SEGGER_RTT_UNCACHED_OFF_VARIABLE
extern ptrdiff_t g_segger_offset;
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -53,7 +57,11 @@ extern struct rspinlock_s g_segger_lock;
/* Address alias where RTT CB and buffers can be accessed uncached */
#define SEGGER_RTT_UNCACHED_OFF CONFIG_SEGGER_RTT_UNCACHED_OFF
#ifdef CONFIG_SEGGER_RTT_UNCACHED_OFF_VARIABLE
# define SEGGER_RTT_UNCACHED_OFF g_segger_offset
#else
# define SEGGER_RTT_UNCACHED_OFF CONFIG_SEGGER_RTT_UNCACHED_OFF
#endif
/* Number of up-buffers (T->H) available on this target */
+1
View File
@@ -31,6 +31,7 @@
****************************************************************************/
struct rspinlock_s g_segger_lock = RSPINLOCK_INITIALIZER;
ptrdiff_t g_segger_offset = PTRDIFF_MAX;
/****************************************************************************
* Public Functions