fix: rebuild stale CAN map on firmware upgrade (new tmpobcmax canary)
Build Firmware / Build stm32-teslacharger (pull_request) Successful in 58s

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) <noreply@anthropic.com>
This commit is contained in:
Bastian de Byl
2026-05-14 22:06:52 -04:00
parent 2c9e7a8bbe
commit 1803f9b41d
2 changed files with 16 additions and 4 deletions
+1 -1
View File
@@ -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<N> convention.
#define VERSTR STRINGIFY(4=VER-S5)
#define VERSTR STRINGIFY(4=VER-S6)
/***** enums ******/
+15 -3
View File
@@ -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);