-
Notifications
You must be signed in to change notification settings - Fork 44
Feature/segger rtt sysview #449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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; | ||||||||||||
|
|
||||||||||||
|
|
@@ -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]; | ||||||||||||
|
|
||||||||||||
| 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); | ||||||||||||
|
|
||||||||||||
|
||||||||||||
| if (name == NULL) { | |
| name = "unknown"; | |
| } |
Copilot
AI
Apr 1, 2026
There was a problem hiding this comment.
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
AI
Apr 1, 2026
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Zephyr, using
snprintk()(andsizeof(isr_desc)/ARRAY_SIZE(isr_desc)for the buffer size) is typically preferred oversnprintf()to avoid pulling in heavier libc formatting and to match common Zephyr patterns in constrained builds. This also removes dependence onSEGGER_SYSVIEW_MAX_STRING_LENmatching the actual buffer size.