[Power] Recover battery gauge after VGM flashing#1041
Conversation
|
Hardware follow-up found one side effect that needs more investigation before review: recovery from |
|
Hardware follow-up completed with an additional lower-SOC check:\n\n- Before flashing the official VGM firmware: 98%\n- After leaving Video Game Module Tool: the runtime recovery completed without reboot\n- Desktop battery value after recovery: 98%\n- The previous 99% -> 100% observation was therefore not a forced/default 100% value; it was consistent with a one-point OCV re-estimation at the upper rounding boundary.\n- The user-visible regression remains fixed: the battery percentage returns automatically instead of staying as a dash until a Flipper reboot.\n\nThe recovery uses the same existing BQ27220 initialization path that a reboot would invoke, but now performs it only after the app queue is empty. Marking the PR ready again with this hardware result documented. |
|
Correction after another hardware run:\n\n- Before flashing the official VGM firmware: 97%\n- After leaving Video Game Module Tool and automatic gauge recovery: 100%\n\nThis disproves the earlier tentative conclusion from the 98% -> 98% run. The current recovery is not acceptable: a full BQ27220 reset can lose the accumulated SOC state and replace it with an OCV estimate that differs by several percentage points.\n\nThe PR is being returned to draft. The fix must prevent the VGM flashing path from disturbing the gauge, or otherwise preserve valid gauge state without issuing a full reset. |
|
Deferring this approach after additional hardware testing. A battery-only VGM flash can clear INITCOMP, but the proposed full BQ27220 recovery loses accumulated SOC and can re-estimate 97% as 100%, so it is not safe to merge. USB-powered VGM flashing preserves INITCOMP, and opening/closing the tool without flashing is harmless. The complete telemetry matrix, workaround, candidate VGM Tool power-path fix, and acceptance criteria are archived in squazaryu/tumoflip#131. Tumoflip 089-038 will exclude all commits from this recovery experiment. |
|
AI-Slop issue, stop using Claude for everything... Try to use keyboard for making comments at least. |
Summary
Fixes #961.
Flashing official firmware to the Video Game Module can leave the BQ27220 fuel gauge with
INITCOMP=0. Battery telemetry remains readable, butfuri_hal_power_gauge_is_ok()correctly reports the gauge as unavailable, so Desktop shows-until Flipper is rebooted.Changes
gauge_is_okchanges;BATTPRESbefore recovery;bq27220_init()path only whenINITCOMP=0.The recovery does not run for a healthy gauge or on an I2C read failure. No public API symbols were added or changed.
Root-cause evidence
Immediately after reproducing the issue, before reboot:
-;gauge.initcomp: 0;gauge.battpres: 1;100;4.15 V;30 C.A reboot restored
INITCOMP=1, matching the boot-time BQ27220 initialization behavior.Verification
./fbt -j4 firmware_all88.0unchanged100%info power_debugconfirmedgauge.initcomp: 1,gauge.battpres: 1, and valid telemetryRisk
The existing BQ27220 initialization can briefly delay the power service, but the new path is one-shot, application-exit gated, and only entered for the confirmed
BATTPRES=1 && INITCOMP=0state.