Pixel2: power off on measured voltage, not the fuel gauge - #3329
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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 measuredvoltage_avgagainst 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
Additional Context
quirks/devices/GameKiddy GKD Pixel2/, nothing else changes. Split out of rk817: correct the fuel gauge across boot and sleep #3305, which is now kernel-only.AI Usage
Did you use AI tools to help write this code? YES
🤖 Generated with Claude Code
https://claude.ai/code/session_01RNwUueUVhNqodU1izyxqAK