native-sim
npx machina-cli add skill beriberikix/zephyr-agent-skills/native-sim --openclawZephyr Native Simulation
Develop, test, and debug Zephyr applications with the speed and convenience of your host machine.
Core Workflows
1. Simulation Basics
Understand when to use native_sim vs. QEMU and how to map host resources.
- Reference: simulation_basics.md
- Key Tools:
west build -b native_sim.
2. Host-Side Debugging
Use professional host tools to find the most elusive bugs.
- Reference: debugging.md
- Key Tools:
gdb,valgrind,gprof,pcap.
3. Automated Testing (CI/CD)
The foundation of modern firmware development.
- Reference: See the
testing-debuggingskill (Phase 3) for comprehensive testing workflows. - Key Tools:
twister -p native_sim.
Quick Start
# Build for host
west build -b native_sim samples/hello_world
# Run the app
./build/zephyr/zephyr.exe
# Debug with GDB
west debug
Resources
- References:
simulation_basics.md: Architectural overview and usage patterns.debugging.md: GDB, Valgrind, and profiling guide.
Source
git clone https://github.com/beriberikix/zephyr-agent-skills/blob/main/skills/native-sim/SKILL.mdView on GitHub Overview
Develop, test, and debug Zephyr apps with the speed of your host machine. native_sim supports building for Linux, macOS, and Windows, automated testing, host-side debugging, and host-target integration. Use it to iterate application logic without hardware or complex CI/CD setup.
How This Skill Works
Zephyr native_sim runs the target entirely on the host. Build with west build -b native_sim, run the app with the host executable (zephyr.exe on Windows), and debug via west debug using GDB. For testing, Twister can be used with native_sim to mirror CI/CD workflows and validate behavior on the host environment, with tools like gdb, valgrind, gprof, and pcap available for debugging and profiling.
When to Use It
- Iterate application logic quickly without hardware
- Prepare local CI/CD style tests before hardware access
- Debug Zephyr code using host tools (GDB, Valgrind, profiling)
- Validate performance and resource usage across Linux/macOS/Windows
- Compare host-versus-target behavior by mapping host workloads to the simulated target
Quick Start
- Step 1: west build -b native_sim samples/hello_world
- Step 2: Run the app: ./build/zephyr/zephyr.exe
- Step 3: Debug with GDB: west debug
Best Practices
- Use west build -b native_sim to ensure reproducible host builds
- Prefer west debug for stepwise debugging with GDB
- Run Valgrind, gprof, and pcap to uncover memory, performance, and I/O issues
- Incorporate twister -p native_sim for automated tests to mirror CI workflows
- Consult references/simulation_basics.md and debugging.md for resource mapping and workflows
Example Use Cases
- Building and running a hello_world sample on native_sim
- Debugging a multithread issue with GDB in host mode
- Memory leak check using Valgrind on the host simulation
- Profiling with gprof during a representative workload
- Running a local Twister CI-like test for a Zephyr app with native_sim