Hello World
The fastest way to get started is to use the sample that already ships with Zephyr. You'll copy it out of the Zephyr tree, build it, and flash it to your board.
Your Zephyr workspace can be anywhere on your machine. Throughout this guide we use /your/workspace/path as a placeholder — replace it with wherever you put your workspace (e.g. /home/john/zephyr_ws on Linux, /Users/john/zephyr_ws on macOS, or D:\projects\zephyr_ws on Windows).
Step 1 — Open your terminal
- 🐧 Linux
- 🍎 macOS
- 🪟 Windows
Open your preferred terminal emulator — GNOME Terminal, Konsole, Alacritty, or any other.
Activate your virtual environment:
source /your/workspace/path/.venv/bin/activate
Open Terminal (/Applications/Utilities/Terminal.app) or iTerm2 if you have it installed.
Activate your virtual environment:
source /your/workspace/path/.venv/bin/activate
Use PowerShell — not cmd.exe. Open it by pressing Win + X and selecting Terminal or Windows PowerShell.
Activate your virtual environment:
D:\your\workspace\path\.venv\Scripts\Activate.ps1
Step 2 — Copy the sample
Zephyr ships with a samples/ folder full of ready-to-build examples. The Hello World sample lives at:
/your/workspace/path/zephyr/samples/hello_world/
Copy it into a devzone/ folder — this is where you'll keep all your personal projects, separate from the Zephyr source tree:
- 🐧 Linux
- 🍎 macOS
- 🪟 Windows
mkdir -p /your/workspace/path/devzone
cp -r /your/workspace/path/zephyr/samples/hello_world /your/workspace/path/devzone/hello_world
Example (if your workspace is at /home/john/zephyr_ws):
mkdir -p /home/john/zephyr_ws/devzone
cp -r /home/john/zephyr_ws/zephyr/samples/hello_world /home/john/zephyr_ws/devzone/hello_world
mkdir -p /your/workspace/path/devzone
cp -r /your/workspace/path/zephyr/samples/hello_world /your/workspace/path/devzone/hello_world
Example (if your workspace is at /Users/john/zephyr_ws):
mkdir -p /Users/john/zephyr_ws/devzone
cp -r /Users/john/zephyr_ws/zephyr/samples/hello_world /Users/john/zephyr_ws/devzone/hello_world
New-Item -ItemType Directory -Force -Path "D:\your\workspace\path\devzone"
Copy-Item -Recurse "D:\your\workspace\path\zephyr\samples\hello_world" "D:\your\workspace\path\devzone\hello_world"
Example (if your workspace is at D:\projects\zephyr_ws):
New-Item -ItemType Directory -Force -Path "D:\projects\zephyr_ws\devzone"
Copy-Item -Recurse "D:\projects\zephyr_ws\zephyr\samples\hello_world" "D:\projects\zephyr_ws\devzone\hello_world"
Building directly inside the Zephyr tree works, but keeping your apps in a separate devzone/ folder keeps things clean and lets you track your own projects in a separate git repo.
Your devzone/hello_world/ folder should now look like this:
devzone/hello_world/
├── CMakeLists.txt
├── prj.conf
└── src/
└── main.c
Step 3 — Look at the files
CMakeLists.txt
cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(hello_world)
target_sources(app PRIVATE src/main.c)
The find_package(Zephyr ...) line connects your app to the Zephyr build system.
West sets ZEPHYR_BASE automatically — you don't need to set it yourself.
prj.conf
# Nothing needed for Hello World
# Add CONFIG_* symbols here to enable drivers and subsystems
src/main.c
#include <stdio.h>
int main(void)
{
printf("Hello World! %s\n", CONFIG_BOARD);
return 0;
}
CONFIG_BOARD expands to the board name you pass with -b — so building for esp32s3_devkitc prints Hello World! esp32s3_devkitc.
Step 4 — Build and flash
Navigate to your copied sample and build it. Replace <your-board> with your board ID (e.g. esp32s3_devkitc/esp32s3/procpu, nrf52840dk/nrf52840):
- 🐧 Linux
- 🍎 macOS
- 🪟 Windows
cd /your/workspace/path/devzone/hello_world
west build -b <your-board> .
west flash
cd /your/workspace/path/devzone/hello_world
west build -b <your-board> .
west flash
cd D:\your\workspace\path\devzone\hello_world
west build -b <your-board> .
west flash
Expected output on the serial console:
*** Booting Zephyr OS build v4.4.0 ***
Hello World! esp32s3_devkitc
Step 5 — Read the output with Serial Monitor
After flashing, open Serial Monitor in VS Code to see the output from your board:
- Go to
Terminal → New Terminalin VS Code - The Serial Monitor tab will appear at the bottom panel
- Select your board's port (e.g.
/dev/ttyUSB0on Linux,/dev/cu.usbserial-*on macOS,COM3on Windows) - Set the baud rate to 115200
- Click Start Monitoring
You should see:
*** Booting Zephyr OS build v4.4.0 ***
Hello World! esp32s3_devkitc
Follow the Serial Monitor setup guide in the Environment Setup page first.
What west build actually does
- Reads
CMakeLists.txtand findsfind_package(Zephyr) - Merges all Kconfig files into
build/zephyr/.config - Compiles the final devicetree into
build/zephyr/zephyr.dts - Compiles all source files and links
zephyr.elf - Produces
zephyr.bin/zephyr.hexready for flashing
The build/ directory is reusable. Run west build again after changing main.c and only changed files are recompiled. Use west build -p always to force a clean rebuild.