Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions cmake/modules/extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,9 @@ endfunction()
# When `EXACT` is not specified, this function will set the Zephyr build system
# variable `ACTIVE_BOARD_REVISION` with the selected revision.
#
# FORMAT <LETTER | NUMBER | MAJOR.MINOR.PATCH>: Specify the revision format.
# FORMAT <ALPHANUM | LETTER | NUMBER | MAJOR.MINOR.PATCH>: Specify the revision format.
# ALPHANUM: Revision format is a single letter from A - Z
# followed by one or two integer number ('C02')
# LETTER: Revision format is a single letter from A - Z.
# NUMBER: Revision format is a single integer number.
# MAJOR.MINOR.PATCH: Revision format is three numbers, separated by `.`,
Expand Down Expand Up @@ -915,7 +917,9 @@ function(board_check_revision)
endif()
endif()

if(BOARD_REV_FORMAT STREQUAL LETTER)
if(BOARD_REV_FORMAT STREQUAL ALPHANUM)
set(revision_regex "([A-Z][0-9]+)")
Comment on lines +920 to +921
Copy link
Contributor

Choose a reason for hiding this comment

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

this ALPHANUM revision format seems to specific for the nucleo boards.

So far i'm not convinced we should extend the common helper for this case.

What about a two letters + numbers, or the opposite, number, like 25hdd ?
Should that be called NUMALPHA.

Note, boards can use any revision format they like, but not everything need to have built-in support in the board_check_revision() function.

For example, the legend board uses revisions 25hdd, 25ssd, 35.
Ref:
https://github.com/zephyrproject-rtos/zephyr/blob/main/boards/arm/legend/revision.cmake

Also read:
https://docs.zephyrproject.org/latest/hardware/porting/board_porting.html#custom-revision-cmake-files

elseif(BOARD_REV_FORMAT STREQUAL LETTER)
set(revision_regex "([A-Z])")
elseif(BOARD_REV_FORMAT STREQUAL NUMBER)
set(revision_regex "([0-9]+)")
Expand All @@ -935,7 +939,7 @@ function(board_check_revision)
endif()
else()
message(FATAL_ERROR "Invalid format specified for \
`board_check_revision(FORMAT <LETTER | NUMBER | MAJOR.MINOR.PATCH>)`")
`board_check_revision(FORMAT <ALPHANUM | LETTER | NUMBER | MAJOR.MINOR.PATCH>)`")
endif()

if(NOT (BOARD_REVISION MATCHES "^${revision_regex}$"))
Expand Down
27 changes: 26 additions & 1 deletion doc/hardware/porting/board_porting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,30 @@ example will result in the following error message:

Board revision `0.7.0` not found. Please specify a valid board revision.

Alphanum revision matching
==========================

Let's say instead that you need to support revisions ``A0``, ``C01``, and ``C02`` of
the ``plank`` board. Create the following additional files in the board
directory:

.. code-block:: none

boards/<ARCH>/plank
├── plank_A0.conf
├── plank_A0.overlay
├── plank_C01.conf
├── plank_C01.overlay
├── plank_C02.conf
├── plank_C02.overlay
└── revision.cmake

And add the following to :file:`revision.cmake`:

.. code-block:: cmake

board_check_revision(FORMAT ALPHANUM)

Letter revision matching
========================

Expand Down Expand Up @@ -694,7 +718,7 @@ board_check_revision() details

.. code-block:: cmake

board_check_revision(FORMAT <LETTER | NUMBER | MAJOR.MINOR.PATCH>
board_check_revision(FORMAT <ALPHANUM | LETTER | NUMBER | ALPHANUM | MAJOR.MINOR.PATCH>
[EXACT]
[DEFAULT_REVISION <revision>]
[HIGHEST_REVISION <revision>]
Expand All @@ -703,6 +727,7 @@ board_check_revision() details

This function supports the following arguments:

* ``FORMAT ALPHANUM``: matches single letter followed by integer revisions
* ``FORMAT LETTER``: matches single letter revisions from ``A`` to ``Z`` only
* ``FORMAT NUMBER``: matches integer revisions
* ``FORMAT MAJOR.MINOR.PATCH``: matches exactly three digits. The command line
Expand Down