Skip to content

fw/services/battery: add optional fuel gauge diagnostic logging - #1850

Draft
adipascu wants to merge 1 commit into
coredevices:mainfrom
adipascu:gauge-diag-log
Draft

fw/services/battery: add optional fuel gauge diagnostic logging#1850
adipascu wants to merge 1 commit into
coredevices:mainfrom
adipascu:gauge-diag-log

Conversation

@adipascu

@adipascu adipascu commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Validating state-of-charge estimation needs a uniform record of what the fuel gauge was told and what it concluded. The existing battery log fires on percent changes and while charging, so it is dense during a charge and silent for hours otherwise. This adds an evenly spaced one, off unless a build asks for it.

BATTERY_GAUGE_DIAG_LOG gates a single structured line carrying the raw inputs and outputs together: SOC in centi-percent, voltage, current, temperature, time-to-empty and time-to-full, and whether the charger is unplugged, plugged or charging. BATTERY_GAUGE_DIAG_LOG_INTERVAL_S sets the cadence, 60 to 3600 seconds, default 900. Everything logged is already in hand at that point in prv_update_state, so nothing new is measured and no driver changes are needed.

The flag defaults to off and the block compiles out with it, so production builds are byte-identical to today.

Motivated by the review discussion on #1841. Answering whether reported SOC drifts when a battery never reaches full needs voltage sampled alongside SOC on a fixed interval, from a watch actually living under a charge limit, which is what this produces. Running on my Pebble Time 2 since 2026-08-11 with the charge limit at 55%.

Written with AI assistance (Claude).


Aside: I am currently available for firmware contracting or full-time work. Contact: adrian@pascu.be.

Add a Kconfig-gated periodic log line with the raw fuel gauge inputs
and outputs: SOC, voltage, current, temperature, TTE/TTF, and charger
state. Unlike the existing INFO log it fires on a fixed interval
regardless of charge activity, giving development devices a uniform
time series for validating state-of-charge estimation, for example
under charge regimes that never reach full.

Off by default, so production builds are unchanged.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Adrian Pascu <adrian@pascu.be>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant