Skip to content

Pixel2: power off on measured voltage, not the fuel gauge - #3329

Merged
spycat88 merged 1 commit into
ROCKNIX:nextfrom
Jacob-Matthew-Cook:pixel2-battery-cutoff
Sep 15, 2026
Merged

spycat88 merged 1 commit into
ROCKNIX:nextfrom
Jacob-Matthew-Cook:pixel2-battery-cutoff

Conversation

@Jacob-Matthew-Cook

Copy link
Copy Markdown
Contributor

Summary

  • What is the goal of this PR? Make the GKD Pixel2's low-battery power-off independent of the fuel gauge. The script shut the device down when the gauge read 0 %. The rk817 gauge can read 0 % erroneously (a false boot value, recoverable only with factoryreset rk817-fuelgauge), and then the script powers the device off on every boot — a boot loop. Tying the safety cutoff to the very number it is meant to guard against is unsafe by design; the gauge can equally stick high while the pack is genuinely empty and never cut off at all. Compare measured voltage_avg against the DT cutoff (voltage-min-design, 3.4 V) instead, six consecutive samples (3 s) below it so load sag does not false-trigger; an unreadable voltage counts as empty so a sysfs failure cannot disable the protection. LED colours are unchanged.

Testing

  • How was this tested? GKD Pixel2, daily use on the RK3326/RK3566/H700: battery, SD card and suspend/resume fixes #3220 test builds that carry this script since August.
  • Test results: LED behaviour as before across the whole range; no false power-offs. The 3.4 V cutoff itself has not been exercised yet — a drain to shutdown is running now with a logger on the device, and the result will be posted here.

Additional Context


AI Usage

Did you use AI tools to help write this code? YES

🤖 Generated with Claude Code

https://claude.ai/code/session_01RNwUueUVhNqodU1izyxqAK

The GKD Pixel2 battery script shut the device down when the gauge
read 0 %. The rk817 gauge can read 0 % erroneously (a false boot value,
recoverable only with 'factoryreset rk817-fuelgauge'), and then the
script powers the device off on every boot: a boot loop, from tying the
safety cutoff to the very number it is meant to guard against. The
gauge can equally stick high while the pack is genuinely empty and
never cut off at all.

Compare voltage_avg against the dts cutoff (voltage-min-design, 3.4 V)
instead, both read at runtime, and require six consecutive samples
below it (3 s at the 0.5 s loop cadence) so momentary load sag does
not trigger it. Unreadable voltage counts as empty so a sysfs failure
cannot disable the protection. LED colours are unchanged.

Split out of ROCKNIX#3305.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RNwUueUVhNqodU1izyxqAK
@spycat88
spycat88 added this pull request to the merge queue Sep 15, 2026
Merged via the queue into ROCKNIX:next with commit 6ca741b Sep 15, 2026
2 checks passed
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