From 269ce762a0589fc6fb1899760304d0cf9ba51eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20J=C3=A4ger?= Date: Wed, 27 Jan 2021 16:55:06 +0100 Subject: [PATCH] Introduce new Zephyr board revisioning feature This file layout allows to specify the revision using @ during west build calls. --- README.md | 22 ++++++++++-------- boards/arm/mppt_1210_hus/mppt_1210_hus.dts | 2 -- .../mppt_1210_hus/mppt_1210_hus_0_4_0.conf | 3 +++ .../mppt_1210_hus/mppt_1210_hus_0_4_0.overlay | 0 .../mppt_1210_hus/mppt_1210_hus_0_7_0.conf | 3 +++ .../mppt_1210_hus/mppt_1210_hus_0_7_0.overlay | 12 ++++++++++ boards/arm/mppt_1210_hus/revision.cmake | 6 +++++ boards/arm/pwm_2420_lus/pwm_2420_lus.dts | 2 -- .../arm/pwm_2420_lus/pwm_2420_lus_0_2_0.conf | 3 +++ .../pwm_2420_lus/pwm_2420_lus_0_2_0.overlay | 0 .../arm/pwm_2420_lus/pwm_2420_lus_0_3_0.conf | 3 +++ .../pwm_2420_lus/pwm_2420_lus_0_3_0.overlay | 12 ++++++++++ boards/arm/pwm_2420_lus/revision.cmake | 6 +++++ ...t_1210_hus.json => mppt_1210_hus@0.7.json} | 0 ...wm_2420_lus.json => pwm_2420_lus@0.3.json} | 0 platformio.ini | 23 ++++++++++--------- 16 files changed, 72 insertions(+), 25 deletions(-) create mode 100644 boards/arm/mppt_1210_hus/mppt_1210_hus_0_4_0.conf rename zephyr/mppt_1210_hus.overlay_0v4 => boards/arm/mppt_1210_hus/mppt_1210_hus_0_4_0.overlay (100%) create mode 100644 boards/arm/mppt_1210_hus/mppt_1210_hus_0_7_0.conf create mode 100644 boards/arm/mppt_1210_hus/mppt_1210_hus_0_7_0.overlay create mode 100644 boards/arm/mppt_1210_hus/revision.cmake create mode 100644 boards/arm/pwm_2420_lus/pwm_2420_lus_0_2_0.conf rename zephyr/pwm_2420_lus.overlay_0v2 => boards/arm/pwm_2420_lus/pwm_2420_lus_0_2_0.overlay (100%) create mode 100644 boards/arm/pwm_2420_lus/pwm_2420_lus_0_3_0.conf create mode 100644 boards/arm/pwm_2420_lus/pwm_2420_lus_0_3_0.overlay create mode 100644 boards/arm/pwm_2420_lus/revision.cmake rename boards/{mppt_1210_hus.json => mppt_1210_hus@0.7.json} (100%) rename boards/{pwm_2420_lus.json => pwm_2420_lus@0.3.json} (100%) diff --git a/README.md b/README.md index 254870a..00b8ef7 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,12 @@ Releases are generated from master after significant changes have been made. The The software is configurable to support different charge controller PCBs with STM32F072, low-power STM32L072 or most recent STM32G431 MCUs: -- [Libre Solar MPPT 2420 HC](https://github.com/LibreSolar/mppt-2420-hc) -- [Libre Solar MPPT 2420 LC](https://github.com/LibreSolar/mppt-2420-lc) -- [Libre Solar MPPT 1210 HUS](https://github.com/LibreSolar/mppt-1210-hus) -- [Libre Solar PWM 2420 LUS](https://github.com/LibreSolar/pwm-2420-lus) +| Board | Default revision | Older revisions | +|-----------------------------------------------------|------------------|-----------------| +| [Libre Solar MPPT 2420 HC](https://github.com/LibreSolar/mppt-2420-hc) | 0.1 | | +| [Libre Solar MPPT 2420 LC](https://github.com/LibreSolar/mppt-2420-lc) | 0.10 | | +| [Libre Solar MPPT 1210 HUS](https://github.com/LibreSolar/mppt-1210-hus) | 0.7 | 0.4 | +| [Libre Solar PWM 2420 LUS](https://github.com/LibreSolar/pwm-2420-lus) | 0.3 | 0.2 | ## Building and flashing the firmware @@ -41,7 +43,7 @@ It is suggested to use Visual Studio Code and PlatformIO for firmware developmen 2. Adjust configuration in `zephyr/prj.conf` if necessary. -3. Select the correct board in `platformio.ini` by removing the comment before the board name under `[platformio]` or create a file `custom.ini` with your personal settings. +3. Select the correct board in `platformio.ini` by removing the comment before the board name under `[platformio]` or create a file `custom.ini` with your personal settings. PlatformIO is configured for latest revision of the boards (see table above). For older revisions adjust `platformio.ini` and the `.json` files in `boards` folder manually or use native Zephyr environment. 4. Connect the board via a programmer. See the Libre Solar website for [further project-agnostic instructions](http://libre.solar/docs/flashing). @@ -65,9 +67,11 @@ The CMake entry point is in the `zephyr` subfolder, so you need to run `west bui cd zephyr -Initial board selection (see `boards subfolder for correct names): +Initial board selection (see `boards` subfolder for correct names): - west build -b + west build -b @ + +The appended `@` specifies the board version according to the above table. It can be omitted if only a single board revision is available or if the default (most recent) version should be used. See also [here](https://docs.zephyrproject.org/latest/application/index.html#application-board-version) for more details regarding board revision handling in Zephyr. Flash with specific debug probe (runner), e.g. J-Link: @@ -126,9 +130,7 @@ In Zephyr, all hardware-specific configuration is described in the [devicetree]( The file `boards/arm/board_name/board_name.dts` contains the default devicetree specification (DTS) for a board. It is based on the DTS of the used MCU, which is included from the main Zephyr repository. -In order to overwrite the default configuration, so-called overlays can be used. An overlay file can be specified via the west command line. If it is stored as `board_name.overlay` in the `zephyr` subfolder, it will be recognized automatically when building the firmware for that board (also with PlatformIO). - -In order to support older board versions (e.g. with changed pins), some overlays with appended version numbers are already existing as a template. Remove the version number (e.g. `_0v4`) to "activate" them. +In order to overwrite the default devicetree specification, so-called overlays can be used. An overlay file can be specified via the west command line. If it is stored as `board_name.overlay` in the `zephyr` subfolder, it will be recognized automatically when building the firmware for that board (also with PlatformIO). ### Application firmware configuration diff --git a/boards/arm/mppt_1210_hus/mppt_1210_hus.dts b/boards/arm/mppt_1210_hus/mppt_1210_hus.dts index cd81f4a..1ea42ed 100644 --- a/boards/arm/mppt_1210_hus/mppt_1210_hus.dts +++ b/boards/arm/mppt_1210_hus/mppt_1210_hus.dts @@ -16,8 +16,6 @@ compatible = "charge-controller"; type = "MPPT 1210 HUS"; - version-str = "v0.7.1"; - version-num = <7>; // minor version .1 includes no HW change hs-voltage-max = <40>; ls-voltage-max = <16>; diff --git a/boards/arm/mppt_1210_hus/mppt_1210_hus_0_4_0.conf b/boards/arm/mppt_1210_hus/mppt_1210_hus_0_4_0.conf new file mode 100644 index 0000000..8e7c984 --- /dev/null +++ b/boards/arm/mppt_1210_hus/mppt_1210_hus_0_4_0.conf @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: Apache-2.0 + +# empty (using defaults from _defconfig file) diff --git a/zephyr/mppt_1210_hus.overlay_0v4 b/boards/arm/mppt_1210_hus/mppt_1210_hus_0_4_0.overlay similarity index 100% rename from zephyr/mppt_1210_hus.overlay_0v4 rename to boards/arm/mppt_1210_hus/mppt_1210_hus_0_4_0.overlay diff --git a/boards/arm/mppt_1210_hus/mppt_1210_hus_0_7_0.conf b/boards/arm/mppt_1210_hus/mppt_1210_hus_0_7_0.conf new file mode 100644 index 0000000..8e7c984 --- /dev/null +++ b/boards/arm/mppt_1210_hus/mppt_1210_hus_0_7_0.conf @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: Apache-2.0 + +# empty (using defaults from _defconfig file) diff --git a/boards/arm/mppt_1210_hus/mppt_1210_hus_0_7_0.overlay b/boards/arm/mppt_1210_hus/mppt_1210_hus_0_7_0.overlay new file mode 100644 index 0000000..635f58c --- /dev/null +++ b/boards/arm/mppt_1210_hus/mppt_1210_hus_0_7_0.overlay @@ -0,0 +1,12 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) 2021 Martin Jäger / Libre Solar + */ + +/ { + pcb { + version-str = "v0.7.1"; + version-num = <7>; // minor version .1 includes no HW change + }; +}; diff --git a/boards/arm/mppt_1210_hus/revision.cmake b/boards/arm/mppt_1210_hus/revision.cmake new file mode 100644 index 0000000..d376712 --- /dev/null +++ b/boards/arm/mppt_1210_hus/revision.cmake @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 + +board_check_revision( + FORMAT MAJOR.MINOR.PATCH + DEFAULT_REVISION 0.7.1 +) diff --git a/boards/arm/pwm_2420_lus/pwm_2420_lus.dts b/boards/arm/pwm_2420_lus/pwm_2420_lus.dts index d6edeaa..f66a494 100644 --- a/boards/arm/pwm_2420_lus/pwm_2420_lus.dts +++ b/boards/arm/pwm_2420_lus/pwm_2420_lus.dts @@ -16,8 +16,6 @@ compatible = "charge-controller"; type = "PWM 2420 LUS"; - version-str = "v0.3"; - version-num = <3>; hs-voltage-max = <55>; ls-voltage-max = <32>; diff --git a/boards/arm/pwm_2420_lus/pwm_2420_lus_0_2_0.conf b/boards/arm/pwm_2420_lus/pwm_2420_lus_0_2_0.conf new file mode 100644 index 0000000..8e7c984 --- /dev/null +++ b/boards/arm/pwm_2420_lus/pwm_2420_lus_0_2_0.conf @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: Apache-2.0 + +# empty (using defaults from _defconfig file) diff --git a/zephyr/pwm_2420_lus.overlay_0v2 b/boards/arm/pwm_2420_lus/pwm_2420_lus_0_2_0.overlay similarity index 100% rename from zephyr/pwm_2420_lus.overlay_0v2 rename to boards/arm/pwm_2420_lus/pwm_2420_lus_0_2_0.overlay diff --git a/boards/arm/pwm_2420_lus/pwm_2420_lus_0_3_0.conf b/boards/arm/pwm_2420_lus/pwm_2420_lus_0_3_0.conf new file mode 100644 index 0000000..8e7c984 --- /dev/null +++ b/boards/arm/pwm_2420_lus/pwm_2420_lus_0_3_0.conf @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: Apache-2.0 + +# empty (using defaults from _defconfig file) diff --git a/boards/arm/pwm_2420_lus/pwm_2420_lus_0_3_0.overlay b/boards/arm/pwm_2420_lus/pwm_2420_lus_0_3_0.overlay new file mode 100644 index 0000000..cf28030 --- /dev/null +++ b/boards/arm/pwm_2420_lus/pwm_2420_lus_0_3_0.overlay @@ -0,0 +1,12 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) 2021 Martin Jäger / Libre Solar + */ + +/ { + pcb { + version-str = "v0.3"; + version-num = <3>; + }; +}; diff --git a/boards/arm/pwm_2420_lus/revision.cmake b/boards/arm/pwm_2420_lus/revision.cmake new file mode 100644 index 0000000..77462aa --- /dev/null +++ b/boards/arm/pwm_2420_lus/revision.cmake @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 + +board_check_revision( + FORMAT MAJOR.MINOR.PATCH + DEFAULT_REVISION 0.3 +) diff --git a/boards/mppt_1210_hus.json b/boards/mppt_1210_hus@0.7.json similarity index 100% rename from boards/mppt_1210_hus.json rename to boards/mppt_1210_hus@0.7.json diff --git a/boards/pwm_2420_lus.json b/boards/pwm_2420_lus@0.3.json similarity index 100% rename from boards/pwm_2420_lus.json rename to boards/pwm_2420_lus@0.3.json diff --git a/platformio.ini b/platformio.ini index 59d2928..9d40fc4 100644 --- a/platformio.ini +++ b/platformio.ini @@ -7,13 +7,8 @@ [platformio] -# Select the charge controller hardware by uncommenting one of the following lines +# Choose one of below charge controller board envs as default, e.g. mppt_2420_hc default_envs = -# mppt_2420_lc -# mppt_2420_rc -# mppt_2420_hpx -# mppt_1210_hus -# pwm_2420_lus # Or create your own custom.ini file to overwrite settings in this file, e.g. for board selection. # For further information see here: @@ -61,7 +56,13 @@ check_flags = #### BOARD DEFINITIONS ######################################################## -# https://github.com/LibreSolar/MPPT-2420-LC/tree/5bc39183c8 +# You can specify a specific version by adding e.g. @0.2 to the board name +# (see https://docs.zephyrproject.org/latest/guides/porting/board_porting.html for details) + +# PlatformIO requires a .json file with the same name in boards/ directory. If not existing for +# a particular board revision, just copy it from an existing different revision + +# https://github.com/LibreSolar/mppt-2420-lc [env:mppt_2420_lc] board = mppt_2420_lc @@ -73,17 +74,17 @@ board = mppt_2420_rc [env:mppt_2420_hc] board = mppt_2420_hc -# https://github.com/LibreSolar/MPPT-1210-HUS +# https://github.com/LibreSolar/mppt-1210-hus [env:mppt_1210_hus] -board = mppt_1210_hus +board = mppt_1210_hus@0.7 # https://github.com/LibreSolar/mppt-2420-hpx [env:mppt_2420_hpx] board = mppt_2420_hpx -# https://github.com/LibreSolar/PWM-2420-LUS +# https://github.com/LibreSolar/pwm-2420-lus [env:pwm_2420_lus] -board = pwm_2420_lus +board = pwm_2420_lus@0.3 [env:unit_test] platform = native