Skip to content

device/husky: generate the gauge overlays from Google's public battery dtsi - #279

Closed
Somnius wants to merge 1 commit into
derekross:mainfrom
Somnius:husky-gauge-from-dtsi
Closed

Somnius wants to merge 1 commit into
derekross:mainfrom
Somnius:husky-gauge-from-dtsi

Conversation

@Somnius

@Somnius Somnius commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

@derekross this is the follow-up you asked for on #249.

tools/gen-gauge-overlay.py now reads Google's public dts/zuma-husky-battery-data.dtsi (GPL-2.0-only, kernel/devices/google/shusky, branch android-gs-shusky-6.1-android16) directly, where the table and the parameters are already u16 words. The old decompiled-dtbo form still parses. BATTERY-NOTES.md points at the public file now, and the generated overlays' header comment cites it.

A new --compare mode reads every model node in the file and says, per overlay, how many of the 48 table words and 27 parameter words differ, and names the parameters. The file has three nodes: default-a1-0k, atl-a1-1k and cos-a1-2k. ATL is identical to gauge-model-atl.dtso. COS differs from it in 30 table words and 7 parameters, the generic model in all 48 and 16. The table is section 5.7 of BATTERY-NOTES.md. lsn-a1-3k, which my notes mentioned, isn't in this file: it is in other boards' overlays of the stock dtbo (ov9 to ov18 here), and the notes now say so.

What I ran: regenerating both overlays from a fresh download of the file gives the same properties as the files in the tree (I regenerated them with the new header comment, so the two .dtso files change in comments only; I checked with the comments stripped). tests/device-overlays passes, but its dtc part skipped because I have no dtc here, and tools/pr-check origin/main is all ok. Nothing booted on a phone, since no overlay property changed.

I didn't put the #250 wrap in here, as you said it goes into the next husky package change.

…y dtsi

tools/gen-gauge-overlay.py now reads dts/zuma-husky-battery-data.dtsi
from Google's shusky device tree repository (GPL-2.0-only, branch
android-gs-shusky-6.1-android16), where the model table and the
parameters are already u16 words, instead of a decompiled stock dtbo.
The decompiled form (u32 cells and a byte list) still parses. The
overlays generated from a fresh fetch of the public file matched
gauge-model-atl.dtso and gauge-model.dtso byte for byte (cmp and
diff, 2026-11-01); both are then regenerated so their header names
the public file, and with comments stripped they are identical to
the files that booted.

A --compare mode reads every model node of the maxim,config block
(// and /* */ comments stripped) and prints each node's DesignCap and
table ends, then per overlay how many of the 48 table words and 27
parameter words differ, naming the parameters and the equal table
words; a length mismatch, wrong lengths and an odd byte list are
reported as such. BATTERY-NOTES.md points at the public file instead
of the dtbo and gets a section 5.7 with the result: the file has
default-a1-0k, atl-a1-1k and cos-a1-2k (no default-fake-batt, which
husky's ov8 has, and no lsn-a1-3k, which only other boards' entries
of the stock dtbo have); ATL is identical to gauge-model-atl.dtso,
COS differs from it in 30 table words and 7 parameters, the generic
model in all 48 and 16.

Asked for by the review of derekross#249. Tested: tests/device-overlays (dtc
compile skipped, no dtc here), tools/pr-check origin/main, the
script's own regeneration and compare runs. Nothing booted on a phone:
the overlays' properties did not change.
@derekross

Copy link
Copy Markdown
Owner

@Somnius thank you, this is exactly what I hoped for after #249. I checked it here against my own copy of zuma-husky-battery-data.dtsi from android-gs-shusky-6.1-android16:

  • Your generator rebuilds both overlays byte for byte as they are in this PR.
  • With the header comments removed, both overlays are identical to the ones on main, so nothing the phone loads has changed.
  • --compare gives the same table as section 5.7: ATL identical, COS 30/48 table words and 7 parameters apart, the generic model 48 and 16.
  • The overlays compile with dtc -@ (I had a dtc here, so that part of tests/device-overlays ran), and tools/pr-check is clean.

Thanks also for dropping the third-party image from section 2. Now anyone can regenerate the overlays from a public file under a clear licence.

One small addition I'll make when I merge, unless you'd rather push it: the overlays now carry data from a file whose header says "Copyright 2022 Google LLC", so I'll add a line with that notice to the generator's header template and to both overlays. It's the same line in all three, so regenerating stays byte-identical (I've checked that too).

This touches the same part of BATTERY-NOTES.md as #282. That one is a draft, so it can rebase once this is in.

@derekross derekross closed this in 549e3c9 Nov 1, 2026
@derekross

Copy link
Copy Markdown
Owner

Landed on main as 549e3c9 (squashed, authored by you), with the edits I described in my last comment. Thank you.

robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
…y dtsi (derekross#279)

The husky gauge overlays (gauge-model.dtso, gauge-model-atl.dtso) are now
generated from Google's GPL-2.0 zuma-husky-battery-data.dtsi by
gen-gauge-overlay.py, instead of from a decompiled factory image. The
regenerated overlays are property-for-property identical to the previous
ones, and --compare matches the published table. BATTERY-NOTES cites the
public source.

Maintainer edit at merge: Google's copyright line travels with the data,
in the generator's template and in both overlays (regenerating stays
byte-identical).

Closes derekross#279

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants