Skip to content

Commit 81f27bd

Browse files
xianglycDonny9
authored andcommitted
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>
1 parent b0904e7 commit 81f27bd

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

drivers/segger/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,16 @@ config SEGGER_RTT_CPU_CACHE_LINE_SIZE
3333
---help---
3434
Largest cache line size (in bytes) in the target system.
3535

36+
config SEGGER_RTT_UNCACHED_OFF_VARIABLE
37+
bool
38+
default n
39+
---help---
40+
Converting the macro for Segger RTT uncached offset to variable representation
41+
3642
config SEGGER_RTT_UNCACHED_OFF
3743
int "Segger RTT uncached offset"
3844
default 0
45+
depends on !SEGGER_RTT_UNCACHED_OFF_VARIABLE
3946
---help---
4047
Address alias where RTT CB and buffers can be accessed uncached
4148

drivers/segger/config/SEGGER_RTT_Conf.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
extern struct rspinlock_s g_segger_lock;
4242
#endif
4343

44+
#ifdef CONFIG_SEGGER_RTT_UNCACHED_OFF_VARIABLE
45+
extern ptrdiff_t g_segger_offset;
46+
#endif
47+
4448
/****************************************************************************
4549
* Pre-processor Definitions
4650
****************************************************************************/
@@ -53,7 +57,11 @@ extern struct rspinlock_s g_segger_lock;
5357

5458
/* Address alias where RTT CB and buffers can be accessed uncached */
5559

56-
#define SEGGER_RTT_UNCACHED_OFF CONFIG_SEGGER_RTT_UNCACHED_OFF
60+
#ifdef CONFIG_SEGGER_RTT_UNCACHED_OFF_VARIABLE
61+
# define SEGGER_RTT_UNCACHED_OFF g_segger_offset
62+
#else
63+
# define SEGGER_RTT_UNCACHED_OFF CONFIG_SEGGER_RTT_UNCACHED_OFF
64+
#endif
5765

5866
/* Number of up-buffers (T->H) available on this target */
5967

drivers/segger/segger.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
****************************************************************************/
3232

3333
struct rspinlock_s g_segger_lock = RSPINLOCK_INITIALIZER;
34+
ptrdiff_t g_segger_offset = PTRDIFF_MAX;
3435

3536
/****************************************************************************
3637
* Public Functions

0 commit comments

Comments
 (0)