Clean up prj.conf and improve documentation

This commit is contained in:
Martin Jäger
2021-04-14 12:23:07 +02:00
parent 1943533360
commit 613e454fed
4 changed files with 63 additions and 56 deletions
+41 -35
View File
@@ -86,40 +86,6 @@ Report of used memory (RAM and flash):
west build -t rom_report
west build -t ram_report
### Troubleshooting
#### Errors with STM32L072 MCU using OpenOCD
The standard OpenOCD settings sometimes fail to flash firmware to this MCU, which is used in the MPPT 1210 HUS and the PWM charge controller.
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`.
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.
## Firmware customization
This firmware is developed to allow easy customization for individual use-cases. Below options based on the Zephyr devicetree and Kconfig systems try to allow customization without changing any of the files tracked by git, so that a `git pull` does not lead to conflicts with local changes.
@@ -153,7 +119,7 @@ CONFIG_BAT_TYPE_LFP=y
CONFIG_BAT_NUM_CELLS=4
```
#### Define serial for ThingSet protocol
#### Configure serial for ThingSet protocol
By default, the charge controller uses the serial interface in the UEXT connector for the [ThingSet protocol](https://libre.solar/thingset/). This allows to use WiFi modules with ESP32 without any firmware change.
@@ -163,6 +129,12 @@ Add the following configuration if you prefer to use the serial of the LS.one po
CONFIG_UEXT_SERIAL_THINGSET=n
```
To disable regular data publication in one-second interval on ThingSet serial at startup add the following configuration:
```
CONFIG_THINGSET_SERIAL_PUB_DEFAULT=n
```
### Custom functions (separate C/C++ files)
If you want experiment with some completely new functions for the charge controller, new files should be stored in a subfolder `src/custom`.
@@ -200,3 +172,37 @@ PlatformIO integrates cppcheck and clangtidy. The following command is an exampl
- [Charge controller basic concepts](docs/charger-concepts.md)
- [Firmware module overview](docs/module-overview.md)
## Troubleshooting
### Errors with STM32L072 MCU using OpenOCD
The standard OpenOCD settings sometimes fail to flash firmware to this MCU, which is used in the MPPT 1210 HUS and the PWM charge controller.
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`.
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.
+3 -3
View File
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#if CONFIG_EXT_OLED_DISPLAY
#if CONFIG_UEXT_OLED_DISPLAY
#include <math.h>
#include <stdio.h>
@@ -178,7 +178,7 @@ void oled_thread()
DT_GPIO_FLAGS(UEXT_EN_GPIO, gpios) | GPIO_OUTPUT_ACTIVE);
#endif
oled.init(CONFIG_EXT_OLED_BRIGHTNESS);
oled.init(CONFIG_UEXT_OLED_BRIGHTNESS);
while (true) {
oled_update();
@@ -188,4 +188,4 @@ void oled_thread()
K_THREAD_DEFINE(oled_thread_id, 1024, oled_thread, NULL, NULL, NULL, 6, 0, 1000);
#endif /* CONFIG_EXT_OLED_DISPLAY */
#endif /* CONFIG_UEXT_OLED_DISPLAY */
+3 -3
View File
@@ -315,12 +315,12 @@ endmenu # Charge controller setup
menu "UEXT port"
config EXT_OLED_DISPLAY
config UEXT_OLED_DISPLAY
select I2C
bool "OLED display"
config EXT_OLED_BRIGHTNESS
depends on EXT_OLED_DISPLAY
config UEXT_OLED_BRIGHTNESS
depends on UEXT_OLED_DISPLAY
int "OLED display brightness"
range 1 255
default 1
+16 -15
View File
@@ -8,8 +8,6 @@ CONFIG_CPLUSPLUS=y
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_BUILD_OUTPUT_BIN=y
CONFIG_WATCHDOG=y
CONFIG_WDT_DISABLE_AT_BOOT=y
CONFIG_TASK_WDT=y
@@ -19,21 +17,24 @@ CONFIG_REBOOT=y
CONFIG_HWINFO=y
CONFIG_GPIO=y
CONFIG_SERIAL=y
CONFIG_CONSOLE_SUBSYS=y
CONFIG_CONSOLE_GETCHAR=y
# direct printf calls to console
CONFIG_STDOUT_CONSOLE=y
# use minimal log by default to save memory for STM32F0 with little RAM
# Use minimal logging by default to save memory for STM32F0 with little RAM
CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=y
# ThingSet protocol interface at UART serial
# ThingSet protocol interface via UART serial
CONFIG_THINGSET_SERIAL=y
# I2C OLED display in UEXT connector
#CONFIG_EXT_OLED_DISPLAY=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=?