Skip to content

volvo: solve PSCM_RELATED CHECKSUM_2, fix invalid checksum during rack fault - #11

Open
joeywritesc wants to merge 1 commit into
paper5590:master-cma-dev5from
joeywritesc:volvo-pscm-checksum-2
Open

joeywritesc wants to merge 1 commit into
paper5590:master-cma-dev5from
joeywritesc:volvo-pscm-checksum-2

Conversation

@joeywritesc

Copy link
Copy Markdown

Same class of bug as the ECHO=6 fix for CHECKSUM_1, this time in CHECKSUM_2.

Problem
When the rack resets itself mid-drive it switches 0x17 byte[2] from 0x8_ to 0xA_ and holds it until the car is power cycled. checksum_2_pscm_related_message was a lookup table over 0x80..0x8E only, so for 0xA_ it returned 0x00, and every 0x17 frame forwarded to the car during a rack fault had an invalid CHECKSUM_2. CHECKSUM_1 (your GF(2) formula) already handles 0xA_ correctly.

Data
A Polestar 2 drive (Nov 7) with a real power-steering failure on StarPilot. The rack data is independent of the fork.

  • 12,374 normal-state rack frames: old table correct, new formula correct
  • 7,450 fault-state rack frames: old table wrong on every one, new formula correct on every one

Fix
Replace the table with the linear GF(2) function: each set bit of byte[2] flips a fixed pattern of checksum bits. Solved from the 30 observed byte[2] values; leave-one-out predicts 30/30, and all 15 previous table entries are reproduced exactly.

Test
test_checksum_2_covers_rack_fault_state adds the 15 fault-state values. It fails on the current code (b2=0xA0: 0 != 0x85) and passes with the fix. ./test.sh has the same pre-existing failures before and after.

Caveat
The fault-state data is from one car and one drive. Bits 4 and 6 of byte[2] have never been seen set, so the formula assumes they flip nothing.

Possible follow-up (separate PR): byte[2] = 0xA_ appears ~690 ms after the rack reboots, on both failures I've looked at, so it could set steerFaultPermanent for a proper alert.

Validation

  • Dongle ID: N/A, no comma device yet. Data is from another owner's route (can share privately)
  • Route: Polestar 2, Nov 7 2026, real power-steering failure on StarPilot

…k fault

checksum_2_pscm_related_message was a 15-entry lookup table over
byte[2] = 0x80..0x8E, returning 0 on a miss. After the rack resets itself
mid-drive it reports byte[2] = 0xA0..0xAE (fault state) until the car is
power cycled, so every 0x17 frame openpilot forwarded to the car during a
rack fault carried an invalid checksum (0x00).

Replace the table with the underlying function: like CHECKSUM_1 it is
linear over GF(2), so each set bit of byte[2] flips a fixed pattern of
checksum bits. Solved from 19,824 rack frames from one Polestar 2 drive
with a real power-steering fault (7,450 frames in the fault state),
spanning 30 distinct byte[2] values. Leave-one-out cross-validation
predicts 30/30, and all 15 previous table entries are reproduced exactly.
Bits 4 and 6 of byte[2] were never observed set and are taken to flip
nothing.

Adds a regression test with the 15 fault-state values. ./test.sh shows
the same pre-existing failures before and after this change.
@github-actions github-actions Bot added the car label Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant