Skip to main content

The Build System

Zephyr uses CMake as its build system generator and Ninja as the build tool. You almost never write CMake directly — West handles it for you.



Build output files

After west build, everything lands in the build/zephyr/ directory:

FileWhat it's for
zephyr.elfELF binary with debug symbols — used by GDB
zephyr.hexIntel HEX format for flashing
zephyr.binRaw binary
zephyr.dtsMerged, final devicetree — read this to debug DT issues
.configFinal resolved Kconfig — read this to debug config issues
zephyr.mapLinker map — shows flash and RAM usage per symbol


Checking memory usage

After a build, check how much flash and RAM your firmware uses:

west build -b esp32s3_devkitc/esp32s3/procpu . && \
cat build/zephyr/zephyr.stat

Or with the size tool:

arm-zephyr-eabi-size build/zephyr/zephyr.elf

Example output:

text data bss dec hex filename
42312 312 6248 48872 bf08 build/zephyr/zephyr.elf
FieldMeaning
textFlash used by code and read-only data
dataRAM used by initialized variables (also stored in flash)
bssRAM used by zero-initialized variables


Useful build flags

# Force a full clean rebuild
west build --pristine

# Build with a custom overlay file
west build -b esp32s3_devkitc/esp32s3/procpu . -- \
-DDTC_OVERLAY_FILE=boards/esp32s3_devkitc_esp32s3_procpu.overlay

# Override a Kconfig value without editing prj.conf
west build -b esp32s3_devkitc/esp32s3/procpu . -- \
-DCONFIG_LOG_DEFAULT_LEVEL=4

# Build with verbose output (see every compiler command)
west build -b esp32s3_devkitc/esp32s3/procpu . -- -DCMAKE_VERBOSE_MAKEFILE=ON
note

-- separates west build arguments from CMake arguments. Everything after -- is passed directly to CMake.



Build-time vs. runtime errors

Error typeWhen it happensHow to debug
Kconfig errorwest build failsCheck the depends on chain in the driver's Kconfig file
DTS errorwest build failsRead build/zephyr/zephyr.dts after fixing
Linker errorwest build failsUsually a missing CONFIG_ or wrong target_sources()
Runtime panicBoard crashes after flashUse Serial Monitor or west debug + GDB
Build failing with a cryptic error?

The first thing to check is always build/zephyr/.config (Kconfig) and build/zephyr/zephyr.dts (devicetree). The build system writes these intermediate files before compilation — they show exactly what Zephyr assembled from your project.



🎉 You're ready!

Zephyr RTOS

Welcome to Zephyr RTOS 🚀

You've just completed the full embedded development loop.
From zero to firmware running on real hardware — that's no small thing.

Here's what you accomplished:

✅ Set up a cross-platform Zephyr development environment
✅ Installed west and initialized a workspace with Zephyr v4.4.0
✅ Built and flashed your first firmware binary
✅ Read live output from your board over serial


What's next — the real Zephyr:

🌳
Devicetree

Describe your hardware in code. The heart of Zephyr.

⚙️
Kconfig

Control exactly what gets compiled into your firmware.

🔌
Drivers & Peripherals

GPIO, I2C, SPI, UART, BLE — all with one unified API.

🧵
Threads & RTOS

Semaphores, message queues, timers — real-time done right.

Every embedded engineer who works with Zephyr started exactly where you are right now. The tools are set up, the workspace is ready — now go build something real. 💪