Remove PlatformIO support

Rationale: Too much effort to maintain two different tool chains.

PlatformIO does not consider the west.yml files and thus, does not
support custom Zephyr modules. However, they are needed to include
ThingSet as a module.

In addition to that, PlatformIO versions always lag behind official
Zephyr releases and we want to avoid being dependent on PlatformIO.
This commit is contained in:
Martin Jäger
2021-10-05 15:01:50 +02:00
parent c54d8ebe05
commit c1f3f05d32
15 changed files with 68 additions and 494 deletions
+5
View File
@@ -29,6 +29,11 @@ jobs:
west update
pip3 install -r rtos/scripts/requirements-base.txt
- name: Trailing whitespace check
working-directory: charge-controller-firmware
run: |
git diff --check `git rev-list --max-parents=0 HEAD`..HEAD
- name: Build firmware
working-directory: charge-controller-firmware
run: |
+3 -47
View File
@@ -35,25 +35,9 @@ git clone --recursive https://github.com/LibreSolar/charge-controller-firmware
Unfortunately, the green GitHub "Clone or download" button does not include submodules. If you cloned the repository already and want to pull the submodules, run `git submodule update --init --recursive`.
### PlatformIO
Building the firmware requires the native Zephyr build system.
It is suggested to use Visual Studio Code and PlatformIO for firmware development, as it simplifies compiling and uploading the code a lot:
1. Install Visual Studio Code and [PlatformIO](https://platformio.org/platformio-ide) to build the firmware.
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. 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).
5. Press the upload button at the bottom left corner in VS Code.
### Native Zephyr environment
You can also use the Zephyr build system directly for advanced configuration with `menuconfig` or if you need more recently added features.
This guide assumes you have already installed the Zephyr SDK and the west tool according to the [Zephyr documentation](https://docs.zephyrproject.org/latest/getting_started/). Also make sure that `west` is at least at version `0.8.0`.
This guide assumes you have already installed the Zephyr SDK and the west tool according to the [Zephyr documentation](https://docs.zephyrproject.org/latest/getting_started/).
Now after you cloned the repository (see above), go into the root firmware directory and initialize a west workspace:
@@ -162,12 +146,6 @@ Core functions of the firmware are covered by unit-tests (located in `tests` dir
cd tests
west build -p -b native_posix -t run
### Static code analysis
PlatformIO integrates cppcheck and clangtidy. The following command is an example to run the checks for MPPT 1210 HUS charge controller code:
platformio check -e mppt_1210_hus
## Additional firmware documentation (docs folder)
- [Charge controller basic concepts](docs/charger-concepts.md)
@@ -182,28 +160,6 @@ The standard OpenOCD settings sometimes fail to flash firmware to this MCU, whic
Try one of these workarounds:
1. Change OpenOCD settings to `adapter_khz 500` in line 70 in `~/.platformio/packages/tool-openocd/scripts/target/stm32l0.cfg`.
1. Change OpenOCD settings to `adapter_khz 500` in `openocd-path/scripts/target/stm32l0.cfg`.
2. Use other tools or debug probes such as [STM32CubeProgrammer](https://www.st.com/en/development-tools/stm32cubeprog.html) or [Segger J-Link](https://www.segger.com/products/debug-probes/j-link/).
### Connection failures
If flashing fails like this in PlatformIO:
```
Error: init mode failed (unable to connect to the target)
in procedure 'program'
** OpenOCD init failed **
shutdown command invoked
```
or with ST-Link:
```bash
$ st-flash write .pio/build/mppt-1210-hus-v0.4/firmware.bin 0x08000000
st-flash 1.5.1
2019-06-21T18:13:03 INFO common.c: Loading device parameters....
2019-06-21T18:13:03 WARN common.c: unknown chip id! 0x5fa0004
```
check the connection between the programmer (for example the ST-Link of the Nucleo board) and the charge controller.
-21
View File
@@ -1,21 +0,0 @@
# Configuration of supported boards
## Zephyr board definition
The definitions found in `boards/arm/my-board/` folders are used directly by Zephyr.
More detiails can be found in Zephyr
[porting guide](https://docs.zephyrproject.org/latest/guides/porting/board_porting.html) and
[Kconfig description](https://docs.zephyrproject.org/latest/guides/kconfig/setting.html#the-initial-configuration).
- `board.cmake`, `CMakeLists.txt`: CMake definitions for board, normally don't need to be touched.
- `Kconfig.board`: Defines the name of the board as used in DTS config.
- `Kconfig.defconfig`: Configuration of invisible Kconfig symbols, i.e. symbols that should not be adjustable by the user via menuconfig.
- `<BOARD>_defconfig`: Default configuration of the board (can be overwritten by prj.conf)
- `<BOARD>.dts`: Main board device tree specification.
- `<BOARD>.yaml`:
- `pinmux.c`: Defines which pins should be used for peripherals like SPI1, SPI2, SPI3 if selected by the user.
## PlatformIO configuration
PlatformIO needs an additional definition file for each board. It is stored as `boards/my-board.json`
-43
View File
@@ -1,43 +0,0 @@
{
"build": {
"cpu": "cortex-m0plus",
"extra_flags": "-DSTM32L072xx",
"f_cpu": "32000000L",
"framework_extra_flags": {
"arduino": "-D__CORTEX_SC=0"
},
"mcu": "stm32l072rz",
"variant": "MPPT-1210-HUS"
},
"debug": {
"default_tools": [
"stlink"
],
"jlink_device": "STM32L072RZ",
"onboard_tools": [
"stlink"
],
"openocd_board": "st_nucleo_l073rz",
"svd_path": "STM32L07x.svd"
},
"frameworks": [
"arduino",
"mbed",
"stm32cube",
"zephyr"
],
"name": "Libre Solar MPPT 1210 HUS",
"upload": {
"maximum_ram_size": 20480,
"maximum_size": 196608,
"protocol": "stlink",
"protocols": [
"jlink",
"stlink",
"blackmagic",
"mbed"
]
},
"url": "http://libre.solar/",
"vendor": "Libre Solar"
}
-42
View File
@@ -1,42 +0,0 @@
{
"build": {
"cpu": "cortex-m4",
"extra_flags": "-DSTM32G4xx -DSTM32G431xx",
"f_cpu": "150000000L",
"mcu": "stm32g431rb",
"variant": "MPPT-2420-HC"
},
"connectivity": [
"can"
],
"debug": {
"default_tools": [
"jlink"
],
"jlink_device": "STM32G431RB",
"onboard_tools": [
"stlink"
],
"openocd_board": "st_nucleo_g431rb",
"svd_path": "STM32G431xx.svd"
},
"frameworks": [
"arduino",
"stm32cube",
"zephyr"
],
"name": "Libre Solar MPPT 2420 HC",
"upload": {
"maximum_ram_size": 32768,
"maximum_size": 131072,
"protocol": "jlink",
"protocols": [
"jlink",
"stlink",
"blackmagic",
"mbed"
]
},
"url": "https://libre.solar/",
"vendor": "Libre Solar"
}
-42
View File
@@ -1,42 +0,0 @@
{
"build": {
"cpu": "cortex-m4",
"extra_flags": "-DSTM32G4xx -DSTM32G431xx",
"f_cpu": "150000000L",
"mcu": "stm32g431rb",
"variant": "MPPT-2420-HPX"
},
"connectivity": [
"can"
],
"debug": {
"default_tools": [
"jlink"
],
"jlink_device": "STM32G431RB",
"onboard_tools": [
"stlink"
],
"openocd_board": "st_nucleo_g431rb",
"svd_path": "STM32G431xx.svd"
},
"frameworks": [
"arduino",
"stm32cube",
"zephyr"
],
"name": "Libre Solar MPPT 2420 HPX",
"upload": {
"maximum_ram_size": 32768,
"maximum_size": 131072,
"protocol": "jlink",
"protocols": [
"jlink",
"stlink",
"blackmagic",
"mbed"
]
},
"url": "http://libre.solar/",
"vendor": "Libre Solar"
}
-41
View File
@@ -1,41 +0,0 @@
{
"build": {
"cpu": "cortex-m0",
"extra_flags": "-DSTM32F072xB",
"f_cpu": "48000000L",
"mcu": "stm32f072rbt6"
},
"connectivity": [
"can"
],
"debug": {
"default_tools": [
"stlink"
],
"jlink_device": "STM32F072RB",
"onboard_tools": [
"stlink"
],
"openocd_board": "st_nucleo_f0",
"svd_path": "STM32F072x.svd"
},
"frameworks": [
"mbed",
"stm32cube",
"zephyr"
],
"name": "Libre Solar MPPT 2420 LC",
"upload": {
"maximum_ram_size": 16384,
"maximum_size": 131072,
"protocol": "stlink",
"protocols": [
"jlink",
"stlink",
"blackmagic",
"mbed"
]
},
"url": "http://libre.solar/",
"vendor": "Libre Solar"
}
-42
View File
@@ -1,42 +0,0 @@
{
"build": {
"cpu": "cortex-m4",
"extra_flags": "-DSTM32G4xx -DSTM32G431xx",
"f_cpu": "150000000L",
"mcu": "stm32g431rb",
"variant": "MPPT-2420-RC"
},
"connectivity": [
"can"
],
"debug": {
"default_tools": [
"jlink"
],
"jlink_device": "STM32G431RB",
"onboard_tools": [
"stlink"
],
"openocd_board": "st_nucleo_g431rb",
"svd_path": "STM32G431xx.svd"
},
"frameworks": [
"arduino",
"stm32cube",
"zephyr"
],
"name": "Libre Solar MPPT 2420 RC",
"upload": {
"maximum_ram_size": 32768,
"maximum_size": 131072,
"protocol": "jlink",
"protocols": [
"jlink",
"stlink",
"blackmagic",
"mbed"
]
},
"url": "http://libre.solar/",
"vendor": "Libre Solar"
}
-42
View File
@@ -1,42 +0,0 @@
{
"build": {
"core": "stm32",
"cpu": "cortex-m4",
"extra_flags": "-DSTM32G4xx -DSTM32G474xx",
"f_cpu": "170000000L",
"mcu": "stm32g474ret6",
"product_line": "STM32G474xx",
"variant": "NUCLEO_G474RE"
},
"connectivity": [
"can"
],
"debug": {
"jlink_device": "STM32G474RE",
"openocd_target": "stm32g4x",
"svd_path": "STM32G474xx.svd"
},
"frameworks": [
"arduino",
"cmsis",
"mbed",
"libopencm3",
"stm32cube",
"zephyr"
],
"name": "Nucleo G474RE",
"upload": {
"maximum_ram_size": 131072,
"maximum_size": 524288,
"protocol": "mbed",
"protocols": [
"jlink",
"stlink",
"cmsis-dap",
"blackmagic",
"mbed"
]
},
"url": "https://www.st.com/en/evaluation-tools/nucleo-g474re.html",
"vendor": "ST"
}
-43
View File
@@ -1,43 +0,0 @@
{
"build": {
"cpu": "cortex-m0plus",
"extra_flags": "-DSTM32L072xx",
"f_cpu": "32000000L",
"framework_extra_flags": {
"arduino": "-D__CORTEX_SC=0"
},
"mcu": "stm32l072rz",
"variant": "PWM-2420-LUS"
},
"debug": {
"default_tools": [
"stlink"
],
"jlink_device": "STM32L072RZ",
"onboard_tools": [
"stlink"
],
"openocd_board": "st_nucleo_l073rz",
"svd_path": "STM32L07x.svd"
},
"frameworks": [
"arduino",
"mbed",
"stm32cube",
"zephyr"
],
"name": "Libre Solar PWM 2420 LUS",
"upload": {
"maximum_ram_size": 20480,
"maximum_size": 196608,
"protocol": "stlink",
"protocols": [
"jlink",
"stlink",
"blackmagic",
"mbed"
]
},
"url": "http://libre.solar/",
"vendor": "Libre Solar"
}
-94
View File
@@ -1,94 +0,0 @@
#
# Project Configuration File
#
# A detailed documentation with the EXAMPLES is located here:
# http://docs.platformio.org/en/latest/projectconf.html
#
[platformio]
# Choose one of below charge controller board envs as default, e.g. mppt_2420_hc
default_envs =
# Or create your own custom.ini file to overwrite settings in this file, e.g. for board selection.
# For further information see here:
# https://docs.platformio.org/en/latest/projectconf/section_platformio.html#extra-configs
extra_configs =
custom.ini
[env]
framework = zephyr
#platform = https://github.com/platformio/platform-ststm32.git
platform = ststm32@~14.1.0
# Use customized Zephyr branch from Libre Solar repository
platform_packages =
toolchain-gccarmnoneeabi@1.90301.200702
# framework-zephyr@https://github.com/LibreSolar/zephyr#v2.6-branch
#upload_protocol = mbed
upload_protocol = stlink
#upload_protocol = jlink
#debug_tool = jlink
# Custom Serial Monitor baud rate
monitor_speed = 115200
# Compiler settings
build_flags =
-std=gnu++17
-fsingle-precision-constant
-Wl,-Map,memory.map
# Below flags are only valid for C++ and create warnings for C files, so we add them as
# CXXFLAGS in extra_script.
build_unflags = -Wno-register -fno-rtti
extra_scripts = scripts/platformio-extra.py
check_tool = cppcheck, clangtidy
check_flags =
cppcheck: --enable=warning,style,performance,portability,information,missingInclude -j 7 --inline-suppr
# --addon=addons/misra.py --addon=addons/cert.py
clangtidy: --checks=-*,cert-*,clang-analyzer-*,bugprone-*,misc-*,performance-*,readability-*,-readability-magic-numbers,-cert-err58-cpp
lib_deps =
https://github.com/LibreSolar/thingset-device-library.git
#### BOARD DEFINITIONS ########################################################
# 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
# https://github.com/LibreSolar/mppt-2420-rc
[env:mppt_2420_rc]
board = mppt_2420_rc
# https://github.com/LibreSolar/mppt-2420-hc
[env:mppt_2420_hc]
board = mppt_2420_hc@0.2
# https://github.com/LibreSolar/mppt-1210-hus
[env: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
[env:pwm_2420_lus]
board = pwm_2420_lus@0.3
# Nucleo board for testing purposes
[env:nucleo_g474re]
board = nucleo_g474re
+37 -8
View File
@@ -2,12 +2,14 @@
:: This file performs continuous integration checks and should be run before pushing new commits
echo "---------- Trailing whitespace check -------------"
:: check uncommitted changes
git diff --check HEAD
if errorlevel 1 (
echo Failure Reason is %errorlevel%
exit /b %errorlevel%
)
:: check all commits starting from initial commit
for /F %i in ('"git rev-list --max-parents=0 HEAD"') do git diff --check %i..HEAD
if errorlevel 1 (
@@ -16,24 +18,51 @@ if errorlevel 1 (
)
echo "---------- Running compile check -------------"
platformio run -e mppt_2420_lc -e mppt_1210_hus -e mppt_2420_hc -e pwm_2420_lus
cd zephyr
west build -b mppt_2420_hc@0.2
if errorlevel 1 (
echo Failure Reason is %errorlevel%
exit /b %errorlevel%
)
west build -b mppt_2420_lc
if errorlevel 1 (
echo Failure Reason is %errorlevel%
exit /b %errorlevel%
)
west build -b mppt_1210_hus@0.7
if errorlevel 1 (
echo Failure Reason is %errorlevel%
exit /b %errorlevel%
)
west build -b pwm_2420_lus@0.3
if errorlevel 1 (
echo Failure Reason is %errorlevel%
exit /b %errorlevel%
)
cd ..
echo "---------- Running unit-tests -------------"
platformio test -e unit_test
if errorlevel 1 (
echo Failure Reason is %errorlevel%
exit /b %errorlevel%
)
echo "---------- Running static code checks -------------"
platformio check -e mppt_1210_hus -e pwm_2420_lus --skip-packages --fail-on-defect high
cd tests
west build -b native_posix -t run
if errorlevel 1 (
echo Failure Reason is %errorlevel%
exit /b %errorlevel%
)
cd ..
:: echo "---------- Running static code checks -------------"
:: platformio check -e mppt_1210_hus -e pwm_2420_lus --skip-packages --fail-on-defect high
:: if errorlevel 1 (
:: echo Failure Reason is %errorlevel%
:: exit /b %errorlevel%
:: )
echo "---------- All tests passed -------------"
+22 -19
View File
@@ -3,34 +3,37 @@
# This file performs continuous integration checks and should be run before pushing new commits
#
# exit when any command fails
set -e
# use board-specific directory
west config build.dir-fmt "build/{board}"
echo "---------- Trailing whitespace check -------------"
# check uncommitted changes
git diff --check HEAD
if [ $? != 0 ]; then
exit 1;
fi
# check all commits starting from initial commit
git diff --check `git rev-list --max-parents=0 HEAD`..HEAD
if [ $? != 0 ]; then
exit 1;
fi
echo "---------- Running compile check -------------"
platformio run -e mppt_2420_lc -e mppt_1210_hus -e mppt_2420_hc -e pwm_2420_lus
if [ $? != 0 ]; then
exit 1;
fi
cd zephyr
west build -b mppt_2420_hc@0.2
west build -b mppt_2420_lc
west build -b mppt_1210_hus@0.7
west build -b pwm_2420_lus@0.3
cd ..
echo "---------- Running unit-tests -------------"
platformio test -e unit_test
if [ $? != 0 ]; then
exit 1;
fi
echo "---------- Running static code checks -------------"
platformio check -e mppt_1210_hus -e pwm_2420_lus --skip-packages --fail-on-defect high
if [ $? != 0 ]; then
exit 1;
fi
cd tests
west build -b native_posix -t run
cd ..
#echo "---------- Running static code checks -------------"
#platformio check -e mppt_1210_hus -e pwm_2420_lus --skip-packages --fail-on-defect high
echo "---------- All tests passed -------------"
-8
View File
@@ -1,8 +0,0 @@
# Custom settings, as referred to as "extra_script" in platformio.ini
#
# See http://docs.platformio.org/en/latest/projectconf.html#extra-script
Import("env")
env.Append( CXXFLAGS=[ "-Wno-register -fno-rtti" ] )
+1 -2
View File
@@ -21,7 +21,6 @@ int device_status_tests();
int load_tests();
// activate this via build_flags in platformio.ini or custom.ini
#ifdef CUSTOM_TESTS
#ifdef CONFIG_CUSTOM_TESTS
int custom_tests();
#endif