Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion boards/arm/nucleo_f401re/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ System Clock

Nucleo F401RE System Clock could be driven by internal or external oscillator,
as well as main PLL clock. By default System clock is driven by PLL clock at 84MHz,
driven by 8MHz high speed external clock.
- driven by 8MHz high speed external clock (HSE) for board revision C02 and above
- driven by 16MHz high speed internal clock (HSI) for board revision C01

Serial Port
===========
Expand Down
2 changes: 2 additions & 0 deletions boards/arm/nucleo_f401re/nucleo_f401re_C01.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (c) 2023 STMicroelecronics
# SPDX-License-Identifier: Apache-2.0
22 changes: 22 additions & 0 deletions boards/arm/nucleo_f401re/nucleo_f401re_C01.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2023, STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/

&clk_hse {
/* HSE not used on this board revision */
status = "disabled";
};

&clk_hsi {
/* use HSI */
status = "okay";
};

&pll {
/delete-property/ div-m;
div-m = <16>;
/delete-property/ clocks;
clocks = <&clk_hsi>;
};
21 changes: 21 additions & 0 deletions boards/arm/nucleo_f401re/nucleo_f401re_C01.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
identifier: nucleo_f401re@C01
name: ST Nucleo F401RE rev C-01
type: mcu
arch: arm
toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- arduino_gpio
- arduino_i2c
- arduino_spi
- pwm
- counter
- gpio
- i2c
- spi
- adc
- watchdog
ram: 96
flash: 512
2 changes: 2 additions & 0 deletions boards/arm/nucleo_f401re/nucleo_f401re_C02.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (c) 2023 STMicroelecronics
# SPDX-License-Identifier: Apache-2.0
4 changes: 4 additions & 0 deletions boards/arm/nucleo_f401re/revision.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
board_check_revision(
FORMAT ALPHANUM
DEFAULT_REVISION C02
)
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