Skip to main content
NewEpisode 3a is out: Carry the conversation onWatch →

This part is for members

Membership opens soon. Leave your email and we'll tell you the day it does. Founding members get the launch price.

Keep watching the free parts
Data & comms · 28b

Parameter storage 2: what a save does not keep

A save can succeed and the value still not come back. It opens with the whole episode on one framework page: a save keeps only the fields listed in one struct (FLASH_PARAM_STRUCT), and the NonVolatile column of the parameter table servo_hub_database_all.csv decides that list (132 rows marked 1, exactly the 132 fields flash_param_update fills); after power-up each value is written in turn, default (AppParamInit / MotorCtrlInit) → the block (flash_param_init) → the setter (app_param_update) → any code that runs every tick, and the last writer wins. The page: one row per value, one column per writer, the block's bytes underneath, the real runs beside. Running example: 27b's MIT gains, Kp 20 and Kd 0.014, saved and power-cycled: 0.01 after the reboot. The bench: 28a's flash bench (boot_flash) in MIT mode, with new --mit-watch / --mit-hold options. Five stops: what the block holds (180 fields, only 132 filled; 46 of the other 48 are old names of live fields, like Can_Id, that only hold their place; MIT_kp's row is empty); two copies of one gain (the app layer's kAppMotionParam.MIT_kp is what the host writes, and its setter only stores it; the control layer's kAxis.mit_ctl_config.kp_pos_NM_rad is what mit_ctl, the spring, uses; every position-loop tick MitModeRun takes the first over the gear ratio and MitTrajectoryPlanningHandle writes it into the second; the block saves the second); the save (Kp 20 written at 650 ms, enabled at 1,000, MIT's first tick after calibration at 1,102.55 ms sets kAxis 1 → 20, disabled at 1,200, saved at 1,300: byte 176 holds 20, 8 writes, no erase); power-up (MIT_kp's default 0.01, kAxis 1, then 20 from the block, set_app_MIT_kp(0.01) again; HalInit returns with 0.01 and 20); the first MIT tick (1,102.55 ms: kAxis 20 → 0.01, Kd 0.014 → 0.01; the saved 20 is never used). How soft 0.01 is: on episode 27's bench the same 0.1 N·m push gives 105 counts at Kp 20, and 9.9 rad after 8 s, still going, at 0.01 (episode 27's motor model). Then the five kinds of setter (store only; store and push to kAxis, like Torque_constant; refused while enabled, like pole pairs, return 3 on the bench; write ignored, Max_motor_speed written 3,000 reads 6,000; stored but never used, Motor_encoder_type). The fix (fork branch fix/mit-gains-saved: marked 1 in the table, two fields at the end of the struct, two lines each way in the copy functions; PATCHED run: Kp 20 after the reboot). Upgrading the firmware (FlashDB's get_kv copies only the 976 saved bytes; the old fields end at 972 and the struct, holding int64_t fields, is padded to 976, so old firmware saved 4 padding bytes as 0; a what-if build without the filler reads Kp = 0; the fix's 4-byte filler starts the new fields at 976, and after an upgrade 0x6085 is still 6,000 and MIT_kp the default 0.01). Never in the middle: only 1c897f0 (2026-01) ever moved saved fields in this struct, three of them (912 → 909 and so on, worked out from the header); the 48 empty fields exist so nothing moves. Not covered: the write guard, error records and factory reset → 28c; the product contract → episode 29; MIT itself → 27a–27c; the generator ships only as an exe. Your turn: on the patched firmware, only Kd 0.03 saved and power-cycled → Kp 0.01, Kd 0.03.

Up next28c · Parameter storage 3: the lock that protects the flash→