Custom board revision/extension with new Zephyr hardware model

I'm upgrading from SDK version v2.4 to v2.7 which introduces the new Zephyr hardware model and I'm struggling with the transition. I have two custom revisions is based off of the nrf5340dk:

In my v2.4 project I added the following to my CMakeLists.txt:

set(REVISIONS "foo_v4" "bar_v1")
if (NOT DEFINED BOARD_REVISION)
    string(REGEX MATCH "nrf5340dk_nrf5340_cpuapp@([a-zA-Z0-9_]+)" _ ${BOARD})
    set(BOARD_REVISION ${CMAKE_MATCH_1})
endif()
if (NOT BOARD_REVISION IN_LIST REVISIONS)
    message(FATAL_ERROR "${BOARD_REVISION} is invalid. Accepted revisions: ${REVISIONS}")
endif()

I then added the following files:

build/
  nrf5340dk_nrf5340_cpuapp_bar_v1.conf
  nrf5340dk_nrf5340_cpuapp_bar_v1.overlay
  nrf5340dk_nrf5340_cpuapp_foo_v4.conf
  nrf5340dk_nrf5340_cpuapp_foo_v4.overlay

Then I built with: west build -b nrf5340dk_nrf5340_cpuapp@foo_v4 --build-dir build/foo_v4

This worked great.

After updating to v2.7 I tweaked my CMakeLists.txt to match the new string, I tried to build with: west build -b nrf5340dk@foo_v4/nrf5340/cpuapp --build-dir=build/foo_v4

but I get the following error:

Invalid board revision: foo_v4

Board 'nrf5340dk' does not define any revisions.

Looking at the "Board Extensions" section of the documentation it seems like this should still be valid: docs.zephyrproject.org/.../board_porting.html

  • Yes, exactly something like that. Since we are doing something different from the concept called Revision in Zephyr, it might be better to use a different term though. Perhaps variant, or model.

    This is of course not what most projects do usually, so I understand why you call it a little hacky.

    If you want a more mainstream solution, for the Kconfig part, you can create a new Kconfig for just the project and add a "Kconfig description 'overlay'" to set the default value of other configs differently.
    But I can't think of anything for Devicetree...

    By the way, regarding the setup that works for you in 2.4, are the overlay files under the "build" folder or the "boards" folder? I think it should be "boards?"

  • The overlay files are in the "boards" folder, just a typo.

    I still find it a little unfortunate that applications can't define a custom revision anymore. I'll think about it over the weekend and maybe see how much work creating new boards is going to be.

  • Would you like to also check this with the Zephyr community? Board revision management are mostly if not all Zephyr, so the community there might have better ideas.

Related