This is an automated email from the ASF dual-hosted git repository.

jiuzhudong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 81f27bd602 drivers/segger:Add config option to allow defining the 
macro as variable
81f27bd602 is described below

commit 81f27bd602c21d3cb3604227ba0b45e83f07d4b9
Author: liwenxiang1 <liwenxia...@xiaomi.com>
AuthorDate: Tue Apr 15 22:00:31 2025 +0800

    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 <liwenxia...@xiaomi.com>
---
 drivers/segger/Kconfig                  |  7 +++++++
 drivers/segger/config/SEGGER_RTT_Conf.h | 10 +++++++++-
 drivers/segger/segger.c                 |  1 +
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/segger/Kconfig b/drivers/segger/Kconfig
index cfd052cec7..35b5c4ecdc 100644
--- a/drivers/segger/Kconfig
+++ b/drivers/segger/Kconfig
@@ -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
 
diff --git a/drivers/segger/config/SEGGER_RTT_Conf.h 
b/drivers/segger/config/SEGGER_RTT_Conf.h
index 4856b0ac08..b4bc1f8d67 100644
--- a/drivers/segger/config/SEGGER_RTT_Conf.h
+++ b/drivers/segger/config/SEGGER_RTT_Conf.h
@@ -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 */
 
diff --git a/drivers/segger/segger.c b/drivers/segger/segger.c
index 7d71aa96ed..d179bccef1 100644
--- a/drivers/segger/segger.c
+++ b/drivers/segger/segger.c
@@ -31,6 +31,7 @@
  ****************************************************************************/
 
 struct rspinlock_s g_segger_lock = RSPINLOCK_INITIALIZER;
+ptrdiff_t g_segger_offset = PTRDIFF_MAX;
 
 /****************************************************************************
  * Public Functions

Reply via email to