Introduce new Zephyr board revisioning feature

This file layout allows to specify the revision using <board-name>@<revision>
during west build calls.
This commit is contained in:
Martin Jäger
2021-02-04 17:28:52 +01:00
parent ed29e54d20
commit 269ce762a0
16 changed files with 72 additions and 25 deletions
+12 -10
View File
@@ -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 <board-name>
west build -b <board-name>@<revision>
The appended `@<revision>` 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
@@ -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>;
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: Apache-2.0
# empty (using defaults from _defconfig file)
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: Apache-2.0
# empty (using defaults from _defconfig file)
@@ -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
};
};
+6
View File
@@ -0,0 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
board_check_revision(
FORMAT MAJOR.MINOR.PATCH
DEFAULT_REVISION 0.7.1
)
-2
View File
@@ -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>;
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: Apache-2.0
# empty (using defaults from _defconfig file)
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: Apache-2.0
# empty (using defaults from _defconfig file)
@@ -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>;
};
};
+6
View File
@@ -0,0 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
board_check_revision(
FORMAT MAJOR.MINOR.PATCH
DEFAULT_REVISION 0.3
)
+12 -11
View File
@@ -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