Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions soc/alif/ensemble/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ config RTSS_HE
select HAS_ALIF_SE_SERVICES
select HAS_PM
select HAS_POWEROFF
select HAS_SEGGER_RTT
select CORTEX_M_SYSTICK_RESET_BY_LPM if (PM && CORTEX_M_SYSTICK && \
!CORTEX_M_SYSTICK_LPM_TIMER_NONE)

Expand All @@ -49,6 +50,7 @@ config RTSS_HP
select HAS_ALIF_SE_SERVICES
select HAS_PM
select HAS_POWEROFF
select HAS_SEGGER_RTT
select CORTEX_M_SYSTICK_RESET_BY_LPM if (PM && CORTEX_M_SYSTICK && \
!CORTEX_M_SYSTICK_LPM_TIMER_NONE)

Expand Down
39 changes: 39 additions & 0 deletions subsys/tracing/sysview/sysview_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include <zephyr/kernel.h>
#include <SEGGER_SYSVIEW.h>
#include <ksched.h>
#ifdef CONFIG_SYMTAB
#include <zephyr/debug/symtab.h>
#include <zephyr/sw_isr_table.h>
#endif

extern const SEGGER_SYSVIEW_OS_API SYSVIEW_X_OS_TraceAPI;

Expand Down Expand Up @@ -46,13 +50,48 @@ void sys_trace_thread_info(struct k_thread *thread)
SEGGER_SYSVIEW_SendTaskInfo(&Info);
}

/**
* @brief User-defined SystemView system description hook.
*
* Override this weak function in your application to inject additional
* SEGGER_SYSVIEW_SendSysDesc() calls — e.g. IRQ name mappings:
*
* void sysview_app_send_sys_desc(void) {
* SEGGER_SYSVIEW_SendSysDesc("I#15=SysTick");
* }
*
* The function is called at the end of every cbSendSystemDesc() invocation,
* including reconnects from the SystemView host.
*/
__weak void sysview_app_send_sys_desc(void)
{
}


static void cbSendSystemDesc(void)
{
SEGGER_SYSVIEW_SendSysDesc("N=" CONFIG_SEGGER_SYSVIEW_APP_NAME);
SEGGER_SYSVIEW_SendSysDesc("D=" CONFIG_BOARD " "
CONFIG_SOC_FAMILY " " CONFIG_ARCH);
SEGGER_SYSVIEW_SendSysDesc("O=Zephyr");

#ifdef CONFIG_SYMTAB
char isr_desc[SEGGER_SYSVIEW_MAX_STRING_LEN];
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Zephyr, using snprintk() (and sizeof(isr_desc) / ARRAY_SIZE(isr_desc) for the buffer size) is typically preferred over snprintf() to avoid pulling in heavier libc formatting and to match common Zephyr patterns in constrained builds. This also removes dependence on SEGGER_SYSVIEW_MAX_STRING_LEN matching the actual buffer size.

Copilot uses AI. Check for mistakes.

for (int idx = 0; idx < IRQ_TABLE_SIZE; idx++) {
const struct _isr_table_entry *entry = &_sw_isr_table[idx];

if ((entry->isr == z_irq_spurious) || (entry->isr == NULL)) {
continue;
}
const char *name = symtab_find_symbol_name((uintptr_t)entry->isr, NULL);

Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

symtab_find_symbol_name() may return NULL when no symbol is found. Passing a NULL pointer to %s is not portable and can crash on some C libraries/targets. Add a fallback (e.g., skip emitting the mapping, or use a placeholder like "unknown") when name == NULL.

Suggested change
if (name == NULL) {
name = "unknown";
}

Copilot uses AI. Check for mistakes.
snprintf(isr_desc, SEGGER_SYSVIEW_MAX_STRING_LEN, "I#%d=%s", idx + 16, name);
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idx + 16 IRQ number offset is hard-coded and will produce incorrect IRQ numbering on architectures (or configurations) where the external IRQ vector base is not 16. Use the platform/configured IRQ vector base (e.g., CONFIG_GEN_IRQ_START_VECTOR on platforms that provide it, or an appropriate Zephyr/arch macro) instead of a literal 16 so the mapping matches the real vector numbering.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Zephyr, using snprintk() (and sizeof(isr_desc) / ARRAY_SIZE(isr_desc) for the buffer size) is typically preferred over snprintf() to avoid pulling in heavier libc formatting and to match common Zephyr patterns in constrained builds. This also removes dependence on SEGGER_SYSVIEW_MAX_STRING_LEN matching the actual buffer size.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to move to snprintk but that would diverge the code from the upstream zephyr. Code owners shall decide.


SEGGER_SYSVIEW_SendSysDesc(isr_desc);
}
#endif
sysview_app_send_sys_desc();
}

static void send_task_list_cb(void)
Expand Down