zephyr icon indicating copy to clipboard operation
zephyr copied to clipboard

Board-specific overlays defined in a module's shield directory are not found

Open cdwilson opened this issue 10 months ago • 10 comments

Describe the bug This issue is similar to https://github.com/zephyrproject-rtos/zephyr/issues/67227 but has to do with board-specific overlays defined within a shield directory in a Zephyr module.

Zephyr allows board-specific overlays & Kconfig to be defined for a particular shield by adding a boards/ directory within the shield's directory, e.g. boards/shields/adafruit_neopixel_grid_bff/boards/:

boards/shields/adafruit_neopixel_grid_bff/boards/
├── adafruit_qt_py_rp2040.conf
└── adafruit_qt_py_rp2040.overlay

However, if a boards/shields/ directory is defined in a Zephyr module, the board-specific overlays within the shield's boards/ directory are not found:

<zephyr-workspace>/modules/lib/golioth-zephyr-boards/
├── boards
│   ├── ...
│   └── shields
│       └── arduino_uno_click
│           └── boards
│               ├── nrf9160dk_nrf9160.overlay <-- not found
│               ├── nrf9160dk_nrf9160_common.dtsi <-- not found
│               └── nrf9160dk_nrf9160_ns.overlay <-- not found
└── zephyr
    └── module.yml

To Reproduce

I have prepared two example branches in my Zephyr fork that can be used to reproduce this using a mikroe_weather_click shield installed on an arduino_uno_click shield installed on the nRF9160dk board.

IMG_3444

After checking out each branch below, the firmware can be built using the following command:

west build -p -b nrf9160dk/nrf9160/ns samples/sensor/bme280 -- -DSHIELD="arduino_uno_click mikroe_weather_click"

Example where overlays are correctly found

The first branch places the board-specific overlays for the arduino_uno_click shield in the Zephyr tree where they are correctly found by the build system:

https://github.com/cgnd/zephyr/tree/cdwilson/github-issues/zephyr-in-tree-shield-board-overlays/boards/shields/arduino_uno_click/boards

In the build output, the following shield overlays are found:

...
-- Found devicetree overlay: <redacted>/zephyr/boards/shields/arduino_uno_click/arduino_uno_click.overlay
-- Found devicetree overlay: <redacted>/zephyr/boards/shields/arduino_uno_click/boards/nrf9160dk_nrf9160.overlay
-- Found devicetree overlay: <redacted>/zephyr/boards/shields/arduino_uno_click/boards/nrf9160dk_nrf9160_ns.overlay
-- Found devicetree overlay: <redacted>/zephyr/boards/shields/mikroe_weather_click/mikroe_weather_click.overlay
...

Example where overlays are NOT correctly found

The second branch pulls in a 3rd-party Zephyr module in west.yml that contains the exact same board-specific overlays for the arduino_uno_click shield, but located within the module's boards/shields directory:

https://github.com/cgnd/zephyr/blob/cdwilson/github-issues/zephyr-module-shield-board-overlays/west.yml#L32-L35

In the build output, the following shield overlays are found:

...
-- Found devicetree overlay: <redacted>/zephyr/boards/shields/arduino_uno_click/arduino_uno_click.overlay
-- Found devicetree overlay: <redacted>/zephyr/boards/shields/mikroe_weather_click/mikroe_weather_click.overlay
...

In this 2nd example, the boards/nrf9160dk_nrf9160*.overlay files defined in the module are not found.

Expected behavior I expect that the shields/ directory of a Zephyr module are searched exactly like the shields/ directory in the Zephyr tree when searching for overlay files. In the example above, I expect that overlays in boards/shields/<shield>/boards/*.overlay are found during build.

Impact Current workaround is to add the overlay code in the app-specific board overlay instead of in the Zephyr module.

Environment (please complete the following information):

  • OS: macOS 14.4.1
  • Toolchain Zephyr SDK: zephyr-sdk-0.16.5-1
  • Commit SHA or Version used: f643f3a6cf6bafd6338c090f4413e34eb3ed806c

cdwilson avatar Apr 04 '24 22:04 cdwilson