From 613e454fed0696f6af49b986de5b8a35e2bb0529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20J=C3=A4ger?= Date: Wed, 14 Apr 2021 12:22:38 +0200 Subject: [PATCH] Clean up prj.conf and improve documentation --- README.md | 76 ++++++++++++++++++++++++++---------------------- src/ext/oled.cpp | 6 ++-- zephyr/Kconfig | 6 ++-- zephyr/prj.conf | 31 ++++++++++---------- 4 files changed, 63 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index 71bd953..5f9f362 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/ext/oled.cpp b/src/ext/oled.cpp index d8113ec..1811a48 100644 --- a/src/ext/oled.cpp +++ b/src/ext/oled.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#if CONFIG_EXT_OLED_DISPLAY +#if CONFIG_UEXT_OLED_DISPLAY #include #include @@ -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 */ diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 461cb78..98bff88 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -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 diff --git a/zephyr/prj.conf b/zephyr/prj.conf index 22209e9..b3d4022 100644 --- a/zephyr/prj.conf +++ b/zephyr/prj.conf @@ -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=?