Documentation: nsh: document the top command#19399
Merged
Merged
Conversation
linguini1
previously approved these changes
Jul 11, 2026
xiaoxiang781216
previously approved these changes
Jul 11, 2026
The top command was added to nshlib in 2024 but was never documented. Add a section to the NSH commands page covering syntax, options, example output and configuration dependencies, including the Linux-like summary header. Also enable the command in the linum-stm32h753bi:nsh config: procfs, CPU load measurement, stack coloration and task names, so that top and ps are fully functional out of the box. This requires a dedicated interrupt stack and larger IDLE/init task stacks: with SCHED_CPULOAD the per-tick accounting runs in interrupt context, and with ARCH_INTERRUPTSTACK=0 it lands on the stack of the interrupted task, overflowing the 1 KiB IDLE stack and corrupting the adjacent heap. Also add the VT100 escape sequences used by the top command screen refresh as string literals in include/nuttx/vt100.h (VT100_STR_*), next to the existing VT100_FMT_* definitions. Tested on hardware. Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
66525cc to
1e2f9cb
Compare
acassis
approved these changes
Jul 11, 2026
xiaoxiang781216
approved these changes
Jul 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The nsh
topcommand exists since 2024 but was never documented.topsection to the NSH commands documentation page(
Documentation/applications/nsh/commands.rst): syntax, options,example output and configuration dependencies.
topusage example to the linum-stm32h753bi boarddocumentation.
SCHED_CPULOAD,STACK_COLORATIONandTASK_NAME_SIZE, sotopand
psare fully functional out of the box. This also configures adedicated interrupt stack and enlarges the IDLE/init task stacks:
with
SCHED_CPULOADthe per-tick accounting runs in interruptcontext, and with
ARCH_INTERRUPTSTACK=0it lands on the stack ofthe interrupted task, overflowing the 1 KiB IDLE stack (~60% used at
rest) and corrupting the adjacent heap.
Companion PR (nshlib improvements shown in the examples):
apache/nuttx-apps#3628
Impact
topcommand is now discoverable in the documentation;linum-stm32h753bi:nsh users get
top/psworking out of the box.CPU load measurement to one board configuration (flash: ~186 KB,
1.7% SRAM on a 2 MB / 1 MB part).
Testing
sphinx-build -b htmlcompletes with no warnings onthe changed pages; new section renders at
applications/nsh/commands.html#cmdtop.tools/configure.sh linum-stm32h753bi:nshfrom distcleanSCHED_CPULOADon this board causes heap corruption and random asserts ("Stack
pointer is not within the stack"), reproduced and fixed on hardware.
tools/checkpatch.sh -g HEAD~1..HEAD: all checks pass