Move to standard Zephyr T2 workspace structure (star topology)

https://docs.zephyrproject.org/latest/guides/west/workspaces.html

Previously, west manifest and CMake entry point were in zephyr subfolder
as required for PlatformIO. As PlatformIO support was dropped, we can
follow the default Zephyr folder structure more closely.

The application is built and flashed from app subfolder, where as unit
tests are run from tests subfolder.
This commit is contained in:
Martin Jäger
2021-12-12 14:09:05 +01:00
parent 15ee7d8553
commit 8ab8ea244a
57 changed files with 67 additions and 48 deletions
-14
View File
@@ -1,14 +0,0 @@
# custom DTS overlays
*.overlay
# custom project configuration per board
prj_*.conf
# alternative location for custom DTS overlays or conf files
boards*
# folders generated by west
build
modules
rtos
-26
View File
@@ -1,26 +0,0 @@
# Copyright (c) The Libre Solar Project Contributors
# SPDX-License-Identifier: Apache-2.0
set(BOARD_ROOT ${CMAKE_SOURCE_DIR}/..)
set(DTS_ROOT ${CMAKE_SOURCE_DIR})
cmake_minimum_required(VERSION 3.13.1)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(libre_solar_charge_controller)
add_subdirectory(../src build/src)
add_subdirectory(../lib/oled-display build/oled-display)
# determine git tag and commit hash for automatic firmware versioning
find_package(Git)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --long --dirty --tags
OUTPUT_VARIABLE FIRMWARE_VERSION_ID
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
set(FIRMWARE_VERSION_ID "unknown")
endif()
add_definitions(-DFIRMWARE_VERSION_ID="${FIRMWARE_VERSION_ID}")
-481
View File
@@ -1,481 +0,0 @@
# Copyright (c) The Libre Solar Project Contributors
# SPDX-License-Identifier: Apache-2.0
mainmenu "Libre Solar Charge Controller Firmware"
#
# Invisible (board-specific) Kconfig symbols
#
config CONTROL_FREQUENCY
int
default 10
help
Main control function frequency (Hz)
Frequencies higher than 10 Hz caused issues with MPPT control during lab test with
PV simulator. Might be different with actual solar panel.
config LIBRE_SOLAR_TYPE_ID
int
help
Numeric Libre Solar hardware type ID
config HS_MOSFET_FAIL_SAFE_PROTECTION
bool
default y
help
If enabled, the DC/DC control function will will detect if the high-side MOSFET has failed
short and trip the fuse by switching the low-side MOSFET continuously on. This will prevent
accidental overcharging of the battery.
#
# Visible (user-configurable) Kconfig symbols
#
menu "Charge Controller Setup"
choice
prompt "High-voltage terminal"
depends on $(dt_compat_enabled,half-bridge)
help
Select the device connected to the high-voltage
side terminal of the DC/DC converter.
config HV_TERMINAL_SOLAR
bool "Solar panel"
config HV_TERMINAL_NANOGRID
bool "DC nanogrid"
config HV_TERMINAL_GENERATOR
bool "DC generator, e.g. wind turbine"
config HV_TERMINAL_BATTERY
bool "Battery, e.g. electric bicycle"
endchoice
choice
prompt "Low-voltage terminal"
help
Select the device connected to the low-voltage side
of the charge controller (usually battery terminal).
config LV_TERMINAL_BATTERY
depends on !HV_TERMINAL_BATTERY
bool "Battery 12V/24V"
config LV_TERMINAL_SOLAR
depends on HV_TERMINAL_BATTERY || HV_TERMINAL_NANOGRID
bool "Solar panel"
endchoice
choice
prompt "PWM terminal"
depends on $(dt_node_has_bool_prop,/outputs/pwm_switch,kconfig-flag)
help
Select the device connected to the PWM switch (currently
only solar panel possible)
config PWM_TERMINAL_SOLAR
depends on LV_TERMINAL_BATTERY && !HV_TERMINAL_SOLAR
bool "Solar panel"
endchoice
menu "Battery default settings"
config BAT_CAPACITY_AH
int "Battery nominal capacity in Ah"
range 10 1000
default 50
help
Nominal battery capacity or sum of parallel cells capacity
choice
prompt "Battery type"
default BAT_TYPE_GEL
help
Select the type of the single cells inside the battery
to determine voltage set points. Total voltage set points
are multiplied with the selected number of cells.
config BAT_TYPE_CUSTOM
bool "Custom type"
config BAT_TYPE_FLOODED
bool "Flooded (wet) lead-acid"
config BAT_TYPE_GEL
bool "VRLA gel, maintainance-free"
config BAT_TYPE_AGM
bool "AGM, maintainance-free"
config BAT_TYPE_LFP
bool "LiFePO4 Li-ion, 3.3V nominal"
config BAT_TYPE_NMC
bool "NMC/Graphite Li-ion, 3.7V nominal, 4.2V max"
config BAT_TYPE_NMC_HV
bool "NMC/Graphite High Voltage Li-ion, 3.7V nominal, 4.35 max"
endchoice
# values must match enum BatType in bat_charger.h
config BAT_TYPE
int
default 0 if BAT_TYPE_CUSTOM
default 1 if BAT_TYPE_FLOODED
default 2 if BAT_TYPE_GEL
default 3 if BAT_TYPE_AGM
default 4 if BAT_TYPE_LFP
default 5 if BAT_TYPE_NMC
default 6 if BAT_TYPE_NMC_HV
config BAT_NUM_CELLS
int "Number of cells for single battery"
default 6 if BAT_TYPE_FLOODED || BAT_TYPE_GEL || BAT_TYPE_AGM
default 4 if BAT_TYPE_LFP
default 3 if BAT_TYPE_NMC || BAT_TYPE_NMC_HV
range 3 16
help
Typical choices:
- 6 for 12V lead-acid battery
- 4 for 12V LiFePO4 battery
- 3 for 12V NMC Li-ion battery
Remarks:
- If you choose settings for 12V system, 24V systems
(2 batteries in series) are recognized automatically
- Make sure the voltage of the used charge controller
is not exceeded.
menu "Custom cell-level settings"
depends on BAT_TYPE_CUSTOM
config CELL_ABS_MAX_VOLTAGE_MV
int "Absolute maximum voltage (mV)"
default 2450
help
Above this voltage the battery or loads might get damaged.
config CELL_TOPPING_VOLTAGE_MV
int "Topping voltage (mV)"
default 2400
help
Charger target voltage, switching from CC to CV at this voltage threshold.
config CELL_RECHARGE_VOLTAGE_MV
int "Recharge voltage (mV)"
default 2300
help
Start charging again if voltage of fully charged battery drops below this threshold.
config CELL_RECONNECT_VOLTAGE_MV
int "Load reconnect cell voltage (mV)"
default 2100
help
Re-enable the load only after charged beyond this value.
config CELL_DISCONNECT_VOLTAGE_MV
int "Load disconnect cell voltage (mV)"
default 1950
help
Load output is disabled if battery voltage is below this threshold.
config CELL_ABS_MIN_VOLTAGE_MV
int "Topping voltage (mV)"
default 1600
help
Below this voltage the battery is considered damaged.
config CELL_OCV_FULL_MV
int "OCV full cell (mV)"
default 2150
help
Voltages during idle (no charging/discharging current)
config CELL_OCV_EMPTY_MV
int "OCV empty cell (mV)"
default 1900
help
Voltages during idle (no charging/discharging current)
config CELL_FLOAT
bool "Enable float charging phase"
default y
config CELL_FLOAT_VOLTAGE_MV
int "Float charging cell voltage (mV)" if CELL_FLOAT
default 2300
help
Charger target voltage for float charging of lead-acid batteries
config CELL_FLOAT_RECHARGE_TIME
int "Float recharge time (s)" if CELL_FLOAT
default 1800
help
If the float voltage is not reached anymore (e.g. because of lack of solar
input power) for this period of time, the charger state machine goes back
into CC/bulk charging mode.
config CELL_EQUALIZATION
bool "Enable equalization phase"
default n
help
Enable for flooded batteries only.
config CELL_EQUALIZATION_VOLTAGE_MV
int "Equalization phase cell voltage (mV)" if CELL_EQUALIZATION
default 2450
help
Charger target voltage for equalization charging of lead-acid batteries
config CELL_EQUALIZATION_DURATION
int "Equalization duration (seconds)" if CELL_EQUALIZATION
default 3600
help
After this time, equalization charging is stopped.
config CELL_EQUALIZATION_TRIGGER_DAYS
int "Equalization time trigger (days)" if CELL_EQUALIZATION
default 60
help
After passing specified amount of days, an equalization charge is triggered.
config CELL_EQUALIZATION_TRIGGER_DEEP_CYCLES
int "Equalization deep cycle count trigger" if CELL_EQUALIZATION
default 10
help
After specified number of deep discharges, an equalization charge is triggered.
config CELL_TEMP_COMPENSATION_MV_K
int "Cell voltage temperature compenstaion (mV/K)"
range -5 0
default -3
help
Suggested value: -3 mV/K/cell for lead-acid batteries, 0 for Li-ion batteries
config CELL_INTERNAL_RESISTANCE_MOHM
int "Cell internal resistance (mOhm)"
range 1 30
default 5
endmenu # Custom cell-level settings
menu "Custom temperature settings"
depends on BAT_TYPE_CUSTOM
config BAT_CHARGE_TEMP_MAX
int "Maximum charge temperature (°C)"
range 0 60
default 50
config BAT_CHARGE_TEMP_MIN
int "Minimum charge temperature (°C)"
range -10 20
default 0
config BAT_DISCHARGE_TEMP_MAX
int "Maximum discharge temperature (°C)"
range 0 60
default 50
config BAT_DISCHARGE_TEMP_MIN
int "Minimum discharge temperature (°C)"
range -20 20
default -10
endmenu # Custom temperature settings
endmenu # Battery default settings
menu "Load output settings"
depends on $(dt_node_has_bool_prop,/outputs/load,kconfig-flag)
config LOAD_OC_RECOVERY_DELAY
int "Overcurrent recovery delay (s)"
default 300
config LOAD_LVD_RECOVERY_DELAY
int "Low-voltage disconnect recovery delay (s)"
default 300
help
Prevents toggling load output in case of heavy load and low state of charge.
endmenu # Load output settings
endmenu # Charge controller setup
menu "UEXT port"
config UEXT_OLED_DISPLAY
select I2C
bool "OLED display"
config UEXT_OLED_BRIGHTNESS
depends on UEXT_OLED_DISPLAY
int "OLED display brightness"
range 1 255
default 1
config UEXT_SERIAL_THINGSET
depends on THINGSET_SERIAL
bool "Use UEXT serial for ThingSet interface"
default y
help
If the ThingSet interface is not attached to the serial port in the UEXT connector, the
serial in the LS.one port or the debug connector is used (if existing).
endmenu # UEXT port
menu "ThingSet interfaces"
config THINGSET_SERIAL
bool "ThingSet serial interface"
config THINGSET_SERIAL_RX_BUF_SIZE
depends on THINGSET_SERIAL
int "ThingSet serial RX buffer size"
range 64 2048
default 512
config THINGSET_SERIAL_TX_BUF_SIZE
depends on THINGSET_SERIAL
int "ThingSet serial TX buffer size"
range 256 2048
default 1024
config THINGSET_SERIAL_PUB_DEFAULT
bool "Enable serial publication messages at startup"
depends on THINGSET_SERIAL
default y
config THINGSET_CAN
depends on CAN
bool "ThingSet CAN interface"
config THINGSET_CAN_PUB_DEFAULT
bool "Enable CAN publication messages at startup"
depends on THINGSET_CAN
default y
config THINGSET_CAN_DEFAULT_NODE_ID
depends on THINGSET_CAN
int "ThingSet CAN default node ID"
range 0 255
default 20
config THINGSET_EXPERT_PASSWORD
string "ThingSet expert user password"
default "expert123"
config THINGSET_MAKER_PASSWORD
string "ThingSet maker password"
default "maker456"
endmenu # ThingSet interfaces
menu "Logging setup"
config CAN_LOG_LEVEL
int "Log level for the CAN module (if included)"
default 2
depends on LOG
help
Log level for the CAN module (if included). 0=off, 1=ERR, 2=WRN, 3=INF, 4=DBG
config DAQ_LOG_LEVEL
int "Log level for the DAQ module"
default 2
depends on LOG
help
Log level for the DAQ module. 0=off, 1=ERR, 2=WRN, 3=INF, 4=DBG
config DATA_OBJECTS_LOG_LEVEL
int "Log level for the data objects module"
default 2
depends on LOG
help
Log level for the data nodes module. 0=off, 1=ERR, 2=WRN, 3=INF, 4=DBG
config DATA_STORAGE_LOG_LEVEL
int "Log level for the data storage module"
default 2
depends on LOG
help
Log level for the data storage module. 0=off, 1=ERR, 2=WRN, 3=INF, 4=DBG
config DCDC_LOG_LEVEL
int "Log level for the DCDC module (if included)"
default 2
depends on LOG
help
Log level for the DCDC module (if included). 0=off, 1=ERR, 2=WRN, 3=INF, 4=DBG
config HW_LOG_LEVEL
int "Log level for the hardware module"
default 2
depends on LOG
help
Log level for the hardware module. 0=off, 1=ERR, 2=WRN, 3=INF, 4=DBG
config BAT_LOG_LEVEL
int "Log level for the battery module"
default 2
depends on LOG
help
Log level for the battery module. 0=off, 1=ERR, 2=WRN, 3=INF, 4=DBG
config PWM_LOG_LEVEL
int "Log level for the PWM module (if included)"
default 2
depends on LOG
help
Log level for the PWM module (if included). 0=off, 1=ERR, 2=WRN, 3=INF, 4=DBG
endmenu # Logging setup
menuconfig CUSTOMIZATION
bool "Firmware customization"
help
Activating this option allows to overwrite existing firmware functions
or add customizations independent of the main branch.
Custom implementations should be stored in the
src/custom subdirectory.
if CUSTOMIZATION
config CUSTOM_DATA_OBJECTS_FILE
bool "Use custom data nodes file"
default n
help
Use the file data_objects_custom.cpp instead of the default data_objects.cpp
for ThingSet configuration.
config CUSTOM_DCDC_CONTROLLER
bool "Custom implementation of DC/DC controller"
depends on $(dt_compat_enabled,half-bridge)
default n
help
Use a custom implementation instead of the default perturb & observe
MPPT control.
endif
# include custom Kconfig if existing
orsource "../src/custom/Kconfig"
#if 0
#orsource "modules/thingset/zephyr/Kconfig.thingset"
#endif
# include main Zephyr menu entries from Zephyr root directory
source "Kconfig.zephyr"
-47
View File
@@ -1,47 +0,0 @@
# Copyright (c) The Libre Solar Project Contributors
# SPDX-License-Identifier: Apache-2.0
description: Description for an ADC input including gain (multiplier/divider) and offset
compatible: "adc-inputs"
child-binding:
description: ADC inputs child node
properties:
io-channels:
type: phandle-array
required: true
description: |
ADC channel for this input.
multiplier:
type: int
required: true
description: |
Resistance of the lower leg of the voltage divider.
divider:
type: int
required: true
description: |
Resistance of the full path through the voltage divider.
offset:
type: int
required: false
description: |
Offset to be substracted from ADC raw reading before applying the gain
filter-const:
type: int
default: 5
description: Low-pass filter multiplier 1/(2^filter-const)
enable-gpios:
type: phandle-array
required: false
description: |
Enable the voltage divider input or amplifier.
If present the corresponding GPIO must be set to an active level
to enable the divider input.
@@ -1,62 +0,0 @@
# Copyright (c) The Libre Solar Project Contributors
# SPDX-License-Identifier: Apache-2.0
description: Generic charge controller device setup
compatible: "charge-controller"
properties:
type:
type: string
required: true
description: Device type
version-str:
type: string
required: true
description: Hardware version number (human-readable)
version-num:
type: int
required: true
description: Hardware version number (usable in preprocessor defines)
hs-voltage-max:
type: int
required: true
description: Maximum voltage at high-side (typically PV input) in volts
ls-voltage-max:
type: int
required: true
description: Maximum voltage at low-side (typically battery) in volts
dcdc-current-max:
type: int
description: Maximum inductor current in amps (if existing in the charge controller)
internal-tref-max:
type: int
default: 50
description: |
Internal reference temperature at full load (°C)
This value is used for model-based control of overcurrent protection. It represents
the steady-state internal temperature for max. continuous current at ambient
temperature of 25°C. Default value is conservative and can be overwritten in PCB
configuration.
mosfets-tj-max:
type: int
default: 120
description: |
Maximum Tj of MOSFETs (°C)
This value is used for model-based control of overcurrent protection. It represents
the steady-state junction temperature for max. continuous current at ambient
temperature of 25°C.
mosfets-tau-ja:
type: int
default: 5
description: |
Thermal time constant junction to ambient (s)
This value is used for model-based control of overcurrent protection. It does not reflect
the much lower MOSFET-internal time constant junction to case, but includes thermal
inertia of the board.
Around 5s seems to be a good conservative estimation for 5x6 type SMD MOSFETs. Take larger
values for big heat sinks.
@@ -1,19 +0,0 @@
# Copyright (c) The Libre Solar Project Contributors
# SPDX-License-Identifier: Apache-2.0
description: Description for an ADC input including gain (multiplier/divider) and offset
compatible: "charlieplexing-leds"
properties:
gpios:
type: phandle-array
description: GPIO handle of pin
child-binding:
description: GPIO child node
properties:
states:
type: array
description: |
Pin states to switch on LED identified by child node. 1=on, 0=off, 2=floating
-28
View File
@@ -1,28 +0,0 @@
# Copyright (c) The Libre Solar Project Contributors
# SPDX-License-Identifier: Apache-2.0
description: Half bridge, consisting of two coupled PWM outputs
compatible: "half-bridge"
include: base.yaml
properties:
frequency:
type: int
required: true
description: PWM frequency in Hz
deadtime:
type: int
required: true
description: Dead time for synchronous PWM generation in nanoseconds
pinctrl-0:
type: phandles
required: false
description: |
GPIO pin configuration for PWM signal/s. We expect that the phandles
will reference pinctrl nodes, e.g.
pinctrl-0 = <&tim1_ch1_pwm_pa8 &tim1_ch2_pwm_pa9>;
-29
View File
@@ -1,29 +0,0 @@
# Copyright (c) The Libre Solar Project Contributors
# SPDX-License-Identifier: Apache-2.0
description: GPIOs used for digital output (either on/off type or PWM signal)
compatible: "outputs"
child-binding:
description: GPIO digital outputs child node
properties:
gpios:
type: phandle-array
description: GPIO handle for on/off type output
pwms:
type: phandle-array
description: PWM handle for PWM type output
latching-pgood:
type: boolean
description: Driver for latching power good pin (optional)
current-max:
type: int
description: Maximum current of driven power switch (A)
label:
type: string
required: true
description: Human readable string describing the device (used by Zephyr for API name)
kconfig-flag:
type: boolean
description: This value can be checked by Kconfig parser using dt_node_has_bool_prop function
-15
View File
@@ -1,15 +0,0 @@
# Copyright (c) The Libre Solar Project Contributors
# SPDX-License-Identifier: Apache-2.0
description: ADC similar to STM32 for unit tests
compatible: "zephyr,dummy-adc"
include: adc-controller.yaml
properties:
"#io-channel-cells":
const: 1
io-channel-cells:
- input
-21
View File
@@ -1,21 +0,0 @@
# Copyright (c) The Libre Solar Project Contributors
# SPDX-License-Identifier: Apache-2.0
description: PWM similar to STM32 for unit tests
compatible: "zephyr,dummy-pwm"
include: [pwm-controller.yaml, base.yaml]
properties:
label:
required: true
"#pwm-cells":
const: 3
pwm-cells:
- channel
# period in terms of nanoseconds
- period
- flags
-46
View File
@@ -1,46 +0,0 @@
# Main application configuration (overrides board-specific settings)
# only very small heap necessary for malloc in printf statements with %f
CONFIG_HEAP_MEM_POOL_SIZE=256
CONFIG_CPLUSPLUS=y
CONFIG_LIB_CPLUSPLUS=y
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_WATCHDOG=y
CONFIG_WDT_DISABLE_AT_BOOT=y
CONFIG_TASK_WDT=y
CONFIG_THREAD_NAME=y
CONFIG_REBOOT=y
CONFIG_HWINFO=y
CONFIG_CONSOLE_SUBSYS=y
CONFIG_CONSOLE_GETCHAR=y
# Use minimal logging by default to save memory for STM32F0 with little RAM
CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=y
CONFIG_THINGSET=y
# ThingSet protocol interface via UART serial
CONFIG_THINGSET_SERIAL=y
# Uncomment to disable regular data publication on ThingSet serial at startup
#CONFIG_THINGSET_SERIAL_PUB_DEFAULT=n
# Uncomment to use LS.one or debug RX/TX connector instead of UEXT serial for ThingSet
#CONFIG_UEXT_SERIAL_THINGSET=n
# Uncomment to enable I2C OLED display in UEXT connector
#CONFIG_UEXT_OLED_DISPLAY=y
# Select initial battery configuration: GEL (default), FLOODED, AGM, LFP, NMC or NMC_HV
#CONFIG_BAT_TYPE_???=y
# Change number of cells considering selected type (12V/24V battery by default if not set)
#CONFIG_BAT_NUM_CELLS=?
-32
View File
@@ -1,32 +0,0 @@
manifest:
remotes:
- name: zephyrproject
url-base: https://github.com/zephyrproject-rtos
- name: libresolar
url-base: https://github.com/LibreSolar
- name: thingset
url-base: https://github.com/ThingSet
- name: throwtheswitch
url-base: https://github.com/ThrowTheSwitch
projects:
- name: zephyr
remote: zephyrproject
revision: v2.7-branch
# path must be something else than zephyr as we get a Kconfig include recursion otherwise
path: rtos
import:
# main zephyr modules should be placed in here into zephyr subdirectory
path-prefix: zephyr
# only get modules we actually need
name-allowlist:
- cmsis
- edtt
- hal_stm32
- name: thingset-device-library
remote: thingset
revision: 1eaa305a9f1873f676b77b8dd0f9d34f1944ecd1
path: zephyr/modules/thingset
- name: unity
path: zephyr/modules/unity
revision: 74cde089e65c3435ce9aa87d5c69f4f16b7f6ade
remote: throwtheswitch