cmake: dts: look for allowed dts overlays file presence in board/

Hardware model v2 allows the usage of <board>_<revision>.overlay and any
valid <board>_<identifier>_<revision>.overlay dts overlays in the board/
directory but CMake was only looking for the most specific
<board>_<identifier>_<revision>.overlay overlay file.

This commit allows CMake to look for the presence of any allowed overlay
file to fix this issue.

Tested by building the hello_world sample with the Olimex board
lora_stm32wl_devkit revision C.

The following line wasn't appearing before in build log and now does:
"-- Found devicetree overlay: <path>/olimex_lora_stm32wl_devkit_C.overlay"

Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
This commit is contained in:
Johan Lafon 2024-03-05 13:47:47 +01:00 committed by David Leach
commit 69648c17d7

View file

@ -133,16 +133,18 @@ if(NOT DEFINED DTS_SOURCE)
endif() endif()
if(EXISTS ${DTS_SOURCE}) if(EXISTS ${DTS_SOURCE})
# We found a devicetree. Check for a board revision overlay. # We found a devicetree. Append all relevant dts overlays we can find...
if(DEFINED BOARD_REVISION) zephyr_file(CONF_FILES ${BOARD_DIR} DTS DTS_SOURCE)
zephyr_build_string(dts_board_string BOARD ${BOARD}
BOARD_IDENTIFIER ${BOARD_IDENTIFIER} zephyr_file(
BOARD_REVISION ${BOARD_REVISION} CONF_FILES ${BOARD_DIR}
) DTS no_rev_suffix_dts_board_overlays
if(EXISTS ${BOARD_DIR}/${dts_board_string}.overlay) BOARD ${BOARD}
list(APPEND DTS_SOURCE ${BOARD_DIR}/${dts_board_string}.overlay) BOARD_IDENTIFIER ${BOARD_IDENTIFIER}
endif() )
endif()
# ...but remove the ones that do not include the revision suffix
list(REMOVE_ITEM DTS_SOURCE ${no_rev_suffix_dts_board_overlays})
else() else()
# If we don't have a devicetree, provide an empty stub # If we don't have a devicetree, provide an empty stub
set(DTS_SOURCE ${ZEPHYR_BASE}/boards/common/stub.dts) set(DTS_SOURCE ${ZEPHYR_BASE}/boards/common/stub.dts)