Skip to content

Repository files navigation

#initial build:
west build -p always -b nrf52840dk/nrf52840 --no-sysbuild . 

#further builds:
west build -b nrf52840dk/nrf52840 --no-sysbuild .   

#faster secondary builds:
west build -b nrf52840dk/nrf52840 --no-sysbuild --pristine=auto .


python collect_zephyr_deps.py --build build --out copilot_context --kinds headers,sources --also-copy-compile-commands 



Board Settings:


Bootloader:

You must also flash MCUboot itself to your board (the bootloader app).

Location: ncs/bootloader/mcuboot/boot/zephyr/

Build it with west:

west build -b nrf52840dk_nrf52840 ncs/bootloader/mcuboot/boot/zephyr
west flash


Then build your app with CONFIG_BOOTLOADER_MCUBOOT=y.

Sign it with:

west sign -t imgtool -- --key bootloader/mcuboot/root-rsa-2048.pem
west flash


When you now reset the board, MCUboot runs first, validates your app, then jumps to it.


NEED TO DO:
1. Implement LED connection (ILI9341 SPI and peripheral GPIOs) on .dts file




**********************************************************************************













Why West Builds Feel Slow

When you run:

west build -b nrf52840dk_nrf52840


Zephyr uses CMake + Ninja, which:

Generates a build directory (build/) with dependency graphs.

Rebuilds files if their sources or any dependent CMake inputs changed.

Relinks the full ELF every time, even for small source changes.

That “setup” phase can be slow because:

Zephyr includes hundreds of headers and generated config files.

Even small changes can trigger regeneration if Kconfig, CMakeLists.txt, or generated headers are touched.

On Windows, I/O overhead is significantly worse than on Linux.

⚡ The Good News: Incremental Builds Already Work (but…)

Ninja does already rebuild only changed .c files — if:

You run west build without -p=always or -p.

You don’t delete your build directory.

You don’t change your prj.conf, CMakeLists.txt, or board configuration.

So the key is:

# Initial build
west build -b nrf52840dk_nrf52840

# Later incremental build (only rebuilds changed sources)
west build


If you keep your build/ folder and your CMake configuration stable, only the modified .c files in src/ will be recompiled.

🧰 Practical Tips to Make It Much Faster
✅ 1. Use west build --pristine=auto

Instead of manually cleaning, use:

west build --pristine=auto


That keeps previous build artifacts unless your config or CMake files change.

✅ 2. Build only your app source

You can skip unnecessary regeneration of dependencies by separating your /src changes from system code.

Structure your app like:

project/
├─ CMakeLists.txt
├─ prj.conf
└─ src/
   ├─ main.c
   ├─ zrtos.c
   └─ ...


Then use Ninja directly for speed:

west build
ninja -C build app


ninja app will rebuild only your app sources and relink.

✅ 3. Use ccache

Zephyr supports ccache, which caches compiled objects — so rebuilds of unchanged code are instantaneous.

Install and enable it:

# Windows example (from Zephyr SDK)
set CCACHE_DIR=C:\ccache
set CCACHE_MAXSIZE=5G
west build -t menuconfig  # Optional, triggers cmake re-run

# In prj.conf (or environment)
export ZEPHYR_CCACHE=1


Then add to your environment or ~/.zephyrrc:

export ZEPHYR_CCACHE=1

✅ 4. Use --build-dir consistently

If you change build directories often, Zephyr will regenerate everything each time.
Stick with one:

west build -b nrf52840dk_nrf52840 -d build
west build -d build

✅ 5. Avoid unnecessary regeneration triggers

These cause full reconfigurations:

Editing CMakeLists.txt

Changing board or build type

Modifying Kconfig or overlay files

Running west build -p=always

Try to avoid these unless needed.

✅ 6. Parallel builds

Ninja automatically parallelizes, but you can set:

ninja -C build -j 8


to match your CPU cores.

🧠 Bonus: Pure /src rebuild shortcut

If you only want to rebuild your app source files and not regenerate anything else, you can run:

ninja -C build app


or even:

ninja -C build src/


That directly calls the Ninja target for your application code, skipping all CMake regeneration.

🚀 TL;DR — Best Fast-Build Recipe

Do an initial full build:

west build -b nrf52840dk_nrf52840


For later builds:

west build  # incremental


Use caching:

export ZEPHYR_CCACHE=1


When only source changes:

ninja -C build app

About

NRF52840 project for custom BLE + LoRA swarm network on Zephyr RTOS. ---Further Progress: Check Private Projects----

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages