resizeable VE table - #791
Conversation
|
Here is Opus 5 PR review: Overall: design is right and the generator work is clean. Two real safety holes on the firmware side. Blocking
Allocation is veLoadBins[32], veRpmBins[32], veTable[576]. But maxRows * maxCols = 1024 > 576, so the axis maxima and the cell budget cannot both be satisfied by construction — the product must be enforced at read time. getVeImpl passes the raw config bytes straight through. Consequences with rows=32, cols=32: interpolate3dDynamic indexes up to table[1023] — 448 cells (896 bytes) past the array. A garbage count byte (rows=200) also walks bins[199] past a 32-entry array. Result is a uint16_t of adjacent config reinterpreted as VE, up to 6553% — commanded on a running engine. Clamp once, in interpolate3dDynamic or a shared helper:
ensureArrayIsAscendingDynamic(..., config->veTableRows) runs before the size check, so a corrupt count reads out of bounds inside the validator itself. Move the size check first. The size check is also insufficient: it tests the product only. rows=200, cols=2 → 400 ≤ 576, passes, and veLoadBins[199] is still out of bounds. Each axis needs checking against its own bin array too. Worth fixing before merge
Related: those bin arrays are still declared [FUEL_RPM_COUNT] / [FUEL_LOAD_COUNT], defines that no longer have anything to do with the VE table. Bumping FUEL_RPM_COUNT would silently reshape those engines. |
You can now resize the VE table in TS to use up to 576 cells, with axis sizes of 8-32. That means 24x24, 32x18, 27x21, etc, anything that meets those constraints.