My Self-Driving G-Wagon

truck / 6 / Engine ECU, Bosch ME 2.8.1

Engine ECU: a torque request on CAN

The M113K's ME 2.8.1 accepts a torque request on CAN at 50 Hz with a 100 ms watchdog, while the ESP keeps traction cuts and brake state. The patch is assembly, built by a pipeline that refuses what it cannot justify, run inside an emulator of the ECU, and written to 4 of 11 flash sectors. Checked with the key on and the engine off; not yet on the road. measured

Spec

ControllerBosch ME 2.8.1, M113K 5.4 L supercharged V8
CPUInfineon C167 (C166 family)
FlashAm29F400BB, 512 KB, 11 sectors
Base imagestock Bosch code + the existing calibration, unchanged
Addedtorque request handler; 10 Hz engine telemetry on CAN
Request rate50 Hz
Resolution0.25 N·m
Watchdog100 ms: no fresh request, back to passive
Kept by the truckESP traction cuts and brake state; brake, ESP and liveness gates in the handler
Writtensectors 7-10, 256 KB, 262,144 bytes in 376.5 s over K-line
In the truck since3 Nov 2026
Checkedkey on, engine off: request 2,500 read as +125.00 N·m, valid, then passive
Not yetno torque request on the road

Flash map

Am29F400BB, 512 KB, 11 sectors. Blue: erased and written. Dashed: never written.0boot1234calibration564 KB664 KB764 KB864 KB964 KB1064 KB

Telemetry the patch adds 10 Hz on CAN, read at idle, key cycle after the flash

Manifold pressure33 kPa
Injection time, bank 1about 2.46 ms
Spark-11.0°
Short-term fuel trim, bank 1+4.7 %

History

  • first ECU probing sessions over K-line
  • first patched image flashed; torque path checked key on, engine off; 10 Hz telemetry on CAN
  • patches rebuilt from assembly; checks now run the stock code around each patch
  • current image written, 376.5 s

Faults found, and what catches them now each could have been found on the desk

FaultCauseSeen asNow
Torque path not passivethe patch assumed the ESP's own torque request stays passiveon the truck it was nothandled in the selector; emulator case
Wrong memory reada data page register was not set when reading the CAN message bufferread garbage on the truckregister set and restored; emulator case
Frame gone before readthe stock handler cleared the new-data flag firstthe patch never saw the framea gate passes only full-length frames to the stock handler
Jump out of the call framefirst assembled rewrite returned through a stock routineroutine body ran twice; the stack still balancedhook contract: enter and leave only by call and return

Checks before a flash all must pass; bytes are build output, never input

CheckResultWhat it does
Splice refusals7 kindswrong base hash, manifest mismatch, overlap, outside the image, source/manifest disagree, writing over non-erased code, outside the flashed sectors
Stock routine around the patchbyte-exactBosch's CAN routine run in the emulator from the hook to its return; equal to stock except the one frame handled
Telemetry staging64 KB state preservedRAM, registers and flags byte for byte across 3 message slots, key on and running
Channel sweep1,024 valuesevery byte value of the four telemetry channels
Manifold-pressure input sweep1,024 valuesevery 10-bit reading of the MAP sensor's producer
Bit flips256 of 256 caughtevery single-bit flip of the 32-byte region
Mutation tests0 unexplained survivorsevery surviving mutant must be pinned with a reason
Flasher gates5 + simulated flashincluding a connection dropped halfway and recovered
Before the eraseevery sectora checksum pass showed the car's image matched the build's base byte for byte
After the writesectors 7-10 + 12 rangeschecksums answered for the new image; a wrong sum was refused

Pipeline

patch.s
→ assembler (Ghidra C166 module)
→ splice (7 refusals)
→ emulator: stock code runs around the patch
→ mutation, differential, 5 flasher gates
→ flash sectors 7-10, read back, compare

Emulator

CPUC167 core
FlashAm29F400BB, boot-sector erase and pre-erase marker
Checksums32 + 2 descriptors
Gatereset gate, split-buffer selector

Limits

No torque request has driven the truck on the road.
A dealer or tuner reflash removes the patch without warning.
Engine torque only; braking is a separate open question.