Skip to content

Conversation

@nlebedenco
Copy link
Contributor

After #72857 the concept of board directory was expanded from a single path (BOARD_DIR) to a list of paths (BOARD_DIRECTORIES) which is taken into account in several places except when including pre_dt_board.cmake files. This patch moves the inclusion of pre_dt_board.cmake files into dts.cmake AFTER boards.cmake is included (so we can access BOARD_DIRECTORIES) but BEFORE pre_dt.cmake, which preserves the original inclusion order relative to pre DTC operations.

The original motivation of this patch was to address the practicality of defining board extensions that can re-use base board definitions.

In particular, one of the drawbacks of
#72857 is that board extensions are not really extending board definitions just the qualifier. There is still the need to create a DTS for each new board extension which is often a copy-and-paste of the base board DTS eventually with a few alterations. The problem is that except for toy examples, board DTS files are rarely self-contained and instead are composed of multiple dtsi includes using relative paths which then forces board extension files to either use hard coded paths to the base board directory OR recursively copy all included dtsi files from the base board directory into the board extension directory.

With this patch a board extension directory can define custom configuration steps like regular base boards can and then adjust CPP and DTC include search paths dynamically, for example with:

list(APPEND DTS_EXTRA_CPPFLAGS "-I${BOARD_DIR}")
list(APPEND EXTRA_DTC_FLAGS "-i${BOARD_DIR}")

After zephyrproject-rtos#72857 the concept
of board directory was expanded from a single path (BOARD_DIR) to a list
of paths (BOARD_DIRECTORIES) which is taken into account in several places
except when including `pre_dt_board.cmake` files. This patch moves the
inclusion of `pre_dt_board.cmake` files into `dts.cmake` AFTER
`boards.cmake` is included (so we can access `BOARD_DIRECTORIES`) but
BEFORE `pre_dt.cmake`, which preserves the original inclusion order
relative to pre DTC operations.

The original motivation of this patch was to address the practicality of
defining board extensions that can re-use base board definitions.

In particular, one of the drawbacks of
zephyrproject-rtos#72857 is that board
extensions are not really extending board definitions just the qualifier.
There is still the need to create a DTS for each new board extension which
is often a copy-and-paste of the base board DTS eventually with a few
alterations. The problem is that except for toy examples, board DTS files
are rarely self-contained and instead are composed of multiple dtsi
includes using relative paths which then forces board extension files to
either use hard coded paths to the base board directory
OR recursively copy all included dtsi files from the base board directory
into the board extension directory.

With this patch a board extension directory can define custom
configuration steps like regular base boards can and then adjust CPP and
DTC include search paths dynamically, for example with:
```
list(APPEND DTS_EXTRA_CPPFLAGS "-I${BOARD_DIR}")
list(APPEND EXTRA_DTC_FLAGS "-i${BOARD_DIR}")
```

Signed-off-by: Nicolas Lebedenco <[email protected]>
@sonarqubecloud
Copy link

@nlebedenco
Copy link
Contributor Author

Note that the same problem does not apply to Kconfig files because #72857
already took care of sourcing the base board files first and then the extension ones. So if we want to effectively inherit configurations from the base all we need to do is define the symbol of the base board we extended (qualified). For example, to extend nrf9160dk/nrf9160/ns we can have a board.yml like this

board:
  extend: nrf9160dk
  variants:
    - name: mymod
      qualifier: nrf9160/ns

And then in the same directory it is enough to have a Kconfig.nrf9160dk with:

config BOARD_NRF9160DK_NRF9160_NS
	def_bool y
	depends on BOARD_NRF9160DK_NRF9160_NS_MYMOD
	help
	  Kconfig symbol identifying the extended board.

Copy link
Contributor

@tejlmand tejlmand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look at #87821
And ensure the comments in that PR are not applicable in this PR, as the two PRs are very similar, #87821 (review)

Comment on lines +10 to +11
foreach(dir IN LISTS BOARD_DIRECTORIES)
include("${dir}/pre_dt_board.cmake" OPTIONAL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this suffers the same issue as described here: #87821 (comment)

@github-actions
Copy link

github-actions bot commented Nov 5, 2025

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants