Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: enhanced board entry file handling #67322

Merged
merged 1 commit into from
Jan 10, 2024

Conversation

tejlmand
Copy link
Collaborator

@tejlmand tejlmand commented Jan 8, 2024

With a single board now covering what used to be several boards, and with the ability to omit SoC when building for a single SoC board, then <board>_defconfig and <board>.dts lookup is improved.

A single SoC board may prefer to keep its defconfig entry point as <board>_defconfig instead of <board>_<soc>_defconfig.

Also, a multi-SoC board / multi-core SoC board, which used to be implemented as n-boards may wish to have common _defconfig settings in a common <board>_defconfig file, and the SoC / cpuset specifics in <board>_<soc>_defconfig / <board>_<soc>_<core>_defconfig.

Such defconfig support allows also to place build variant specifics in its own <board>_<soc>_<variant>_defconfig file.

This commit allows multiple _defconfigs for a board and its identifiers.

Similar is implemented for a board's dts file.
If a <board>_<soc>_<core>.dts file is not found, the build system will instead use <board>_<soc>.dts, and finally fallback to <board>.dts.

This allows a board to have a shared dts file for all board identifiers which are identical while still support specific dts where required.

A dts file is a devicetree starting point and thus two dts files cannot be used in together. For such cases, an ordinary board overlay file must be used.

@fabiobaltieri
Copy link
Member

fabiobaltieri commented Jan 9, 2024

@tejlmand you may want to look at LLVM being sad, some tests are timing out, unclear to me why

Comment on lines 1476 to 1480
# The full order of build strings returned in the list will be:
# - Full build string, including identifier revision, build type
# - Build string with build type removed
# - Build string with revision removed in addition
# - Build string with board variants removed in addition
# - Build string with cpuset removed in addition
# - Build string with soc removed in addition
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on this description, I tried:

zephyr_build_string(build_string BOARD alpha BOARD_REVISION 1.0.0 BOARD_IDENTIFIER /soc/bar BUILD foo MERGE)

# I expected:  alpha_soc_bar_1_0_0_foo;alpha_soc_bar_1_0_0;alpha_soc_bar;alpha_soc;alpha
# but I got:   alpha_soc_bar_1_0_0_foo;alpha_soc_bar;alpha

It works if I streamline the implementation like this:

  string(REPLACE "/" ";" build_str_segments "${BUILD_STR_BOARD}${BUILD_STR_BOARD_IDENTIFIER}")
  if(DEFINED BUILD_STR_BOARD_REVISION)
    string(REPLACE "." "_" revision_string ${BUILD_STR_BOARD_REVISION})
    list(APPEND build_str_segments ${revision_string})
  endif()
  list(APPEND build_str_segments ${BUILD_STR_BUILD})

  while(NOT build_str_segments STREQUAL "")
    list(JOIN build_str_segments "_" variant_string)
    list(APPEND ${outvar} "${variant_string}")
    list(POP_BACK build_str_segments)
    if(NOT BUILD_STR_MERGE)
      break()
    endif()
  endwhile()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice catch 👍
And thanks for the proposal, using JOIN sure is cleaner.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed, resorted to use string(JOIN ...) as that allows for BUILD_STR_BUILD at end, so that all build strings are appended with that info when passed as argument.

That conforms to what we do today with build string, and it was an oversight in first round that it was only appended to first string.

Function description updated as well.

@tejlmand tejlmand added the DNM This PR should not be merged (Do Not Merge) label Jan 9, 2024
@tejlmand tejlmand removed the DNM This PR should not be merged (Do Not Merge) label Jan 9, 2024
With a single board now covering what used to be several boards, and
with the ability to omit SoC when building for a single SoC board, then
<board>_defconfig and <board>.dts lookup is improved.

A single SoC board may prefer to keep its defconfig entry point as
<board>_defconfig instead of <board>_<soc>_defconfig.

Also, a multi-SoC board / multi-core SoC board, which used to be
implemented as n-boards may wish to have common _defconfig settings in
a common <board>_defconfig file, and the SoC / cpuset specifics in
<board>_<soc>_defconfig / <board>_<soc>_<core>_defconfig.

Such defconfig support allows also to place build variant specifics in
its own <board>_<soc>_<variant>_defconfig file.

This commit allows multiple _defconfigs for a board and its identifiers.

Similar is implemented for a board's dts file.
If a <board>_<soc>_<core>.dts file is not found, the build system will
instead use <board>_<soc>.dts, and finally fallback to <board>.dts.

This allows a board to have a shared dts file for all board identifiers
which are identical while still support specific dts where required.

A dts file is a devicetree starting point and thus two dts files cannot
be used in together. For such cases, an ordinary board overlay file must
be used.

Signed-off-by: Torsten Rasmussen <[email protected]>
@tejlmand
Copy link
Collaborator Author

compliance failure is related to out-of-date MAINTAINERS file for soc and board entries.
MAINTAINERS file is planned to be updated in a single commit when porting is done.

@tejlmand tejlmand merged commit 408201d into zephyrproject-rtos:collab-hwm Jan 10, 2024
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants