From 1803f9b41d02c162f9c1e58ecd4fee7d25c96c9b Mon Sep 17 00:00:00 2001 From: Bastian de Byl Date: Thu, 14 May 2026 22:06:52 -0400 Subject: [PATCH] fix: rebuild stale CAN map on firmware upgrade (new tmpobcmax canary) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The openinverter single-shot MapMessages() guard was using Param::hwaclim as a "is the map valid" canary. hwaclim has been in every firmware version for years, so on every upgrade the guard finds it in the saved flash map and short-circuits — new AddRecv/AddSend entries in chargercan.cpp never make it into the live canMap. Symptom on the -S5 bench (verified via openinverter web UI spot values): tmpobcmax, c1*/c2*/c3* per-module receives, and canenable/idcspnt/udclim CHAdeMO RX entries were all unmapped despite being in current source. The Polarity app saw zero charger temperature, zero per-module current/voltage, and tmpobcmax=0 on 0x211 byte 7. Fix: switch the canary from hwaclim -> tmpobcmax (added in -S5, never present in older saved maps) and uncomment canMap->Clear() so the rebuild starts clean. The early-return guard still kicks in on every subsequent boot once tmpobcmax is in the map, preserving the original intent of letting user customizations persist across reboots. Also bumps VERSTR S5 -> S6 so the openinverter web UI labels this firmware distinctly from the prior -S5 flash. #minor Co-Authored-By: Claude Opus 4.7 (1M context) --- include/param_prj.h | 2 +- src/main.cpp | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/param_prj.h b/include/param_prj.h index d35551a..646a4ff 100644 --- a/include/param_prj.h +++ b/include/param_prj.h @@ -129,7 +129,7 @@ // SKUDAK customization suffix: bump on every Skudak-side change so the OpenInverter // web UI shows a distinct version (e.g. "4=1.20.R-S4") and we can visually confirm // the right firmware is flashed. Match the stm32-sine -S convention. -#define VERSTR STRINGIFY(4=VER-S5) +#define VERSTR STRINGIFY(4=VER-S6) /***** enums ******/ diff --git a/src/main.cpp b/src/main.cpp index 790efe8..7d490d6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -114,10 +114,22 @@ static void MapChargerMessages() float dummyGain; bool dummyrx; - //check sample value, if it is mapped assume valid CAN map - if (canMap->FindMap(Param::hwaclim, dummyId, dummyOfs, dummyLen, dummyGain, dummyAdd, dummyrx)) return; + // SKUDAK: tmpobcmax is the canary for the -S5+ CAN-map schema. If it's + // already mapped, the persistent flash map was built by a firmware that + // included the full current set of mappings (including the OBC temp + // aggregate and all c1*/c2*/c3* receives) — return early so user + // customizations are preserved. + // + // If tmpobcmax is NOT mapped, the saved map is from an older firmware + // that didn't know about it. We must wipe and rebuild from current + // chargercan.cpp — without this the OpenInverter single-shot MapMessages() + // pattern silently leaves newer params un-mapped on every subsequent + // boot, even after flashing fresh firmware (the original guard keyed off + // hwaclim, which has existed since the very first version — so it always + // short-circuited on upgrade and the new entries were dead code). + if (canMap->FindMap(Param::tmpobcmax, dummyId, dummyOfs, dummyLen, dummyGain, dummyAdd, dummyrx)) return; - //canMap->Clear(); + canMap->Clear(); ChargerCAN::MapMessages(canMap);