Skip to content

Commit e12e487

Browse files
committed
cmake: modules: extension for HW board revision format
Add the combination of Letter and Number(s) for the Revision format of the Hardware Board. This is for example used for nucleo_stm32f401re rev C01 Signed-off-by: Francois Ramu <[email protected]>
1 parent bc4b49c commit e12e487

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

cmake/modules/extensions.cmake

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,9 @@ endfunction()
849849
# When `EXACT` is not specified, this function will set the Zephyr build system
850850
# variable `ACTIVE_BOARD_REVISION` with the selected revision.
851851
#
852-
# FORMAT <LETTER | NUMBER | MAJOR.MINOR.PATCH>: Specify the revision format.
852+
# FORMAT <ALPHANUM | LETTER | NUMBER | MAJOR.MINOR.PATCH>: Specify the revision format.
853+
# ALPHANUM: Revision format is a single letter from A - Z
854+
# followed by one or two integer number ('C02')
853855
# LETTER: Revision format is a single letter from A - Z.
854856
# NUMBER: Revision format is a single integer number.
855857
# MAJOR.MINOR.PATCH: Revision format is three numbers, separated by `.`,
@@ -915,7 +917,9 @@ function(board_check_revision)
915917
endif()
916918
endif()
917919

918-
if(BOARD_REV_FORMAT STREQUAL LETTER)
920+
if(BOARD_REV_FORMAT STREQUAL ALPHANUM)
921+
set(revision_regex "([A-Z][0-9]+)")
922+
elseif(BOARD_REV_FORMAT STREQUAL LETTER)
919923
set(revision_regex "([A-Z])")
920924
elseif(BOARD_REV_FORMAT STREQUAL NUMBER)
921925
set(revision_regex "([0-9]+)")
@@ -935,7 +939,7 @@ function(board_check_revision)
935939
endif()
936940
else()
937941
message(FATAL_ERROR "Invalid format specified for \
938-
`board_check_revision(FORMAT <LETTER | NUMBER | MAJOR.MINOR.PATCH>)`")
942+
`board_check_revision(FORMAT <ALPHANUM | LETTER | NUMBER | MAJOR.MINOR.PATCH>)`")
939943
endif()
940944

941945
if(NOT (BOARD_REVISION MATCHES "^${revision_regex}$"))

doc/hardware/porting/board_porting.rst

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,30 @@ example will result in the following error message:
641641
642642
Board revision `0.7.0` not found. Please specify a valid board revision.
643643
644+
Alphanum revision matching
645+
==========================
646+
647+
Let's say instead that you need to support revisions ``A0``, ``C01``, and ``C02`` of
648+
the ``plank`` board. Create the following additional files in the board
649+
directory:
650+
651+
.. code-block:: none
652+
653+
boards/<ARCH>/plank
654+
├── plank_A0.conf
655+
├── plank_A0.overlay
656+
├── plank_C01.conf
657+
├── plank_C01.overlay
658+
├── plank_C02.conf
659+
├── plank_C02.overlay
660+
└── revision.cmake
661+
662+
And add the following to :file:`revision.cmake`:
663+
664+
.. code-block:: cmake
665+
666+
board_check_revision(FORMAT ALPHANUM)
667+
644668
Letter revision matching
645669
========================
646670

@@ -694,7 +718,7 @@ board_check_revision() details
694718

695719
.. code-block:: cmake
696720
697-
board_check_revision(FORMAT <LETTER | NUMBER | MAJOR.MINOR.PATCH>
721+
board_check_revision(FORMAT <ALPHANUM | LETTER | NUMBER | ALPHANUM | MAJOR.MINOR.PATCH>
698722
[EXACT]
699723
[DEFAULT_REVISION <revision>]
700724
[HIGHEST_REVISION <revision>]
@@ -703,6 +727,7 @@ board_check_revision() details
703727
704728
This function supports the following arguments:
705729

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

0 commit comments

Comments
 (0)