Commit Graph

32 Commits

Author SHA1 Message Date
Bastian de Byl 5dc715558f fix: CheckDelay returns false forever when timedly is negative
Build Firmware / Build stm32-teslacharger (pull_request) Successful in 1m1s
Upstream openinverter bug surfaced after recent SKUDAK PRs.

Symptom (reported by Kyle on the bench): teslacharger detects EVSE,
shows the AC limit, but stays stuck in WaitStart and never proceeds
to Enable / Activate / Run. State machine looks like it's the OFF
state but it's actually one step further on.

Root cause in src/charger.cpp:85-91:

    bool CheckDelay()
    {
       uint32_t now = rtc_get_counter_val();
       uint32_t start = Param::GetInt(Param::timedly) * 60;
       return start <= 0 || (now - startTime) > start;
    }

With timedly = -1 (the param's documented "no delay" sentinel and its
default value), the math is:

    Param::GetInt(timedly) -> -1 (signed int)
    -1 * 60 -> -60 (signed)
    assigned to uint32_t -> 0xFFFFFFC4 (~4.29 billion)
    start <= 0 -> false (uint32_t can't be negative)
    (now - startTime) > 4294967236 -> false for ~136 years

So CheckDelay() returns false forever; charger wedges in WaitStart.

Why "it was working before": every SKUDAK PR that bumped the param
table (uaux broadcast, expanded 0x210, 0x210->0x211, version suffix)
invalidates the saved-params CRC and resets timedly to its -1 default.
Kyle had a non-default value (probably 0) saved before.

Fix: signed math for the short-circuit so timedly <= 0 still means
"start immediately." Cast to uint32_t only on the right operand, which
is only evaluated when start > 0 — can't reinterpret negative as huge.

The companion CheckTimeout() at line 75 has the same uint32_t pattern
but works "correctly by accident" because timelim = -1 makes timeout
huge and (now - startTime) > timeout is false, which matches the
intended "no timeout" semantics. Leaving that alone — fixing it would
change behaviour, not bugs.

VER suffix bumped -S1 -> -S2 so the OI web UI clearly shows the
deployed firmware (post-fix). Confirmed in built binary as
"4=1.19.R-S2".

Build: text=25192, links clean, pre-existing pedantic warning unchanged.

This bug is also present upstream (johanneshuebner/stm32-charger);
worth a PR upstream once we've confirmed the fix on the bench.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-10 09:34:17 -04:00
bastian f566427835 Merge pull request 'fix: move SKUDAK telemetry to 0x211 + add -S1 version suffix' (#3) from fix/skudak-448-move-telemetry-to-0x211 into main
Build Firmware / Build stm32-teslacharger (push) Successful in 59s
2026-05-09 17:59:39 -04:00
Bastian de Byl 00f359250c chore: add SKUDAK -S1 version suffix to VERSTR
Build Firmware / Build stm32-teslacharger (pull_request) Successful in 59s
The OpenInverter web UI displays the firmware version from the 'version'
parameter (entry 2001), which expands VERSTR. Out of the box this reads
'4=1.19.R' (upstream version, no Skudak indicator). With this change it
reads '4=1.19.R-S1' so we can visually confirm we're running the Skudak
fork and not stock OpenInverter firmware.

Matches the convention already used in stm32-sine ('-sine-S6' / '-foc-S6')
where the -S<N> suffix bumps on each Skudak-side change.

Verified: 'strings stm32_charger.bin | grep S1' shows '4=1.19.R-S1' in the
built artifact.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 17:57:45 -04:00
Bastian de Byl 7de46b8160 fix: move SKUDAK telemetry frame from 0x210 → 0x211 (avoid bus contention)
Build Firmware / Build stm32-teslacharger (pull_request) Successful in 59s
Bench capture on the green car showed a non-Polarity module also
broadcasting at 0x210 (DLC=8 frame with mostly-zero payload, byte 5 = 0x85
static — likely a Tesla OEM DI module). Even after a clean reflash + 'can c'
to clear persisted maps, the rogue 0x210 frame keeps appearing on the wire,
racing our intended frame and intermittently corrupting the VCU's read.

Confirmed via 'can p' on the OBC that this firmware's CanMap has exactly
one 0x210 entry with the 5 expected fields — the conflict is external.

Moves all five AddSends to 0x211, an adjacent free ID. The VCU's
CHARGER_CAN_ID_OI_OBC_AUX constant is updated to match in a paired
stm32-hal-vcu PR. Same 7-byte expanded layout (state/udc/idc/uaux@5/soc),
same 100ms cadence — only the arbitration ID changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 18:54:54 -04:00
bastian 20339b738b Merge pull request 'feat: expand 0x210 telemetry layout (state/udc/idc/uaux@5/soc)' (#2) from feat/skudak-448-expanded-0x210-telemetry into main
Build Firmware / Build stm32-teslacharger (push) Successful in 59s
2026-05-08 17:00:30 -04:00
Bastian de Byl 3580123a39 feat: expand 0x210 telemetry layout (state/udc/idc/uaux@5/soc) for SKUDAK-448
Build Firmware / Build stm32-teslacharger (pull_request) Successful in 59s
Replaces the single uaux-at-byte-0 broadcast (commit d209a47) with a
7-byte expanded telemetry frame. Bench capture on green car showed dual
0x210 frames colliding (DLC=8 simple + DLC=7 expanded) because Kyle's
flashed image had both AddSend sets active; standardising on the
expanded layout eliminates that ambiguity.

Byte layout:
  byte 0     state    (0=Off, 1=WaitStart, 2=Enable, 3=Activate, 4=Run, 5=Stop)
  bytes 1-2  udc      (V, gain=1)
  bytes 3-4  idc      (0.1A, gain=10)
  byte 5     uaux     (decivolts, gain=10) — 12V aux battery rail
  byte 6     soc      (%, gain=1)
  byte 7     reserved

Consumed by stm32-hal-vcu Core/Src/main.c CHARGER_CAN_ID_OI_OBC_AUX
handler. The state byte enables future VCU_IsCharging integration via
state == 4 (Run) without requiring a second CAN ID.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 16:48:48 -04:00
bastian 877508d047 Merge pull request 'feat: broadcast uaux (12V aux battery) on CAN 0x210 (SKUDAK-448)' (#1) from feat/uaux-can-broadcast into main
Build Firmware / Build stm32-teslacharger (push) Successful in 1m0s
2026-05-07 21:23:21 -04:00
Kyle 3d2dbbc709 fix: create obj/ directory before parallel build
Build Firmware / Build stm32-teslacharger (pull_request) Successful in 59s
2026-04-30 11:01:41 -04:00
Kyle 69822ca08e fix: use 'make get-deps' and 'make images' to skip host unit tests in CI
Build Firmware / Build stm32-teslacharger (pull_request) Failing after 1m0s
2026-04-30 10:40:24 -04:00
Kyle 7f1d417db6 fix: use HTTPS submodule URLs for CI (SSH has no GitHub key on runner)
Build Firmware / Build stm32-teslacharger (pull_request) Failing after 20s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-30 10:01:40 -04:00
Kyle 224e7ff286 ci: add Gitea Actions build workflow
Build Firmware / Build stm32-teslacharger (pull_request) Failing after 16s
Builds firmware on PR/push to main. Initializes libopencm3 and
libopeninv submodules then runs make. Uploads stm32_charger.bin
as a 30-day retained artifact.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-30 09:55:53 -04:00
Kyle d209a472a6 feat: broadcast uaux (12V aux battery) on CAN 0x210 (SKUDAK-448)
Adds AddSend for Param::uaux at CAN ID 0x210, bit 0, length 8, gain=10.
Transmits 12V aux battery voltage in decivolts/0.1V steps (e.g. 125 = 12.5V).
VCU reads byte 0 of 0x210 for 12V battery protection logic per SKUDAK-448.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-30 09:49:56 -04:00
johannes 0de1be186a Updated to latest libopeninv 2024-06-12 15:43:36 +02:00
johannes b4029be7a0 Updated to latest libopeninv 2023-12-15 17:56:07 +01:00
johannes 7de1ca7d1d Upgraded to later CAN module
fixed type
2023-01-23 11:32:15 +01:00
johannes fada3b0cba using submodules 2023-01-23 11:30:16 +01:00
Janosch 3ba4f26b43 move to charger.cpp complete, stubs & TODOs for missing tests 2022-10-14 13:24:43 +01:00
Janosch 100821e68c testing calc enable 2022-10-14 13:08:23 +01:00
Janosch b45c29f89e test reset values 2022-10-11 13:38:50 +01:00
Janosch 8e61ddd188 test_check_delay 2022-10-11 13:28:13 +01:00
Janosch e54de68605 test CheckVoltage 2022-10-11 12:20:37 +01:00
Janosch 7481f0f7e8 test CheckStartCondition 2022-10-11 12:12:07 +01:00
Janosch 7a3dd9fb89 moving definition to charger.cpp 2022-10-11 11:45:51 +01:00
Janosch 7b038d5243 mocked timer test, EvseRead 2022-10-11 00:05:01 +01:00
Janosch 52877fb3ea might as well tell people what I am doing 2022-10-10 22:37:12 +01:00
Janosch d7673cd292 timer mocking 2022-10-10 22:34:56 +01:00
Janosch 5c8f5694f0 charger.h 2022-10-10 20:04:18 +01:00
Janosch 0e43f2bf8c testing some simple math examples 2022-10-10 17:40:57 +01:00
Janosch a6f275b742 adding repetitive DigIo mock test 2022-10-10 16:46:25 +01:00
Janosch 624b33ee73 removing declaration from main 2022-10-10 12:47:33 +01:00
Janosch 2327ae7aab adding dependencies 2022-10-10 12:39:30 +01:00
Janosch 0e8e1e4db6 initial commit for tests 2022-10-10 11:46:30 +01:00