Commit a709055
fix(fw): move odometer to its own flash sector (sector 6 bank 2)
The odometer and motion_config (calibration JSON) were both writing to
sector 7 bank 2 (0x081E0000) via `FLASH_USER_START_ADDR`. STM32H7 flash
can only be erased at sector granularity, and both modules call
`Flash_Erase` for the full sector on save. Whichever wrote last wiped
the other tenant's data.
Symptom: flashing the integration branch onto a console that already had
a stored calibration produced "no calibration on device or invalid" on
the next connect, because `Odometer_Init` saw a non-magic block (the
calibration JSON), treated it as first-boot, and erased the sector to
write a fresh zero odometer block.
Fix: dedicate sector 6 bank 2 (0x081C0000) to the odometer.
- STM32H743XX_FLASH.ld + STM32H743VIHX_FLASH.ld: trim FLASH region from
1920 KB to 1792 KB so the linker reserves both sectors 6 and 7 of
bank 2 for persistent data. (Code uses 8.5% of the remaining region;
no risk of crowding.)
- memory_map.h: add FLASH_ODOMETER_START_ADDR alongside FLASH_USER_START_ADDR.
- odometer.h: point ODOMETER_FLASH_BASE_ADDR at the new sector and
document why the two stores must not co-tenant.
Action for already-flashed consoles: calibration must be re-loaded (or
re-run) once after flashing this build, since the existing calibration
on hardware that ran the buggy firmware was already wiped. After this
flash, calibration and odometer writes are independent — no further
clobbering.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent cde2d0f commit a709055
4 files changed
Lines changed: 29 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
40 | 46 | | |
41 | 47 | | |
42 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | | - | |
16 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
17 | 24 | | |
18 | 25 | | |
19 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
64 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
65 | 69 | | |
66 | 70 | | |
67 | 71 | | |
| |||
0 commit comments