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.

On the EFZ-ESP32S3

Swap the target for efz_esp32s3/esp32s3/procpu โ€” everything else is the same. The overlay file is then boards/efz_esp32s3_esp32s3_procpu.overlay.



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. ๐Ÿ’ช