Skip to content

Conversation

@Kaben123
Copy link

Add trace points to record transitions of g_nx_initstate and to mark board early/late initialization boundaries. Also add trace marks for RESET and PANIC to improve boot-time diagnostics and failure analysis.

Note: Please adhere to Contributing Guidelines.

Summary

This patch introduces trace points at key moments during system startup and board-level initialization to improve boot-time diagnostics and tracing. It records transitions of g_nx_initstate, adds begin/end trace markers around board initialization, and marks important events such as RESET and PANIC.

Motivation

Tracing the system initialization sequence helps debugging bring-up and failure analysis on multi-core and board bring-up scenarios. Recording g_nx_initstate transitions and board init boundaries provides better visibility into the boot sequence.

What was changed

  • boards/boardctl.c

    • Include <nuttx/trace.h> and mark RESET when board reset is requested. Set g_nx_initstate = OSINIT_RESET before calling reboot notifier.
  • sched/init/nx_bringup.c

    • Wrap board_late_initialize() with boards_trace_begin() / boards_trace_end().
  • sched/init/nx_start.c

    • Emit sched_trace_mark() calls when updating g_nx_initstate for states: BOOT, TASKLISTS, MEMORY, HARDWARE, OSREADY, IDLELOOP.
    • Wrap board_early_initialize() with boards_trace_begin() / boards_trace_end().
  • sched/misc/assert.c

    • Include <nuttx/trace.h> and emit a PANIC trace mark when entering the panic state.

Impact

  • Functional behavior: No functional changes to logic; only additional trace calls. Should be safe when tracing is disabled.
  • API/ABI: No public API or ABI changes.
  • Risks: Minimal. Trace calls add negligible overhead when enabled.

Testing

  • Built and booted on target device used during development.
  • Observed trace markers during normal boot and when triggering reset/panic.
  • Example observed marks: RESET, BOOT, TASKLISTS, MEMORY, HARDWARE, OSREADY, IDLELOOP, PANIC.

@github-actions github-actions bot added Area: OS Components OS Components issues Size: S The size of the change in this PR is small labels Jan 22, 2026
Add trace points to record transitions of g_nx_initstate and to mark
board early/late initialization boundaries. Also add trace marks for
RESET and PANIC to improve boot-time diagnostics and failure analysis.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
@Kaben123 Kaben123 force-pushed the improve-trace-bringup branch from 8c36f84 to e006c34 Compare January 23, 2026 02:07
Copy link
Contributor

@acassis acassis left a comment

Choose a reason for hiding this comment

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

@Kaben123 Could you please update the https://nuttx.apache.org/docs/latest/debugging/tasktraceuser.html Documentation to include comments about system startup and board initialization

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: OS Components OS Components issues Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants