diff --git a/boards/arm/nucleo_f401re/doc/index.rst b/boards/arm/nucleo_f401re/doc/index.rst index c4aaff7c73f88..e70ca5636433f 100644 --- a/boards/arm/nucleo_f401re/doc/index.rst +++ b/boards/arm/nucleo_f401re/doc/index.rst @@ -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 =========== diff --git a/boards/arm/nucleo_f401re/nucleo_f401re_C01.conf b/boards/arm/nucleo_f401re/nucleo_f401re_C01.conf new file mode 100644 index 0000000000000..288ba3f82390e --- /dev/null +++ b/boards/arm/nucleo_f401re/nucleo_f401re_C01.conf @@ -0,0 +1,2 @@ +# Copyright (c) 2023 STMicroelecronics +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/arm/nucleo_f401re/nucleo_f401re_C01.overlay b/boards/arm/nucleo_f401re/nucleo_f401re_C01.overlay new file mode 100644 index 0000000000000..df2438d183bdb --- /dev/null +++ b/boards/arm/nucleo_f401re/nucleo_f401re_C01.overlay @@ -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>; +}; diff --git a/boards/arm/nucleo_f401re/nucleo_f401re_C01.yaml b/boards/arm/nucleo_f401re/nucleo_f401re_C01.yaml new file mode 100644 index 0000000000000..267cd2f85e472 --- /dev/null +++ b/boards/arm/nucleo_f401re/nucleo_f401re_C01.yaml @@ -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 diff --git a/boards/arm/nucleo_f401re/nucleo_f401re_C02.conf b/boards/arm/nucleo_f401re/nucleo_f401re_C02.conf new file mode 100644 index 0000000000000..288ba3f82390e --- /dev/null +++ b/boards/arm/nucleo_f401re/nucleo_f401re_C02.conf @@ -0,0 +1,2 @@ +# Copyright (c) 2023 STMicroelecronics +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/arm/nucleo_f401re/revision.cmake b/boards/arm/nucleo_f401re/revision.cmake new file mode 100644 index 0000000000000..40ba2cef17840 --- /dev/null +++ b/boards/arm/nucleo_f401re/revision.cmake @@ -0,0 +1,4 @@ +board_check_revision( + FORMAT ALPHANUM + DEFAULT_REVISION C02 +) diff --git a/cmake/modules/extensions.cmake b/cmake/modules/extensions.cmake index 3ba47fc2baf70..8bf9ca69bd920 100644 --- a/cmake/modules/extensions.cmake +++ b/cmake/modules/extensions.cmake @@ -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 : Specify the revision format. +# FORMAT : 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 `.`, @@ -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]+)") + elseif(BOARD_REV_FORMAT STREQUAL LETTER) set(revision_regex "([A-Z])") elseif(BOARD_REV_FORMAT STREQUAL NUMBER) set(revision_regex "([0-9]+)") @@ -935,7 +939,7 @@ function(board_check_revision) endif() else() message(FATAL_ERROR "Invalid format specified for \ - `board_check_revision(FORMAT )`") + `board_check_revision(FORMAT )`") endif() if(NOT (BOARD_REVISION MATCHES "^${revision_regex}$")) diff --git a/doc/hardware/porting/board_porting.rst b/doc/hardware/porting/board_porting.rst index 1b28ae1d427ad..20c92407b2d80 100644 --- a/doc/hardware/porting/board_porting.rst +++ b/doc/hardware/porting/board_porting.rst @@ -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//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 ======================== @@ -694,7 +718,7 @@ board_check_revision() details .. code-block:: cmake - board_check_revision(FORMAT + board_check_revision(FORMAT [EXACT] [DEFAULT_REVISION ] [HIGHEST_REVISION ] @@ -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