You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/01/24 16:06:15 UTC

[GitHub] [incubator-nuttx] anchao opened a new pull request #5327: note/sysview: add Segger System View support

anchao opened a new pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327


   ## Summary
   
   sim/sysview: add build config of Segger System View
   segger/RTT: hotfix for RTT compile warning
   drivers/segger: download the RTT/SystemView from github
   note/sysview: add Segger System View support
   tools/nxstyle: add Segger System View prototype name into white list
   sched/critmonitor: remove the assertion if counter == 0
   timers/critmon: mark the weak reference for up_critmon_*
   
   Reference:
   https://www.segger.com/products/development-tools/systemview/
   https://github.com/SEGGERMicro/SystemView
   https://github.com/SEGGERMicro/RTT
   
   
   ## Impact
   
   N/A, new feature
   
   ## Testing
   
   Test on Cortex-m55:
   
   https://www.segger.com/downloads/systemview/
   
   ![Screenshot from 2022-01-25 00-02-19](https://user-images.githubusercontent.com/758493/150819122-2eeb3cad-f89e-441e-8734-05c6ec38b8cb.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] acassis commented on pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
acassis commented on pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327#issuecomment-1021158119


   Thank you @anchao I just saw you closed this PR, did you find some issue? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327#discussion_r794229680



##########
File path: drivers/segger/Make.defs
##########
@@ -38,4 +51,21 @@ ifeq ($(CONFIG_SEGGER_SYSVIEW),y)
   CFLAGS += ${shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)sched}
   CFLAGS += ${shell $(INCDIR) "$(CC)" segger$(DELIM)SystemView$(DELIM)SEGGER}
   CFLAGS += ${shell $(INCDIR) "$(CC)" segger$(DELIM)SystemView$(DELIM)SYSVIEW}
+
+  SYSVIEW_VERSION ?= 3.30

Review comment:
       remove  the space




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] a-lunev commented on a change in pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
a-lunev commented on a change in pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327#discussion_r794465362



##########
File path: tools/nxstyle.c
##########
@@ -307,6 +307,17 @@ static const char *g_white_list[] =
   "__asan_loadN_noabort",
   "__asan_storeN_noabort",
 
+  /* Ref:
+   * drivers/segger/note_sysview.c

Review comment:
       To follow alphabetical order of the path name I would place this block before:
   ```
   * Ref:
   * fs/nfs/rpc.h
   ```

##########
File path: drivers/segger/config/Global.h
##########
@@ -0,0 +1,45 @@
+/****************************************************************************
+ * drivers/segger/config/Global.h

Review comment:
       I think it'd better to lower case the file name (Global.h -> global.h) as almost all NuttX file names are lower case.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] anchao commented on a change in pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
anchao commented on a change in pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327#discussion_r794635014



##########
File path: drivers/segger/config/SEGGER_SYSVIEW_Conf.h
##########
@@ -0,0 +1,63 @@
+/****************************************************************************
+ * drivers/segger/config/SEGGER_SYSVIEW_Conf.h
+ *
+ * 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 __DRIVERS_SEGGER_CONFIG_SEGGER_SYSVIEW_CONF_H
+#define __DRIVERS_SEGGER_CONFIG_SEGGER_SYSVIEW_CONF_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+extern unsigned int sysview_get_interrupt_id(void);
+extern unsigned int sysview_get_cycle_counter(void);
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Function macro to retrieve the Id of the currently active interrupt.
+ * Call user-supplied function SEGGER_SYSVIEW_X_GetInterruptId().
+ */
+
+#define SEGGER_SYSVIEW_GET_INTERRUPT_ID    sysview_get_interrupt_id
+
+/* Function macro to retrieve a system timestamp for SYSVIEW events.
+ * Call user-supplied function SEGGER_SYSVIEW_X_GetTimestamp().
+ */
+
+#define SEGGER_SYSVIEW_GET_TIMESTAMP       sysview_get_cycle_counter
+
+/* Number of bytes that SystemView uses for the RTT buffer. */
+
+#define SEGGER_SYSVIEW_RTT_BUFFER_SIZE     CONFIG_SEGGER_SYSVIEW_RTT_BUFFER_SIZE
+
+/* Largest cache line size (in bytes) in the target system. */
+
+#define SEGGER_SYSVIEW_CPU_CACHE_LINE_SIZE CONFIG_SEGGER_RTT_CPU_CACHE_LINE_SIZE
+
+/* Enable calling SEGGER_SYSVIEW_Start() after initialization. */
+
+#ifdef CONFIG_SEGGER_SYSVIEW_START_ON_INIT
+  #define SEGGER_SYSVIEW_START_ON_INIT     1

Review comment:
       done

##########
File path: drivers/segger/note_sysview.c
##########
@@ -0,0 +1,553 @@
+/****************************************************************************
+ * drivers/segger/note_sysview.c
+ *
+ * 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/config.h>
+#include <syslog.h>
+#include <syscall.h>
+
+#include <nuttx/clock.h>
+#include <nuttx/sched.h>
+#include <nuttx/sched_note.h>
+
+#include <SEGGER_RTT.h>
+#include <SEGGER_SYSVIEW.h>
+
+#include "sched/sched.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifndef CONFIG_SMP_NCPUS
+#define CONFIG_SMP_NCPUS 1
+#endif

Review comment:
       done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] anchao commented on a change in pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
anchao commented on a change in pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327#discussion_r795019649



##########
File path: drivers/segger/note_sysview.c
##########
@@ -0,0 +1,553 @@
+/****************************************************************************
+ * drivers/segger/note_sysview.c
+ *
+ * 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/config.h>
+#include <syslog.h>
+#include <syscall.h>
+
+#include <nuttx/clock.h>
+#include <nuttx/sched.h>
+#include <nuttx/sched_note.h>
+
+#include <SEGGER_RTT.h>
+#include <SEGGER_SYSVIEW.h>
+
+#include "sched/sched.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifndef CONFIG_SMP_NCPUS
+#define CONFIG_SMP_NCPUS 1
+#endif
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct sysview_cpu_s
+{
+  FAR struct tcb_s *tcb;
+  unsigned int      irq;
+  bool              in_isrcb;
+};
+
+struct sysview_s
+{
+  struct sysview_cpu_s      scpu[CONFIG_SMP_NCPUS];
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  struct note_filter_mode_s mode;
+#endif
+#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
+  struct note_filter_irq_s  irq_mask;
+#endif
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct sysview_s g_sysview =
+{
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  .mode =
+    {
+      .flag = CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
+#ifdef CONFIG_SMP
+      .cpuset = CONFIG_SCHED_INSTRUMENTATION_CPUSET,
+#endif
+    }
+#endif
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sysview_send_taskinfo
+ ****************************************************************************/
+
+static void sysview_send_taskinfo(FAR struct tcb_s *tcb)
+{
+  SEGGER_SYSVIEW_TASKINFO info;
+
+  info.TaskID     = tcb->pid;
+  info.sName      = tcb->name;
+  info.Prio       = tcb->sched_priority;
+  info.StackBase  = (uintptr_t)tcb->stack_base_ptr;
+  info.StackSize  = tcb->adj_stack_size;
+
+  SEGGER_SYSVIEW_SendTaskInfo(&info);
+}
+
+/****************************************************************************
+ * Name: sysview_get_time
+ ****************************************************************************/
+
+static uint64_t sysview_get_time(void)
+{
+  return TICK2MSEC(clock_systime_ticks());
+}
+
+/****************************************************************************
+ * Name: sysview_send_tasklist
+ ****************************************************************************/
+
+static void sysview_send_tasklist(void)
+{
+  int i;
+
+  for (i = 0; i < g_npidhash; i++)
+    {
+      if (g_pidhash[i] != NULL)
+        {
+          sysview_send_taskinfo(g_pidhash[i]);
+        }
+    }
+}
+
+/****************************************************************************
+ * Name: sysview_send_description
+ ****************************************************************************/
+
+static void sysview_send_description(void)
+{
+  SEGGER_SYSVIEW_SendSysDesc("N="SEGGER_SYSVIEW_APP_NAME"");
+  SEGGER_SYSVIEW_SendSysDesc("D="CONFIG_LIBC_HOSTNAME"");
+  SEGGER_SYSVIEW_SendSysDesc("O=NuttX");
+}
+
+/****************************************************************************
+ * Name: sysview_isenabled
+ *
+ * Description:
+ *   Check whether the instrumentation is enabled.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   True is returned if the instrumentation is enabled.
+ *
+ ****************************************************************************/
+
+static bool sysview_isenabled(void)
+{
+  bool enable;
+
+  enable = SEGGER_SYSVIEW_IsStarted();
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  if (enable)
+    {
+      if ((g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE) == 0)
+        {
+          g_sysview.mode.flag |= NOTE_FILTER_MODE_FLAG_ENABLE;
+        }
+    }
+  else
+    {
+      if (g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE)
+        {
+          g_sysview.mode.flag &= ~NOTE_FILTER_MODE_FLAG_ENABLE;
+        }
+    }
+
+  if (enable)
+    {
+#  ifdef CONFIG_SMP
+      /* Ignore notes that are not in the set of monitored CPUs */
+
+      if ((g_sysview.mode.cpuset & (1 << this_cpu())) == 0)
+        {
+          /* Not in the set of monitored CPUs.  Do not log the note. */
+
+          return false;
+        }
+#  endif
+    }
+
+#endif
+
+  return enable;
+}
+
+/****************************************************************************
+ * Name: sysview_isenabled_irqhandler
+ *
+ * Description:
+ *   Check whether the interrupt handler instrumentation is enabled.
+ *
+ * Input Parameters:
+ *   irq   - IRQ number
+ *   enter - interrupt enter/leave flag
+ *
+ * Returned Value:
+ *   True is returned if the instrumentation is enabled.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
+static inline int sysview_isenabled_irq(int irq, bool enter)
+{
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  if (!sysview_isenabled())
+    {
+      return false;
+    }
+
+  /* If the IRQ trace is disabled or the IRQ number is masked, disable
+   * subsequent syscall traces until leaving the interrupt handler
+   */
+
+  if (!(g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_IRQ) ||

Review comment:
       done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] anchao closed pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
anchao closed pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] anchao commented on pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
anchao commented on pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327#issuecomment-1020335572


   > hi @anchao did you test it on more common boards like stm32f4discovery? Unfortunately Segger doesn't support ESP32 yet!
   @acassis ,
   I only tested the arm architecture, the porting layer does not use architecture-related implementations from RTT, I think xtensa should also be works fine without any changes 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] anchao commented on a change in pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
anchao commented on a change in pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327#discussion_r794504866



##########
File path: tools/nxstyle.c
##########
@@ -307,6 +307,17 @@ static const char *g_white_list[] =
   "__asan_loadN_noabort",
   "__asan_storeN_noabort",
 
+  /* Ref:
+   * drivers/segger/note_sysview.c

Review comment:
       Done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on a change in pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327#discussion_r794229680



##########
File path: drivers/segger/Make.defs
##########
@@ -38,4 +51,21 @@ ifeq ($(CONFIG_SEGGER_SYSVIEW),y)
   CFLAGS += ${shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)sched}
   CFLAGS += ${shell $(INCDIR) "$(CC)" segger$(DELIM)SystemView$(DELIM)SEGGER}
   CFLAGS += ${shell $(INCDIR) "$(CC)" segger$(DELIM)SystemView$(DELIM)SYSVIEW}
+
+  SYSVIEW_VERSION ?= 3.30

Review comment:
       remove  the space

##########
File path: drivers/segger/Make.defs
##########
@@ -29,6 +32,16 @@ ifeq ($(CONFIG_SEGGER_RTT),y)
   ifeq ($(CONFIG_ARCH_ARMV7M),y)
     ASRCS += segger/RTT/RTT/SEGGER_RTT_ASM_ARMv7M.S
   endif
+
+  RTT_VERSION     ?= 7.54

Review comment:
       remove space




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] anchao commented on a change in pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
anchao commented on a change in pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327#discussion_r794427487



##########
File path: drivers/segger/Make.defs
##########
@@ -29,6 +32,16 @@ ifeq ($(CONFIG_SEGGER_RTT),y)
   ifeq ($(CONFIG_ARCH_ARMV7M),y)
     ASRCS += segger/RTT/RTT/SEGGER_RTT_ASM_ARMv7M.S
   endif
+
+  RTT_VERSION     ?= 7.54

Review comment:
       Done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] anchao commented on pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
anchao commented on pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327#issuecomment-1021985497


   > Thank you @anchao I just saw you closed this PR, did you find some issue?
   
   @acassis  
   
   This commit relies on tweaks implemented by up_perf* related apis,@xiaoxiang781216 has completed the improvement, I will reopen this PR asap


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] anchao edited a comment on pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
anchao edited a comment on pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327#issuecomment-1020335572


   > hi @anchao did you test it on more common boards like stm32f4discovery? Unfortunately Segger doesn't support ESP32 yet!
   
   @acassis ,
   I only tested the arm architecture, the porting layer does not use architecture-related implementations from RTT, I think xtensa should also be works fine without any changes 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] anchao closed pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
anchao closed pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327#issuecomment-1024854402


   @pkarashchenko do you have more comment?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] anchao commented on pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
anchao commented on pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327#issuecomment-1024859414


   > There is one minor comment that is still not addressed, but nothing that blocks from merging.
   
   resolved


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] anchao commented on a change in pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
anchao commented on a change in pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327#discussion_r794635918



##########
File path: drivers/segger/note_sysview.c
##########
@@ -0,0 +1,553 @@
+/****************************************************************************
+ * drivers/segger/note_sysview.c
+ *
+ * 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/config.h>
+#include <syslog.h>
+#include <syscall.h>
+
+#include <nuttx/clock.h>
+#include <nuttx/sched.h>
+#include <nuttx/sched_note.h>
+
+#include <SEGGER_RTT.h>
+#include <SEGGER_SYSVIEW.h>
+
+#include "sched/sched.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifndef CONFIG_SMP_NCPUS
+#define CONFIG_SMP_NCPUS 1
+#endif
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct sysview_cpu_s
+{
+  FAR struct tcb_s *tcb;
+  unsigned int      irq;
+  bool              in_isrcb;
+};
+
+struct sysview_s
+{
+  struct sysview_cpu_s      scpu[CONFIG_SMP_NCPUS];
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  struct note_filter_mode_s mode;
+#endif
+#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
+  struct note_filter_irq_s  irq_mask;
+#endif
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct sysview_s g_sysview =
+{
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  .mode =
+    {
+      .flag = CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
+#ifdef CONFIG_SMP
+      .cpuset = CONFIG_SCHED_INSTRUMENTATION_CPUSET,
+#endif
+    }
+#endif
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sysview_send_taskinfo
+ ****************************************************************************/
+
+static void sysview_send_taskinfo(FAR struct tcb_s *tcb)
+{
+  SEGGER_SYSVIEW_TASKINFO info;
+
+  info.TaskID     = tcb->pid;
+  info.sName      = tcb->name;
+  info.Prio       = tcb->sched_priority;
+  info.StackBase  = (uintptr_t)tcb->stack_base_ptr;
+  info.StackSize  = tcb->adj_stack_size;
+
+  SEGGER_SYSVIEW_SendTaskInfo(&info);
+}
+
+/****************************************************************************
+ * Name: sysview_get_time
+ ****************************************************************************/
+
+static uint64_t sysview_get_time(void)
+{
+  return TICK2MSEC(clock_systime_ticks());
+}
+
+/****************************************************************************
+ * Name: sysview_send_tasklist
+ ****************************************************************************/
+
+static void sysview_send_tasklist(void)
+{
+  int i;
+
+  for (i = 0; i < g_npidhash; i++)
+    {
+      if (g_pidhash[i] != NULL)
+        {
+          sysview_send_taskinfo(g_pidhash[i]);
+        }
+    }
+}
+
+/****************************************************************************
+ * Name: sysview_send_description
+ ****************************************************************************/
+
+static void sysview_send_description(void)
+{
+  SEGGER_SYSVIEW_SendSysDesc("N="SEGGER_SYSVIEW_APP_NAME"");
+  SEGGER_SYSVIEW_SendSysDesc("D="CONFIG_LIBC_HOSTNAME"");
+  SEGGER_SYSVIEW_SendSysDesc("O=NuttX");
+}
+
+/****************************************************************************
+ * Name: sysview_isenabled
+ *
+ * Description:
+ *   Check whether the instrumentation is enabled.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   True is returned if the instrumentation is enabled.
+ *
+ ****************************************************************************/
+
+static bool sysview_isenabled(void)
+{
+  bool enable;
+
+  enable = SEGGER_SYSVIEW_IsStarted();
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  if (enable)
+    {
+      if ((g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE) == 0)
+        {
+          g_sysview.mode.flag |= NOTE_FILTER_MODE_FLAG_ENABLE;
+        }
+    }
+  else
+    {
+      if (g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE)

Review comment:
       done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] anchao commented on a change in pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
anchao commented on a change in pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327#discussion_r794636206



##########
File path: drivers/segger/note_sysview.c
##########
@@ -0,0 +1,553 @@
+/****************************************************************************
+ * drivers/segger/note_sysview.c
+ *
+ * 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/config.h>
+#include <syslog.h>
+#include <syscall.h>
+
+#include <nuttx/clock.h>
+#include <nuttx/sched.h>
+#include <nuttx/sched_note.h>
+
+#include <SEGGER_RTT.h>
+#include <SEGGER_SYSVIEW.h>
+
+#include "sched/sched.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifndef CONFIG_SMP_NCPUS
+#define CONFIG_SMP_NCPUS 1
+#endif
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct sysview_cpu_s
+{
+  FAR struct tcb_s *tcb;
+  unsigned int      irq;
+  bool              in_isrcb;
+};
+
+struct sysview_s
+{
+  struct sysview_cpu_s      scpu[CONFIG_SMP_NCPUS];
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  struct note_filter_mode_s mode;
+#endif
+#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
+  struct note_filter_irq_s  irq_mask;
+#endif
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct sysview_s g_sysview =
+{
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  .mode =
+    {
+      .flag = CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
+#ifdef CONFIG_SMP
+      .cpuset = CONFIG_SCHED_INSTRUMENTATION_CPUSET,
+#endif
+    }
+#endif
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sysview_send_taskinfo
+ ****************************************************************************/
+
+static void sysview_send_taskinfo(FAR struct tcb_s *tcb)
+{
+  SEGGER_SYSVIEW_TASKINFO info;
+
+  info.TaskID     = tcb->pid;
+  info.sName      = tcb->name;
+  info.Prio       = tcb->sched_priority;
+  info.StackBase  = (uintptr_t)tcb->stack_base_ptr;
+  info.StackSize  = tcb->adj_stack_size;
+
+  SEGGER_SYSVIEW_SendTaskInfo(&info);
+}
+
+/****************************************************************************
+ * Name: sysview_get_time
+ ****************************************************************************/
+
+static uint64_t sysview_get_time(void)
+{
+  return TICK2MSEC(clock_systime_ticks());
+}
+
+/****************************************************************************
+ * Name: sysview_send_tasklist
+ ****************************************************************************/
+
+static void sysview_send_tasklist(void)
+{
+  int i;
+
+  for (i = 0; i < g_npidhash; i++)
+    {
+      if (g_pidhash[i] != NULL)
+        {
+          sysview_send_taskinfo(g_pidhash[i]);
+        }
+    }
+}
+
+/****************************************************************************
+ * Name: sysview_send_description
+ ****************************************************************************/
+
+static void sysview_send_description(void)
+{
+  SEGGER_SYSVIEW_SendSysDesc("N="SEGGER_SYSVIEW_APP_NAME"");
+  SEGGER_SYSVIEW_SendSysDesc("D="CONFIG_LIBC_HOSTNAME"");

Review comment:
       done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] pkarashchenko commented on a change in pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on a change in pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327#discussion_r794530586



##########
File path: drivers/segger/note_sysview.c
##########
@@ -0,0 +1,553 @@
+/****************************************************************************
+ * drivers/segger/note_sysview.c
+ *
+ * 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/config.h>
+#include <syslog.h>
+#include <syscall.h>
+
+#include <nuttx/clock.h>
+#include <nuttx/sched.h>
+#include <nuttx/sched_note.h>
+
+#include <SEGGER_RTT.h>
+#include <SEGGER_SYSVIEW.h>
+
+#include "sched/sched.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifndef CONFIG_SMP_NCPUS
+#define CONFIG_SMP_NCPUS 1
+#endif

Review comment:
       ```suggestion
   ```
   Already available from `sys/types.h`

##########
File path: drivers/segger/note_sysview.c
##########
@@ -0,0 +1,553 @@
+/****************************************************************************
+ * drivers/segger/note_sysview.c
+ *
+ * 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/config.h>
+#include <syslog.h>
+#include <syscall.h>
+
+#include <nuttx/clock.h>
+#include <nuttx/sched.h>
+#include <nuttx/sched_note.h>
+
+#include <SEGGER_RTT.h>
+#include <SEGGER_SYSVIEW.h>
+
+#include "sched/sched.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifndef CONFIG_SMP_NCPUS
+#define CONFIG_SMP_NCPUS 1
+#endif
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct sysview_cpu_s
+{
+  FAR struct tcb_s *tcb;
+  unsigned int      irq;
+  bool              in_isrcb;
+};
+
+struct sysview_s
+{
+  struct sysview_cpu_s      scpu[CONFIG_SMP_NCPUS];
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  struct note_filter_mode_s mode;
+#endif
+#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
+  struct note_filter_irq_s  irq_mask;
+#endif
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct sysview_s g_sysview =
+{
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  .mode =
+    {
+      .flag = CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
+#ifdef CONFIG_SMP
+      .cpuset = CONFIG_SCHED_INSTRUMENTATION_CPUSET,
+#endif
+    }
+#endif
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sysview_send_taskinfo
+ ****************************************************************************/
+
+static void sysview_send_taskinfo(FAR struct tcb_s *tcb)
+{
+  SEGGER_SYSVIEW_TASKINFO info;
+
+  info.TaskID     = tcb->pid;
+  info.sName      = tcb->name;
+  info.Prio       = tcb->sched_priority;
+  info.StackBase  = (uintptr_t)tcb->stack_base_ptr;
+  info.StackSize  = tcb->adj_stack_size;
+
+  SEGGER_SYSVIEW_SendTaskInfo(&info);
+}
+
+/****************************************************************************
+ * Name: sysview_get_time
+ ****************************************************************************/
+
+static uint64_t sysview_get_time(void)
+{
+  return TICK2MSEC(clock_systime_ticks());
+}
+
+/****************************************************************************
+ * Name: sysview_send_tasklist
+ ****************************************************************************/
+
+static void sysview_send_tasklist(void)
+{
+  int i;
+
+  for (i = 0; i < g_npidhash; i++)
+    {
+      if (g_pidhash[i] != NULL)
+        {
+          sysview_send_taskinfo(g_pidhash[i]);
+        }
+    }
+}
+
+/****************************************************************************
+ * Name: sysview_send_description
+ ****************************************************************************/
+
+static void sysview_send_description(void)
+{
+  SEGGER_SYSVIEW_SendSysDesc("N="SEGGER_SYSVIEW_APP_NAME"");

Review comment:
       ```suggestion
     SEGGER_SYSVIEW_SendSysDesc("N="SEGGER_SYSVIEW_APP_NAME);
   ```
   ??  Not sure why `""` is needed

##########
File path: drivers/segger/config/SEGGER_SYSVIEW_Conf.h
##########
@@ -0,0 +1,63 @@
+/****************************************************************************
+ * drivers/segger/config/SEGGER_SYSVIEW_Conf.h
+ *
+ * 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 __DRIVERS_SEGGER_CONFIG_SEGGER_SYSVIEW_CONF_H
+#define __DRIVERS_SEGGER_CONFIG_SEGGER_SYSVIEW_CONF_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+extern unsigned int sysview_get_interrupt_id(void);
+extern unsigned int sysview_get_cycle_counter(void);
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Function macro to retrieve the Id of the currently active interrupt.
+ * Call user-supplied function SEGGER_SYSVIEW_X_GetInterruptId().
+ */
+
+#define SEGGER_SYSVIEW_GET_INTERRUPT_ID    sysview_get_interrupt_id
+
+/* Function macro to retrieve a system timestamp for SYSVIEW events.
+ * Call user-supplied function SEGGER_SYSVIEW_X_GetTimestamp().
+ */
+
+#define SEGGER_SYSVIEW_GET_TIMESTAMP       sysview_get_cycle_counter
+
+/* Number of bytes that SystemView uses for the RTT buffer. */
+
+#define SEGGER_SYSVIEW_RTT_BUFFER_SIZE     CONFIG_SEGGER_SYSVIEW_RTT_BUFFER_SIZE
+
+/* Largest cache line size (in bytes) in the target system. */
+
+#define SEGGER_SYSVIEW_CPU_CACHE_LINE_SIZE CONFIG_SEGGER_RTT_CPU_CACHE_LINE_SIZE
+
+/* Enable calling SEGGER_SYSVIEW_Start() after initialization. */
+
+#ifdef CONFIG_SEGGER_SYSVIEW_START_ON_INIT
+  #define SEGGER_SYSVIEW_START_ON_INIT     1

Review comment:
       ```suggestion
   #  define SEGGER_SYSVIEW_START_ON_INIT     1
   ```

##########
File path: drivers/segger/note_sysview.c
##########
@@ -0,0 +1,553 @@
+/****************************************************************************
+ * drivers/segger/note_sysview.c
+ *
+ * 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/config.h>
+#include <syslog.h>
+#include <syscall.h>
+
+#include <nuttx/clock.h>
+#include <nuttx/sched.h>
+#include <nuttx/sched_note.h>
+
+#include <SEGGER_RTT.h>
+#include <SEGGER_SYSVIEW.h>
+
+#include "sched/sched.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifndef CONFIG_SMP_NCPUS
+#define CONFIG_SMP_NCPUS 1
+#endif
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct sysview_cpu_s
+{
+  FAR struct tcb_s *tcb;
+  unsigned int      irq;
+  bool              in_isrcb;
+};
+
+struct sysview_s
+{
+  struct sysview_cpu_s      scpu[CONFIG_SMP_NCPUS];
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  struct note_filter_mode_s mode;
+#endif
+#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
+  struct note_filter_irq_s  irq_mask;
+#endif
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct sysview_s g_sysview =
+{
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  .mode =
+    {
+      .flag = CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
+#ifdef CONFIG_SMP
+      .cpuset = CONFIG_SCHED_INSTRUMENTATION_CPUSET,
+#endif
+    }
+#endif
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sysview_send_taskinfo
+ ****************************************************************************/
+
+static void sysview_send_taskinfo(FAR struct tcb_s *tcb)
+{
+  SEGGER_SYSVIEW_TASKINFO info;
+
+  info.TaskID     = tcb->pid;
+  info.sName      = tcb->name;
+  info.Prio       = tcb->sched_priority;
+  info.StackBase  = (uintptr_t)tcb->stack_base_ptr;
+  info.StackSize  = tcb->adj_stack_size;
+
+  SEGGER_SYSVIEW_SendTaskInfo(&info);
+}
+
+/****************************************************************************
+ * Name: sysview_get_time
+ ****************************************************************************/
+
+static uint64_t sysview_get_time(void)
+{
+  return TICK2MSEC(clock_systime_ticks());
+}
+
+/****************************************************************************
+ * Name: sysview_send_tasklist
+ ****************************************************************************/
+
+static void sysview_send_tasklist(void)
+{
+  int i;
+
+  for (i = 0; i < g_npidhash; i++)
+    {
+      if (g_pidhash[i] != NULL)
+        {
+          sysview_send_taskinfo(g_pidhash[i]);
+        }
+    }
+}
+
+/****************************************************************************
+ * Name: sysview_send_description
+ ****************************************************************************/
+
+static void sysview_send_description(void)
+{
+  SEGGER_SYSVIEW_SendSysDesc("N="SEGGER_SYSVIEW_APP_NAME"");
+  SEGGER_SYSVIEW_SendSysDesc("D="CONFIG_LIBC_HOSTNAME"");
+  SEGGER_SYSVIEW_SendSysDesc("O=NuttX");
+}
+
+/****************************************************************************
+ * Name: sysview_isenabled
+ *
+ * Description:
+ *   Check whether the instrumentation is enabled.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   True is returned if the instrumentation is enabled.
+ *
+ ****************************************************************************/
+
+static bool sysview_isenabled(void)
+{
+  bool enable;
+
+  enable = SEGGER_SYSVIEW_IsStarted();
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  if (enable)
+    {
+      if ((g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE) == 0)
+        {
+          g_sysview.mode.flag |= NOTE_FILTER_MODE_FLAG_ENABLE;
+        }
+    }
+  else
+    {
+      if (g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE)
+        {
+          g_sysview.mode.flag &= ~NOTE_FILTER_MODE_FLAG_ENABLE;
+        }
+    }
+
+  if (enable)
+    {
+#  ifdef CONFIG_SMP
+      /* Ignore notes that are not in the set of monitored CPUs */
+
+      if ((g_sysview.mode.cpuset & (1 << this_cpu())) == 0)
+        {
+          /* Not in the set of monitored CPUs.  Do not log the note. */
+
+          return false;
+        }
+#  endif
+    }
+
+#endif
+
+  return enable;
+}
+
+/****************************************************************************
+ * Name: sysview_isenabled_irqhandler
+ *
+ * Description:
+ *   Check whether the interrupt handler instrumentation is enabled.
+ *
+ * Input Parameters:
+ *   irq   - IRQ number
+ *   enter - interrupt enter/leave flag
+ *
+ * Returned Value:
+ *   True is returned if the instrumentation is enabled.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
+static inline int sysview_isenabled_irq(int irq, bool enter)
+{
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  if (!sysview_isenabled())
+    {
+      return false;
+    }
+
+  /* If the IRQ trace is disabled or the IRQ number is masked, disable
+   * subsequent syscall traces until leaving the interrupt handler
+   */
+
+  if (!(g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_IRQ) ||
+      NOTE_FILTER_IRQMASK_ISSET(irq, &g_sysview.irq_mask))
+    {
+      return false;
+    }
+#endif
+
+  return true;
+}
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sched_note_start, sched_note_stop, sched_note_switch,
+ *       sched_note_premption
+ *
+ * Description:
+ *   Hooks to scheduler monitor
+ *
+ * Input Parameters:
+ *   Varies
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void sched_note_start(FAR struct tcb_s *tcb)
+{
+  if (!sysview_isenabled())
+    {
+      return;
+    }
+
+  SEGGER_SYSVIEW_OnTaskCreate(tcb->pid);
+  sysview_send_taskinfo(tcb);
+}
+
+void sched_note_stop(FAR struct tcb_s *tcb)
+{
+  if (!sysview_isenabled())
+    {
+      return;
+    }
+
+  SEGGER_SYSVIEW_OnTaskTerminate(tcb->pid);
+}
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
+void sched_note_suspend(FAR struct tcb_s *tcb)
+{
+  if (!sysview_isenabled())
+    {
+      return;
+    }
+
+  if (g_sysview.scpu[up_cpu_index()].in_isrcb == false)
+    {
+      SEGGER_SYSVIEW_OnTaskStopExec();
+    }
+}
+
+void sched_note_resume(FAR struct tcb_s *tcb)
+{
+  struct sysview_cpu_s *scpu;
+
+  if (!sysview_isenabled())
+    {
+      return;
+    }
+
+  scpu = &g_sysview.scpu[up_cpu_index()];
+
+  if (scpu->in_isrcb == false)
+    {
+#if CONFIG_SMP_NCPUS == 1
+      if (tcb->flink == NULL)
+        {
+          SEGGER_SYSVIEW_OnIdle();
+        }
+      else
+#endif
+        {
+          SEGGER_SYSVIEW_OnTaskStartExec(tcb->pid);
+        }
+    }
+  else
+    {
+      scpu->tcb = tcb;
+    }
+}
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
+void sched_note_irqhandler(int irq, FAR void *handler, bool enter)
+{
+  struct sysview_cpu_s *scpu;
+
+  if (!sysview_isenabled_irq(irq, enter))
+    {
+      return;
+    }
+
+  scpu = &g_sysview.scpu[up_cpu_index()];
+
+  if (enter)
+    {
+      if (g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE)
+        {
+          scpu->in_isrcb = true;
+          SEGGER_SYSVIEW_OnTaskStopExec();
+        }
+
+      scpu->irq = irq;
+      SEGGER_SYSVIEW_RecordEnterISR();
+    }
+  else
+    {
+      SEGGER_SYSVIEW_RecordExitISR();
+
+      if (scpu->in_isrcb)
+        {
+#if CONFIG_SMP_NCPUS == 1
+          if (scpu->tcb && scpu->tcb->flink != NULL)
+            {
+              SEGGER_SYSVIEW_OnTaskStartExec(scpu->tcb->pid);
+            }
+          else
+            {
+              SEGGER_SYSVIEW_OnIdle();
+            }
+#else
+          if (scpu->tcb)
+            {
+              SEGGER_SYSVIEW_OnTaskStartExec(scpu->tcb->pid);
+            }
+          else
+            {
+              SEGGER_SYSVIEW_OnTaskStartExec(up_cpu_index());
+            }
+#endif
+
+          scpu->tcb = NULL;
+          scpu->in_isrcb = false;
+        }
+
+      scpu->irq = 0;
+    }
+}
+#endif
+
+/****************************************************************************
+ * Name: sysview_get_interrupt_id
+ *
+ * Description:
+ *   Retrieve the Id of the currently active interrupt.
+ *
+ ****************************************************************************/
+
+unsigned int sysview_get_interrupt_id(void)
+{
+  return g_sysview.scpu[up_cpu_index()].irq;
+}
+
+/****************************************************************************
+ * Name: sysview_get_cycle_counter
+ *
+ * Description:
+ *   Retrieve a system timestamp for SYSVIEW events.
+ *
+ ****************************************************************************/
+
+unsigned int sysview_get_cycle_counter(void)
+{
+  return up_perf_gettime();
+}
+
+/****************************************************************************
+ * Name: sysview_initialize
+ *
+ * Description:
+ *   Initializes the SYSVIEW module.
+ *
+ * Input Parameters:
+ *   None.
+ *
+ * Returned Value:
+ *   Zero on succress. A negated errno value is returned on a failure.
+ *
+ ****************************************************************************/
+
+int sysview_initialize(void)
+{
+  uint32_t freq = up_perf_getfreq();
+
+  static const SEGGER_SYSVIEW_OS_API g_sysview_trace_api =
+    {
+      sysview_get_time,
+      sysview_send_tasklist,
+    };
+
+  SEGGER_SYSVIEW_Init(freq, freq, &g_sysview_trace_api,
+                      sysview_send_description);
+
+#if CONFIG_SEGGER_SYSVIEW_RAM_BASE != 0
+  SEGGER_SYSVIEW_SetRAMBase(CONFIG_SEGGER_SYSVIEW_RAM_BASE);
+#endif
+
+#ifdef CONFIG_SEGGER_SYSVIEW_START_ON_INIT
+  if (g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE)

Review comment:
       ```suggestion
     if ((g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE) != 0)
   ```

##########
File path: drivers/segger/note_sysview.c
##########
@@ -0,0 +1,553 @@
+/****************************************************************************
+ * drivers/segger/note_sysview.c
+ *
+ * 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/config.h>
+#include <syslog.h>
+#include <syscall.h>
+
+#include <nuttx/clock.h>
+#include <nuttx/sched.h>
+#include <nuttx/sched_note.h>
+
+#include <SEGGER_RTT.h>
+#include <SEGGER_SYSVIEW.h>
+
+#include "sched/sched.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifndef CONFIG_SMP_NCPUS
+#define CONFIG_SMP_NCPUS 1
+#endif
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct sysview_cpu_s
+{
+  FAR struct tcb_s *tcb;
+  unsigned int      irq;
+  bool              in_isrcb;
+};
+
+struct sysview_s
+{
+  struct sysview_cpu_s      scpu[CONFIG_SMP_NCPUS];
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  struct note_filter_mode_s mode;
+#endif
+#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
+  struct note_filter_irq_s  irq_mask;
+#endif
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct sysview_s g_sysview =
+{
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  .mode =
+    {
+      .flag = CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
+#ifdef CONFIG_SMP
+      .cpuset = CONFIG_SCHED_INSTRUMENTATION_CPUSET,
+#endif
+    }
+#endif
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sysview_send_taskinfo
+ ****************************************************************************/
+
+static void sysview_send_taskinfo(FAR struct tcb_s *tcb)
+{
+  SEGGER_SYSVIEW_TASKINFO info;
+
+  info.TaskID     = tcb->pid;
+  info.sName      = tcb->name;
+  info.Prio       = tcb->sched_priority;
+  info.StackBase  = (uintptr_t)tcb->stack_base_ptr;
+  info.StackSize  = tcb->adj_stack_size;
+
+  SEGGER_SYSVIEW_SendTaskInfo(&info);
+}
+
+/****************************************************************************
+ * Name: sysview_get_time
+ ****************************************************************************/
+
+static uint64_t sysview_get_time(void)
+{
+  return TICK2MSEC(clock_systime_ticks());
+}
+
+/****************************************************************************
+ * Name: sysview_send_tasklist
+ ****************************************************************************/
+
+static void sysview_send_tasklist(void)
+{
+  int i;
+
+  for (i = 0; i < g_npidhash; i++)
+    {
+      if (g_pidhash[i] != NULL)
+        {
+          sysview_send_taskinfo(g_pidhash[i]);
+        }
+    }
+}
+
+/****************************************************************************
+ * Name: sysview_send_description
+ ****************************************************************************/
+
+static void sysview_send_description(void)
+{
+  SEGGER_SYSVIEW_SendSysDesc("N="SEGGER_SYSVIEW_APP_NAME"");
+  SEGGER_SYSVIEW_SendSysDesc("D="CONFIG_LIBC_HOSTNAME"");
+  SEGGER_SYSVIEW_SendSysDesc("O=NuttX");
+}
+
+/****************************************************************************
+ * Name: sysview_isenabled
+ *
+ * Description:
+ *   Check whether the instrumentation is enabled.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   True is returned if the instrumentation is enabled.
+ *
+ ****************************************************************************/
+
+static bool sysview_isenabled(void)
+{
+  bool enable;
+
+  enable = SEGGER_SYSVIEW_IsStarted();
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  if (enable)
+    {
+      if ((g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE) == 0)
+        {
+          g_sysview.mode.flag |= NOTE_FILTER_MODE_FLAG_ENABLE;
+        }
+    }
+  else
+    {
+      if (g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE)
+        {
+          g_sysview.mode.flag &= ~NOTE_FILTER_MODE_FLAG_ENABLE;
+        }
+    }
+
+  if (enable)
+    {
+#  ifdef CONFIG_SMP
+      /* Ignore notes that are not in the set of monitored CPUs */
+
+      if ((g_sysview.mode.cpuset & (1 << this_cpu())) == 0)
+        {
+          /* Not in the set of monitored CPUs.  Do not log the note. */
+
+          return false;
+        }
+#  endif
+    }
+
+#endif
+
+  return enable;
+}
+
+/****************************************************************************
+ * Name: sysview_isenabled_irqhandler
+ *
+ * Description:
+ *   Check whether the interrupt handler instrumentation is enabled.
+ *
+ * Input Parameters:
+ *   irq   - IRQ number
+ *   enter - interrupt enter/leave flag
+ *
+ * Returned Value:
+ *   True is returned if the instrumentation is enabled.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
+static inline int sysview_isenabled_irq(int irq, bool enter)
+{
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  if (!sysview_isenabled())
+    {
+      return false;
+    }
+
+  /* If the IRQ trace is disabled or the IRQ number is masked, disable
+   * subsequent syscall traces until leaving the interrupt handler
+   */
+
+  if (!(g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_IRQ) ||

Review comment:
       ```suggestion
     if ((g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_IRQ) == 0 ||
   ```

##########
File path: drivers/segger/note_sysview.c
##########
@@ -0,0 +1,553 @@
+/****************************************************************************
+ * drivers/segger/note_sysview.c
+ *
+ * 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/config.h>
+#include <syslog.h>
+#include <syscall.h>
+
+#include <nuttx/clock.h>
+#include <nuttx/sched.h>
+#include <nuttx/sched_note.h>
+
+#include <SEGGER_RTT.h>
+#include <SEGGER_SYSVIEW.h>
+
+#include "sched/sched.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifndef CONFIG_SMP_NCPUS
+#define CONFIG_SMP_NCPUS 1
+#endif
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct sysview_cpu_s
+{
+  FAR struct tcb_s *tcb;
+  unsigned int      irq;
+  bool              in_isrcb;
+};
+
+struct sysview_s
+{
+  struct sysview_cpu_s      scpu[CONFIG_SMP_NCPUS];
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  struct note_filter_mode_s mode;
+#endif
+#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
+  struct note_filter_irq_s  irq_mask;
+#endif
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct sysview_s g_sysview =
+{
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  .mode =
+    {
+      .flag = CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
+#ifdef CONFIG_SMP
+      .cpuset = CONFIG_SCHED_INSTRUMENTATION_CPUSET,
+#endif
+    }
+#endif
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sysview_send_taskinfo
+ ****************************************************************************/
+
+static void sysview_send_taskinfo(FAR struct tcb_s *tcb)
+{
+  SEGGER_SYSVIEW_TASKINFO info;
+
+  info.TaskID     = tcb->pid;
+  info.sName      = tcb->name;
+  info.Prio       = tcb->sched_priority;
+  info.StackBase  = (uintptr_t)tcb->stack_base_ptr;
+  info.StackSize  = tcb->adj_stack_size;
+
+  SEGGER_SYSVIEW_SendTaskInfo(&info);
+}
+
+/****************************************************************************
+ * Name: sysview_get_time
+ ****************************************************************************/
+
+static uint64_t sysview_get_time(void)
+{
+  return TICK2MSEC(clock_systime_ticks());
+}
+
+/****************************************************************************
+ * Name: sysview_send_tasklist
+ ****************************************************************************/
+
+static void sysview_send_tasklist(void)
+{
+  int i;
+
+  for (i = 0; i < g_npidhash; i++)
+    {
+      if (g_pidhash[i] != NULL)
+        {
+          sysview_send_taskinfo(g_pidhash[i]);
+        }
+    }
+}
+
+/****************************************************************************
+ * Name: sysview_send_description
+ ****************************************************************************/
+
+static void sysview_send_description(void)
+{
+  SEGGER_SYSVIEW_SendSysDesc("N="SEGGER_SYSVIEW_APP_NAME"");
+  SEGGER_SYSVIEW_SendSysDesc("D="CONFIG_LIBC_HOSTNAME"");
+  SEGGER_SYSVIEW_SendSysDesc("O=NuttX");
+}
+
+/****************************************************************************
+ * Name: sysview_isenabled
+ *
+ * Description:
+ *   Check whether the instrumentation is enabled.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   True is returned if the instrumentation is enabled.
+ *
+ ****************************************************************************/
+
+static bool sysview_isenabled(void)
+{
+  bool enable;
+
+  enable = SEGGER_SYSVIEW_IsStarted();
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  if (enable)
+    {
+      if ((g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE) == 0)
+        {
+          g_sysview.mode.flag |= NOTE_FILTER_MODE_FLAG_ENABLE;
+        }
+    }
+  else
+    {
+      if (g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE)
+        {
+          g_sysview.mode.flag &= ~NOTE_FILTER_MODE_FLAG_ENABLE;
+        }
+    }
+
+  if (enable)
+    {
+#  ifdef CONFIG_SMP
+      /* Ignore notes that are not in the set of monitored CPUs */
+
+      if ((g_sysview.mode.cpuset & (1 << this_cpu())) == 0)
+        {
+          /* Not in the set of monitored CPUs.  Do not log the note. */
+
+          return false;
+        }
+#  endif
+    }
+
+#endif
+
+  return enable;
+}
+
+/****************************************************************************
+ * Name: sysview_isenabled_irqhandler
+ *
+ * Description:
+ *   Check whether the interrupt handler instrumentation is enabled.
+ *
+ * Input Parameters:
+ *   irq   - IRQ number
+ *   enter - interrupt enter/leave flag
+ *
+ * Returned Value:
+ *   True is returned if the instrumentation is enabled.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
+static inline int sysview_isenabled_irq(int irq, bool enter)
+{
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  if (!sysview_isenabled())
+    {
+      return false;
+    }
+
+  /* If the IRQ trace is disabled or the IRQ number is masked, disable
+   * subsequent syscall traces until leaving the interrupt handler
+   */
+
+  if (!(g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_IRQ) ||
+      NOTE_FILTER_IRQMASK_ISSET(irq, &g_sysview.irq_mask))
+    {
+      return false;
+    }
+#endif
+
+  return true;
+}
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sched_note_start, sched_note_stop, sched_note_switch,
+ *       sched_note_premption
+ *
+ * Description:
+ *   Hooks to scheduler monitor
+ *
+ * Input Parameters:
+ *   Varies
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void sched_note_start(FAR struct tcb_s *tcb)
+{
+  if (!sysview_isenabled())
+    {
+      return;
+    }
+
+  SEGGER_SYSVIEW_OnTaskCreate(tcb->pid);
+  sysview_send_taskinfo(tcb);
+}
+
+void sched_note_stop(FAR struct tcb_s *tcb)
+{
+  if (!sysview_isenabled())
+    {
+      return;
+    }
+
+  SEGGER_SYSVIEW_OnTaskTerminate(tcb->pid);
+}
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
+void sched_note_suspend(FAR struct tcb_s *tcb)
+{
+  if (!sysview_isenabled())
+    {
+      return;
+    }
+
+  if (g_sysview.scpu[up_cpu_index()].in_isrcb == false)
+    {
+      SEGGER_SYSVIEW_OnTaskStopExec();
+    }
+}
+
+void sched_note_resume(FAR struct tcb_s *tcb)
+{
+  struct sysview_cpu_s *scpu;
+
+  if (!sysview_isenabled())
+    {
+      return;
+    }
+
+  scpu = &g_sysview.scpu[up_cpu_index()];
+
+  if (scpu->in_isrcb == false)

Review comment:
       ```suggestion
     if (!scpu->in_isrcb)
   ```

##########
File path: drivers/segger/config/SEGGER_SYSVIEW_Conf.h
##########
@@ -0,0 +1,63 @@
+/****************************************************************************
+ * drivers/segger/config/SEGGER_SYSVIEW_Conf.h
+ *
+ * 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 __DRIVERS_SEGGER_CONFIG_SEGGER_SYSVIEW_CONF_H
+#define __DRIVERS_SEGGER_CONFIG_SEGGER_SYSVIEW_CONF_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+extern unsigned int sysview_get_interrupt_id(void);
+extern unsigned int sysview_get_cycle_counter(void);

Review comment:
       Maybe should be moved to a separate section?

##########
File path: drivers/segger/note_sysview.c
##########
@@ -0,0 +1,553 @@
+/****************************************************************************
+ * drivers/segger/note_sysview.c
+ *
+ * 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/config.h>
+#include <syslog.h>
+#include <syscall.h>
+
+#include <nuttx/clock.h>
+#include <nuttx/sched.h>
+#include <nuttx/sched_note.h>
+
+#include <SEGGER_RTT.h>
+#include <SEGGER_SYSVIEW.h>
+
+#include "sched/sched.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifndef CONFIG_SMP_NCPUS
+#define CONFIG_SMP_NCPUS 1
+#endif
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct sysview_cpu_s
+{
+  FAR struct tcb_s *tcb;
+  unsigned int      irq;
+  bool              in_isrcb;
+};
+
+struct sysview_s
+{
+  struct sysview_cpu_s      scpu[CONFIG_SMP_NCPUS];
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  struct note_filter_mode_s mode;
+#endif
+#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
+  struct note_filter_irq_s  irq_mask;
+#endif
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct sysview_s g_sysview =
+{
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  .mode =
+    {
+      .flag = CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
+#ifdef CONFIG_SMP
+      .cpuset = CONFIG_SCHED_INSTRUMENTATION_CPUSET,
+#endif
+    }
+#endif
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sysview_send_taskinfo
+ ****************************************************************************/
+
+static void sysview_send_taskinfo(FAR struct tcb_s *tcb)
+{
+  SEGGER_SYSVIEW_TASKINFO info;
+
+  info.TaskID     = tcb->pid;
+  info.sName      = tcb->name;
+  info.Prio       = tcb->sched_priority;
+  info.StackBase  = (uintptr_t)tcb->stack_base_ptr;
+  info.StackSize  = tcb->adj_stack_size;
+
+  SEGGER_SYSVIEW_SendTaskInfo(&info);
+}
+
+/****************************************************************************
+ * Name: sysview_get_time
+ ****************************************************************************/
+
+static uint64_t sysview_get_time(void)
+{
+  return TICK2MSEC(clock_systime_ticks());
+}
+
+/****************************************************************************
+ * Name: sysview_send_tasklist
+ ****************************************************************************/
+
+static void sysview_send_tasklist(void)
+{
+  int i;
+
+  for (i = 0; i < g_npidhash; i++)
+    {
+      if (g_pidhash[i] != NULL)
+        {
+          sysview_send_taskinfo(g_pidhash[i]);
+        }
+    }
+}
+
+/****************************************************************************
+ * Name: sysview_send_description
+ ****************************************************************************/
+
+static void sysview_send_description(void)
+{
+  SEGGER_SYSVIEW_SendSysDesc("N="SEGGER_SYSVIEW_APP_NAME"");
+  SEGGER_SYSVIEW_SendSysDesc("D="CONFIG_LIBC_HOSTNAME"");

Review comment:
       ```suggestion
     SEGGER_SYSVIEW_SendSysDesc("D="CONFIG_LIBC_HOSTNAME);
   ```
   ??  Not sure why `""` is needed

##########
File path: drivers/segger/note_sysview.c
##########
@@ -0,0 +1,553 @@
+/****************************************************************************
+ * drivers/segger/note_sysview.c
+ *
+ * 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/config.h>
+#include <syslog.h>
+#include <syscall.h>
+
+#include <nuttx/clock.h>
+#include <nuttx/sched.h>
+#include <nuttx/sched_note.h>
+
+#include <SEGGER_RTT.h>
+#include <SEGGER_SYSVIEW.h>
+
+#include "sched/sched.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifndef CONFIG_SMP_NCPUS
+#define CONFIG_SMP_NCPUS 1
+#endif
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct sysview_cpu_s
+{
+  FAR struct tcb_s *tcb;
+  unsigned int      irq;
+  bool              in_isrcb;
+};
+
+struct sysview_s
+{
+  struct sysview_cpu_s      scpu[CONFIG_SMP_NCPUS];
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  struct note_filter_mode_s mode;
+#endif
+#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
+  struct note_filter_irq_s  irq_mask;
+#endif
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct sysview_s g_sysview =
+{
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  .mode =
+    {
+      .flag = CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
+#ifdef CONFIG_SMP
+      .cpuset = CONFIG_SCHED_INSTRUMENTATION_CPUSET,
+#endif
+    }
+#endif
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sysview_send_taskinfo
+ ****************************************************************************/
+
+static void sysview_send_taskinfo(FAR struct tcb_s *tcb)
+{
+  SEGGER_SYSVIEW_TASKINFO info;
+
+  info.TaskID     = tcb->pid;
+  info.sName      = tcb->name;
+  info.Prio       = tcb->sched_priority;
+  info.StackBase  = (uintptr_t)tcb->stack_base_ptr;
+  info.StackSize  = tcb->adj_stack_size;
+
+  SEGGER_SYSVIEW_SendTaskInfo(&info);
+}
+
+/****************************************************************************
+ * Name: sysview_get_time
+ ****************************************************************************/
+
+static uint64_t sysview_get_time(void)
+{
+  return TICK2MSEC(clock_systime_ticks());
+}
+
+/****************************************************************************
+ * Name: sysview_send_tasklist
+ ****************************************************************************/
+
+static void sysview_send_tasklist(void)
+{
+  int i;
+
+  for (i = 0; i < g_npidhash; i++)
+    {
+      if (g_pidhash[i] != NULL)
+        {
+          sysview_send_taskinfo(g_pidhash[i]);
+        }
+    }
+}
+
+/****************************************************************************
+ * Name: sysview_send_description
+ ****************************************************************************/
+
+static void sysview_send_description(void)
+{
+  SEGGER_SYSVIEW_SendSysDesc("N="SEGGER_SYSVIEW_APP_NAME"");
+  SEGGER_SYSVIEW_SendSysDesc("D="CONFIG_LIBC_HOSTNAME"");
+  SEGGER_SYSVIEW_SendSysDesc("O=NuttX");
+}
+
+/****************************************************************************
+ * Name: sysview_isenabled
+ *
+ * Description:
+ *   Check whether the instrumentation is enabled.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   True is returned if the instrumentation is enabled.
+ *
+ ****************************************************************************/
+
+static bool sysview_isenabled(void)
+{
+  bool enable;
+
+  enable = SEGGER_SYSVIEW_IsStarted();
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  if (enable)
+    {
+      if ((g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE) == 0)
+        {
+          g_sysview.mode.flag |= NOTE_FILTER_MODE_FLAG_ENABLE;
+        }
+    }
+  else
+    {
+      if (g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE)

Review comment:
       ```suggestion
         if ((g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE) != 0)
   ```

##########
File path: drivers/segger/note_sysview.c
##########
@@ -0,0 +1,553 @@
+/****************************************************************************
+ * drivers/segger/note_sysview.c
+ *
+ * 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/config.h>
+#include <syslog.h>
+#include <syscall.h>
+
+#include <nuttx/clock.h>
+#include <nuttx/sched.h>
+#include <nuttx/sched_note.h>
+
+#include <SEGGER_RTT.h>
+#include <SEGGER_SYSVIEW.h>
+
+#include "sched/sched.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifndef CONFIG_SMP_NCPUS
+#define CONFIG_SMP_NCPUS 1
+#endif
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct sysview_cpu_s
+{
+  FAR struct tcb_s *tcb;
+  unsigned int      irq;
+  bool              in_isrcb;
+};
+
+struct sysview_s
+{
+  struct sysview_cpu_s      scpu[CONFIG_SMP_NCPUS];
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  struct note_filter_mode_s mode;
+#endif
+#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
+  struct note_filter_irq_s  irq_mask;
+#endif
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct sysview_s g_sysview =
+{
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  .mode =
+    {
+      .flag = CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
+#ifdef CONFIG_SMP
+      .cpuset = CONFIG_SCHED_INSTRUMENTATION_CPUSET,
+#endif
+    }
+#endif
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sysview_send_taskinfo
+ ****************************************************************************/
+
+static void sysview_send_taskinfo(FAR struct tcb_s *tcb)
+{
+  SEGGER_SYSVIEW_TASKINFO info;
+
+  info.TaskID     = tcb->pid;
+  info.sName      = tcb->name;
+  info.Prio       = tcb->sched_priority;
+  info.StackBase  = (uintptr_t)tcb->stack_base_ptr;
+  info.StackSize  = tcb->adj_stack_size;
+
+  SEGGER_SYSVIEW_SendTaskInfo(&info);
+}
+
+/****************************************************************************
+ * Name: sysview_get_time
+ ****************************************************************************/
+
+static uint64_t sysview_get_time(void)
+{
+  return TICK2MSEC(clock_systime_ticks());
+}
+
+/****************************************************************************
+ * Name: sysview_send_tasklist
+ ****************************************************************************/
+
+static void sysview_send_tasklist(void)
+{
+  int i;
+
+  for (i = 0; i < g_npidhash; i++)
+    {
+      if (g_pidhash[i] != NULL)
+        {
+          sysview_send_taskinfo(g_pidhash[i]);
+        }
+    }
+}
+
+/****************************************************************************
+ * Name: sysview_send_description
+ ****************************************************************************/
+
+static void sysview_send_description(void)
+{
+  SEGGER_SYSVIEW_SendSysDesc("N="SEGGER_SYSVIEW_APP_NAME"");
+  SEGGER_SYSVIEW_SendSysDesc("D="CONFIG_LIBC_HOSTNAME"");
+  SEGGER_SYSVIEW_SendSysDesc("O=NuttX");
+}
+
+/****************************************************************************
+ * Name: sysview_isenabled
+ *
+ * Description:
+ *   Check whether the instrumentation is enabled.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   True is returned if the instrumentation is enabled.
+ *
+ ****************************************************************************/
+
+static bool sysview_isenabled(void)
+{
+  bool enable;
+
+  enable = SEGGER_SYSVIEW_IsStarted();
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  if (enable)
+    {
+      if ((g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE) == 0)
+        {
+          g_sysview.mode.flag |= NOTE_FILTER_MODE_FLAG_ENABLE;
+        }
+    }
+  else
+    {
+      if (g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE)
+        {
+          g_sysview.mode.flag &= ~NOTE_FILTER_MODE_FLAG_ENABLE;
+        }
+    }
+
+  if (enable)
+    {
+#  ifdef CONFIG_SMP
+      /* Ignore notes that are not in the set of monitored CPUs */
+
+      if ((g_sysview.mode.cpuset & (1 << this_cpu())) == 0)
+        {
+          /* Not in the set of monitored CPUs.  Do not log the note. */
+
+          return false;
+        }
+#  endif
+    }
+
+#endif
+
+  return enable;
+}
+
+/****************************************************************************
+ * Name: sysview_isenabled_irqhandler
+ *
+ * Description:
+ *   Check whether the interrupt handler instrumentation is enabled.
+ *
+ * Input Parameters:
+ *   irq   - IRQ number
+ *   enter - interrupt enter/leave flag
+ *
+ * Returned Value:
+ *   True is returned if the instrumentation is enabled.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
+static inline int sysview_isenabled_irq(int irq, bool enter)
+{
+#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
+  if (!sysview_isenabled())
+    {
+      return false;
+    }
+
+  /* If the IRQ trace is disabled or the IRQ number is masked, disable
+   * subsequent syscall traces until leaving the interrupt handler
+   */
+
+  if (!(g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_IRQ) ||
+      NOTE_FILTER_IRQMASK_ISSET(irq, &g_sysview.irq_mask))
+    {
+      return false;
+    }
+#endif
+
+  return true;
+}
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sched_note_start, sched_note_stop, sched_note_switch,
+ *       sched_note_premption
+ *
+ * Description:
+ *   Hooks to scheduler monitor
+ *
+ * Input Parameters:
+ *   Varies
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+void sched_note_start(FAR struct tcb_s *tcb)
+{
+  if (!sysview_isenabled())
+    {
+      return;
+    }
+
+  SEGGER_SYSVIEW_OnTaskCreate(tcb->pid);
+  sysview_send_taskinfo(tcb);
+}
+
+void sched_note_stop(FAR struct tcb_s *tcb)
+{
+  if (!sysview_isenabled())
+    {
+      return;
+    }
+
+  SEGGER_SYSVIEW_OnTaskTerminate(tcb->pid);
+}
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH
+void sched_note_suspend(FAR struct tcb_s *tcb)
+{
+  if (!sysview_isenabled())
+    {
+      return;
+    }
+
+  if (g_sysview.scpu[up_cpu_index()].in_isrcb == false)
+    {
+      SEGGER_SYSVIEW_OnTaskStopExec();
+    }
+}
+
+void sched_note_resume(FAR struct tcb_s *tcb)
+{
+  struct sysview_cpu_s *scpu;
+
+  if (!sysview_isenabled())
+    {
+      return;
+    }
+
+  scpu = &g_sysview.scpu[up_cpu_index()];
+
+  if (scpu->in_isrcb == false)
+    {
+#if CONFIG_SMP_NCPUS == 1
+      if (tcb->flink == NULL)
+        {
+          SEGGER_SYSVIEW_OnIdle();
+        }
+      else
+#endif
+        {
+          SEGGER_SYSVIEW_OnTaskStartExec(tcb->pid);
+        }
+    }
+  else
+    {
+      scpu->tcb = tcb;
+    }
+}
+#endif
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
+void sched_note_irqhandler(int irq, FAR void *handler, bool enter)
+{
+  struct sysview_cpu_s *scpu;
+
+  if (!sysview_isenabled_irq(irq, enter))
+    {
+      return;
+    }
+
+  scpu = &g_sysview.scpu[up_cpu_index()];
+
+  if (enter)
+    {
+      if (g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE)

Review comment:
       ```suggestion
         if ((g_sysview.mode.flag & NOTE_FILTER_MODE_FLAG_ENABLE) != 0)
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] anchao commented on a change in pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
anchao commented on a change in pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327#discussion_r794502724



##########
File path: drivers/segger/config/Global.h
##########
@@ -0,0 +1,45 @@
+/****************************************************************************
+ * drivers/segger/config/Global.h

Review comment:
       drivers/segger/config dir is not use for nuttx, this is overwrite include path for system view:
   
   https://github.com/SEGGERMicro/SystemView/blob/master/SEGGER/SEGGER.h#L59
   https://github.com/SEGGERMicro/SystemView/blob/master/Config/Global.h




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] acassis commented on pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
acassis commented on pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327#issuecomment-1021158119


   Thank you @anchao I just saw you closed this PR, did you find some issue? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] acassis commented on pull request #5327: note/sysview: add Segger System View support

Posted by GitBox <gi...@apache.org>.
acassis commented on pull request #5327:
URL: https://github.com/apache/incubator-nuttx/pull/5327#issuecomment-1020290029


   hi @anchao did you test it on more common boards like stm32f4discovery? Unfortunately Segger doesn't support ESP32 yet!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org