
Zephyr build failures due to missing device tree overlays are a common frustration for developers working with custom boards or modifying existing board support. The error typically surfaces during the west build step, halting compilation with a cryptic “File not found” message. This article provides a systematic approach to diagnosing and resolving these overlay-related build failures, ensuring your Zephyr project compiles successfully.
When building a Zephyr application for a custom board, you might encounter an error like:
*** Error: File not found: 'boards/arm/stm32f4_discovery/stm32f4_discovery.overlay'
This error indicates that the Zephyr build system expects to find a device tree overlay file named stm32f4_discovery.overlay in the board directory, but the file is missing. The build fails during the devicetree compilation phase, preventing further progress.
Zephyr’s build process uses the device tree to describe hardware dependencies. Board definitions often include optional overlay files for hardware variations. When a board’s .dts file references an overlay via an #include directive, the build system mandates that the referenced file exists. If the file is absent, the build fails with a “File not found” error.
Common scenarios leading to missing overlays:
.dts file.Board.overlay vs board.overlay).Examine the full build output to pinpoint the exact missing file. The error message typically includes the searched path:
[devicetree] Error: File not found: 'stm32f4_discovery.overlay'
Note the filename and the directory Zephyr searched (usually the board directory under boards/).
Check if the overlay file exists in the expected location:
ls -la boards/arm/stm32f4_discovery/stm32f4_discovery.overlay
If the file is missing, create it. If it exists elsewhere, move it to the correct directory or adjust the #include path in the .dts file.
Create a basic overlay file if none exists. For example, stm32f4_discovery.overlay:
/ {};
This empty overlay satisfies the build requirement while allowing you to add specific configurations later.
Ensure the board’s .dts file includes the overlay. In stm32f4_discovery.dts, you should see:
#include "stm32f4_discovery.overlay"
If absent, add the line. If present but incorrect, fix the filename to match exactly.
Run west build again. The build should now proceed past the devicetree step. If additional errors appear, repeat the process for any other missing overlays.
Consider a scenario where you’re building for STM32F4 Discovery board and encountering a missing overlay error.
Build output shows:
[devicetree] Error: File not found: 'stm32f4_discovery.overlay'
$ ls boards/arm/stm32f4_discovery/stm32f4_discovery.dts stm32f4_discovery.h ...
The overlay file is indeed missing.
$ touch boards/arm/stm32f4_discovery/stm32f4_discovery.overlay
Check stm32f4_discovery.dts:
/* ... */#include "stm32f4_discovery.overlay"/* ... */
The include is present.
$ west build -b stm32f4_discovery samples/basic/blinky
The build now succeeds, progressing past the devicetree step.
The following diagram illustrates how Zephyr locates and includes device tree overlays during the build process:
+---------------------+ +---------------------+ +---------------------+| Board Definition | | Overlay File | | Build System || (stm32f4_discovery.| | (stm32f4_discovery.| | (devicetree.py) || dts) | | overlay) | | |+---------------------+ +---------------------+ +---------------------+| | || #include "stm32f4_discovery.overlay" | ||-------------------------->| || | || | File exists? ----------->| Yes| | | || | | v| | +---------------------+| | | Continue Build || | +---------------------+| | || | No || |<----------------------+| | Error: File not found || | |+-------------------------<-------------------------+
After adding the missing overlay:
west build..dts include accordingly./ { };) is sufficient to resolve the build error while allowing future customization.Quick Links
Legal Stuff





