chsh-sk-ncs-3-dev-memopt

Analyzes and reduces RAM and Flash usage in Nordic NCS firmware projects.

1|Updated Jan 30, 2026
One-click install
npx skills add https://github.com/chshzh/claude --skill chsh-sk-ncs-3-dev-memopt-chshzh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: chsh-sk-ncs-3-dev-memopt
Source: https://github.com/chshzh/claude/tree/main/skills/chsh-sk-ncs-3-dev-memopt
Command: npx skills add https://github.com/chshzh/claude --skill chsh-sk-ncs-3-dev-memopt-chshzh

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Embedded firmware on Nordic nRF devices often ships with oversized thread stacks and heaps, or worse, suffers stack overflows, heap exhaustion, and Flash overflow build failures. This Skill provides a measure-first workflow to size memory correctly in NCS/Zephyr applications. ## Core Features & Use Cases - Measured stack and heap sizing: Captures thread stack watermarks via Thread Analyzer, ZView over SWD, or the zego memonitor brick, then applies headroom formulas (e.g. floor(peak / 0.8)) to update prj.conf with documented rationale. - Flash and RAM reduction: Applies Kconfig optimizations such as CONFIG_SIZE_OPTIMIZATIONS, CONFIG_LTO, and logging/shell removal, verified with rom_report, ram_report, and puncover. - Structured reporting: Updates docs/dev-specs/3-memopt.md using a report template, consuming validation report watermarks when available. - Use Case: After a validation run captures worst-case memory peaks on nRF7002DK and nRF54LM20DK boards, use this Skill to compute new stack and heap sizes, apply them to prj.conf, and document the changes. ## Quick Start Ask Claude to analyze memory usage on your nRF board build and optimize the thread stack and heap sizes in prj.conf.

Frequently Asked Questions about chsh-sk-ncs-3-dev-memopt

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce memory usage in an nRF Connect SDK project?

Measure first with Thread Analyzer and the zego memonitor brick, then apply sizing formulas: floor(max_usage / 0.9) for thread stacks and floor(peak / 0.8) for heaps. For Flash, enable CONFIG_SIZE_OPTIMIZATIONS and CONFIG_LTO, disable logging and shell, and build with MinSizeRel.

How to measure thread stack usage in Zephyr NCS applications?

Enable CONFIG_THREAD_ANALYZER with CONFIG_THREAD_ANALYZER_AUTO and CONFIG_THREAD_NAME, flash the board, and exercise all code paths while reading UART output. Alternatively use ZView over SWD with west zview live to watch stack watermarks without on-target code.

What is the minimum heap size for NCS Wi-Fi applications?

Wi-Fi apps require at least 64 KB base heap (CONFIG_HEAP_MEM_POOL_SIZE), with 80 KB recommended, totaling roughly 125 KB after automatic subsystem add-ons. Going below 64 KB causes WPA supplicant malloc failures during TLS handshakes.

Why does my NCS build fail with region FLASH overflowed?

Flash overflow happens when the image exceeds its partition. Fix it by enabling CONFIG_SIZE_OPTIMIZATIONS, disabling CONFIG_LOG, CONFIG_ASSERT, CONFIG_SHELL, and CONFIG_PRINTK, and building with -DCMAKE_BUILD_TYPE=MinSizeRel. Check partition fit with west build -t partition_manager_report.

Can I use ZView to monitor heap usage without UART logging?

Yes, ZView reads thread stack watermarks and heap usage over SWD via J-Link with no UART, RTT, or on-target code. Run west zview live with the board's ELF file and J-Link target, or use west zview dump --json for scripted readouts.

When should I not shrink NET_RX_STACK_SIZE and NET_TX_STACK_SIZE?

Do not apply the measured sizing formula to network I/O queues, because measurements reflect steady-state only and fragmented packet bursts can spike stack usage. Keep NET_RX_STACK_SIZE and NET_TX_STACK_SIZE at the 2048 B Zephyr default unless explicitly profiled under load.