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

GUIDINGLI 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 3707c0e62a1 note: add t32fdx driver
3707c0e62a1 is described below

commit 3707c0e62a123cbb663ff87b09348741291448fa
Author: yinshengkai <[email protected]>
AuthorDate: Mon Jul 14 20:53:52 2025 +0800

    note: add t32fdx driver
    
    Add a Trace32 FDX (Fast Data Exchange) note driver that sends
    NuttX scheduler instrumentation data to a Lauterbach debugger
    via the FDX protocol.  Includes the CMM script and nxstyle
    whitelist entries for the T32 FDX API symbols.
    
    Signed-off-by: yinshengkai <[email protected]>
---
 drivers/CMakeLists.txt               |   4 +-
 drivers/Kconfig                      |   1 +
 drivers/Makefile                     |   1 +
 drivers/note/note_initialize.c       |  10 +++
 drivers/trace32/.gitignore           |   1 +
 drivers/{ => trace32}/CMakeLists.txt |  19 +++--
 drivers/trace32/Kconfig              |  46 +++++++++++
 drivers/trace32/Make.defs            |  34 ++++++++
 drivers/trace32/note_fdx.c           | 154 +++++++++++++++++++++++++++++++++++
 drivers/trace32/t32fdx.cmm           |  65 +++++++++++++++
 include/nuttx/trace32/note_fdx.h     |  54 ++++++++++++
 tools/nxstyle.c                      |  18 ++++
 12 files changed, 396 insertions(+), 11 deletions(-)

diff --git a/drivers/CMakeLists.txt b/drivers/CMakeLists.txt
index be748762576..22fecc00077 100644
--- a/drivers/CMakeLists.txt
+++ b/drivers/CMakeLists.txt
@@ -26,7 +26,7 @@ nuttx_add_kernel_library(drivers)
 # included automatically.
 nuttx_add_subdirectory()
 
-# The TEE driver is discovered through its own CMakeLists.txt. The SENT driver
-# is discovered through its own CMakeLists.txt.
+# The TEE, SENT and Trace32 drivers are discovered through their own
+# CMakeLists.txt.
 target_sources(drivers PRIVATE drivers_initialize.c)
 target_include_directories(drivers PRIVATE ${CMAKE_CURRENT_LIST_DIR})
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 64013e33c31..17060df09d9 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -90,3 +90,4 @@ source "drivers/coresight/Kconfig"
 source "drivers/aie/Kconfig"
 source "drivers/tee/Kconfig"
 source "drivers/sent/Kconfig"
+source "drivers/trace32/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index fef955b4358..6e36faab152 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -89,6 +89,7 @@ include pci/Make.defs
 include coresight/Make.defs
 include aie/Make.defs
 include tee/Make.defs
+include trace32/Make.defs
 
 ifeq ($(CONFIG_SPECIFIC_DRIVERS),y)
 -include platform/Make.defs
diff --git a/drivers/note/note_initialize.c b/drivers/note/note_initialize.c
index 77146eb12a0..61b5d38b98b 100644
--- a/drivers/note/note_initialize.c
+++ b/drivers/note/note_initialize.c
@@ -33,6 +33,7 @@
 #include <nuttx/note/notesnap_driver.h>
 #include <nuttx/note/notestream_driver.h>
 #include <nuttx/rtt.h>
+#include <nuttx/trace32/note_fdx.h>
 
 #include "noterpmsg.h"
 
@@ -202,5 +203,14 @@ int note_initialize(void)
     }
 #endif
 
+#ifdef CONFIG_TRACE32_FDX_NOTE
+  ret = notefdx_register();
+  if (ret < 0)
+    {
+      serr("notefdx_register failed %d\n", ret);
+      return ret;
+    }
+#endif
+
   return ret;
 }
diff --git a/drivers/trace32/.gitignore b/drivers/trace32/.gitignore
new file mode 100644
index 00000000000..76280e1ac13
--- /dev/null
+++ b/drivers/trace32/.gitignore
@@ -0,0 +1 @@
+/t32fdx
diff --git a/drivers/CMakeLists.txt b/drivers/trace32/CMakeLists.txt
similarity index 69%
copy from drivers/CMakeLists.txt
copy to drivers/trace32/CMakeLists.txt
index be748762576..42f0912baa6 100644
--- a/drivers/CMakeLists.txt
+++ b/drivers/trace32/CMakeLists.txt
@@ -1,5 +1,5 @@
 # 
##############################################################################
-# drivers/CMakeLists.txt
+# drivers/segger/CMakeLists.txt
 #
 # SPDX-License-Identifier: Apache-2.0
 #
@@ -20,13 +20,14 @@
 #
 # 
##############################################################################
 
-nuttx_add_kernel_library(drivers)
+if(CONFIG_TRACE32_FDX)
+  nuttx_add_kernel_library(trace32)
 
-# Subdirectories that provide their own CMakeLists.txt (for example dma-buf) 
are
-# included automatically.
-nuttx_add_subdirectory()
+  set(CSRCS ${CMAKE_CURRENT_LIST_DIR}/t32fdx/t32fdx.c)
 
-# The TEE driver is discovered through its own CMakeLists.txt. The SENT driver
-# is discovered through its own CMakeLists.txt.
-target_sources(drivers PRIVATE drivers_initialize.c)
-target_include_directories(drivers PRIVATE ${CMAKE_CURRENT_LIST_DIR})
+  if(CONFIG_TRACE32_FDX_NOTE)
+    list(APPEND CSRCS ${CMAKE_CURRENT_LIST_DIR}/note_fdx.c)
+  endif()
+
+  target_sources(trace32 PRIVATE ${CSRCS})
+endif()
diff --git a/drivers/trace32/Kconfig b/drivers/trace32/Kconfig
new file mode 100644
index 00000000000..6137073e827
--- /dev/null
+++ b/drivers/trace32/Kconfig
@@ -0,0 +1,46 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+menu "Trace32 drivers"
+
+config TRACE32_FDX
+       bool
+       default n
+       ---help---
+               The Trace32 FDX driver.
+
+config TRACE32_FDX_NOTE
+       bool "Trace32 FDX Note driver"
+       select DRIVERS_NOTE
+       select TRACE32_FDX
+       default n
+       ---help---
+               The Note driver output to trace32 FDX.
+
+if TRACE32_FDX_NOTE
+
+config TRACE32_FDX_NOTE_FILTER_DEFAULT_MODE
+       hex "Trace32 FDX Note driver filter mode"
+       depends on SCHED_INSTRUMENTATION_FILTER
+       default SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE
+       ---help---
+               Filter mode for notefdx
+
+config TRACE32_FDX_NOTE_BUFSIZE
+       int "Trace32 FDX Note driver buffer size"
+       default 1024
+       ---help---
+               The size of the FDX buffer (in bytes).
+
+config TRACE32_FDX_NOTE_CPUSET
+       hex "Trace32 FDX Note driver CPU set"
+       depends on SMP && SCHED_INSTRUMENTATION_FILTER
+       default SCHED_INSTRUMENTATION_CPUSET
+       ---help---
+               CPU set for notefdx
+
+endif # TRACE32_FDX_NOTE
+
+endmenu # Trace32 drivers
diff --git a/drivers/trace32/Make.defs b/drivers/trace32/Make.defs
new file mode 100644
index 00000000000..363cb160195
--- /dev/null
+++ b/drivers/trace32/Make.defs
@@ -0,0 +1,34 @@
+############################################################################
+# drivers/segger/Make.defs
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+ifeq ($(CONFIG_TRACE32_FDX),y)
+  CSRCS += t32fdx.c
+  DEPPATH += --dep-path trace32/t32fdx
+  VPATH += :trace32/t32fdx
+endif
+
+ifeq ($(CONFIG_TRACE32_FDX_NOTE),y)
+  CSRCS += note_fdx.c
+endif
+
+DEPPATH += --dep-path trace32
+VPATH += :trace32
diff --git a/drivers/trace32/note_fdx.c b/drivers/trace32/note_fdx.c
new file mode 100644
index 00000000000..116a7b7460a
--- /dev/null
+++ b/drivers/trace32/note_fdx.c
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * drivers/trace32/note_fdx.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/note/note_driver.h>
+#include <nuttx/spinlock.h>
+
+#include "t32fdx/t32fdx.h"
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct notefdx_s
+{
+  struct note_driver_s driver;
+  FAR void *channel;
+  spinlock_t lock;
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static void notefdx_add(FAR struct note_driver_s *drv,
+                        FAR const void *note, size_t len);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+T32_Fdx_DefineChannel(g_fdx_note_buffer, CONFIG_TRACE32_FDX_NOTE_BUFSIZE);
+
+static const struct note_driver_ops_s g_notefdx_ops =
+{
+  notefdx_add,
+};
+
+struct notefdx_s g_notefdx =
+{
+  {
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+    "fdx",
+    {
+      {
+        CONFIG_TRACE32_FDX_NOTE_FILTER_DEFAULT_MODE,
+#  ifdef CONFIG_SMP
+        CONFIG_TRACE32_FDX_NOTE_CPUSET
+#  endif
+      },
+    },
+#endif
+    &g_notefdx_ops
+  },
+  NULL,
+  SP_UNLOCKED
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: notefdx_add
+ *
+ * Description:
+ *   Put the variable length note to fdx
+ *
+ * Input Parameters:
+ *   buf    - The note buffer
+ *   notelen - The buffer length
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+static void notefdx_add(FAR struct note_driver_s *drv,
+                        FAR const void *buf, size_t notelen)
+{
+  FAR struct notefdx_s *note = (FAR struct notefdx_s *)drv;
+
+  if (note->channel != NULL)
+    {
+      irqstate_t flags = spin_lock_irqsave(&note->lock);
+
+      T32_Fdx_SendPoll(note->channel, (FAR void *)buf, notelen);
+      spin_unlock_irqrestore(&note->lock, flags);
+    }
+}
+
+/****************************************************************************
+ * Name: notefdx_register
+ *
+ * Description:
+ *   Register a trace32 fdx driver using note_driver_register
+ *
+ * Input Parameters:
+ *   None.
+ *
+ * Returned Value:
+ *   Zero on succress. A negated errno value is returned on a failure.
+ *
+ ****************************************************************************/
+
+int notefdx_register(void)
+{
+  T32_Fdx_InitChannel(g_fdx_note_buffer);
+  T32_Fdx_EnableChannel(g_fdx_note_buffer);
+  g_notefdx.channel = &g_fdx_note_buffer;
+  return note_driver_register(&g_notefdx.driver);
+}
+
+/****************************************************************************
+ * Name: T32_Fdx_GetTimebase
+ *
+ * Description:
+ *   Get the timebase for the FDX driver
+ *
+ * Returned Value:
+ *   The timebase for the FDX driver
+ *
+ * Note:
+ *   This function is used to get the timebase for the FDX driver.
+ *   It is called by t32fdx.c
+ *
+ ****************************************************************************/
+
+unsigned long T32_Fdx_GetTimebase(void)
+{
+  return perf_gettime();
+}
diff --git a/drivers/trace32/t32fdx.cmm b/drivers/trace32/t32fdx.cmm
new file mode 100644
index 00000000000..669244f790d
--- /dev/null
+++ b/drivers/trace32/t32fdx.cmm
@@ -0,0 +1,65 @@
+;=========================================================================
+; drivers/trace32/t32fdx.cmm
+;
+; SPDX-License-Identifier: Apache-2.0
+;
+; Licensed to the Apache Software Foundation (ASF) under one or more
+; contributor license agreements.  See the NOTICE file distributed with
+; this work for additional information regarding copyright ownership.  The
+; ASF licenses this file to you under the Apache License, Version 2.0 (the
+; "License"); you may not use this file except in compliance with the
+; License.  You may obtain a copy of the License at
+;
+;   http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+; License for the specific language governing permissions and limitations
+; under the License.
+;
+;=========================================================================
+
+; Usage:
+; 1. Load elf in trace32 software, Data.LOAD.Elf /path/to/your.elf
+; 2. Run the script, "CD.DO /path/to/fdx.cmm"
+; 3. The trace data will be saved to trace.bin
+;
+
+; Check if ELF file is loaded, exit if not
+If !Symbol.Exist("g_fdx_note_buffer")
+(
+    Printf "ERROR: No ELF file loaded! Please load ELF file."
+    Enddo
+)
+
+System.Attach
+
+; Check if the system is running, if not, execute Go
+If !State.Run()
+(
+    Go
+)
+
+; Set the JTAG clock to 100MHz, transfer rate is related to clock frequency
+System.JtagClock 100MHZ
+
+Fdx.Outchannel g_fdx_note_buffer
+
+Fdx.Address g_fdx_note_buffer
+
+Fdx.DisableChannel g_fdx_note_buffer
+
+Fdx.Clear
+
+Fdx.Mode FIFO
+
+Fdx.EnableChannel
+
+; Wait for a while and discard the old data in the fdx buffer
+Wait 10ms
+
+Printf "FDX record start..."
+
+; Write the trace data to trace.bin
+Fdx.Write g_fdx_note_buffer trace.bin
diff --git a/include/nuttx/trace32/note_fdx.h b/include/nuttx/trace32/note_fdx.h
new file mode 100644
index 00000000000..4102549c8a9
--- /dev/null
+++ b/include/nuttx/trace32/note_fdx.h
@@ -0,0 +1,54 @@
+/****************************************************************************
+ * include/nuttx/trace32/note_fdx.h
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_NUTTX_TRACE32_NOTE_FDX_H
+#define __INCLUDE_NUTTX_TRACE32_NOTE_FDX_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: notefdx_register
+ *
+ * Description:
+ *   Register a trace32 fdx driver using note_driver_register
+ *
+ * Input Parameters:
+ *   None.
+ *
+ * Returned Value:
+ *   Zero on succress. A negated errno value is returned on a failure.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_TRACE32_FDX_NOTE
+int notefdx_register(void);
+#endif
+
+#endif /* __INCLUDE_NUTTX_TRACE32_NOTE_FDX_H */
diff --git a/tools/nxstyle.c b/tools/nxstyle.c
index 17a683e4d5b..2d31d7fff73 100644
--- a/tools/nxstyle.c
+++ b/tools/nxstyle.c
@@ -850,6 +850,24 @@ static const char *g_white_content_list[] =
   "buildVersion",
   "logSystem",
 
+  /* Ref:
+   * drivers/trace32/t32fdx/t32fdx.c
+   */
+
+  "T32_Fdx_DefineChannel",
+  "T32_Fdx_InitChannel",
+  "T32_Fdx_EnableChannel",
+  "T32_Fdx_SendPoll",
+  "T32_Fdx_Send",
+  "T32_Fdx_ReceivePoll",
+  "T32_Fdx_Receive",
+  "T32_Fdx_Poll",
+  "T32_Fdx_PollInterrupt",
+  "T32_Fdx_TraceInit",
+  "T32_Fdx_TraceData",
+  "T32_Fdx_TraceData2",
+  "T32_Fdx_GetTimebase",
+
   NULL
 };
 

Reply via email to