Skip to content
systemcoding.dev
RTOS

Build for a board with a pristine rebuild using west build -p always

Rebuild a Zephyr app from scratch for one board with west build -p always, which deletes the build directory and reruns CMake, on Zephyr 4.0.

1 min read
Summarize in AI

Stale CMake and Kconfig state in the build folder is the usual cause of "I changed the board and nothing happened" in Zephyr. west build -p always makes the build directory pristine, deleting its contents, before configuring again. By default west build does not check whether the directory needs it, so a board change or a moved source tree can silently reuse old settings. Zephyr 4.0 documents the option as --pristine or -p.

Text
west build -p always -b nucleo_f401re samples/basic/blinky

A bare -p means the same as -p always. The value auto asks west to decide, and it re-creates the directory only in a few obvious cases, so use always when you need certainty and the default when iterating, because a pristine build recompiles the whole kernel and takes noticeably longer. The flag also throws away everything in the directory, including any Kconfig change made in menuconfig that was never copied to a configuration file. To keep a configuration, put it in prj.conf first. The behaviour is described in the Zephyr 4.0 west build documentation.

Share

More snippets

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.