fix battery drain when battery charge threshold is set - #84
Open
hojjatabdollahi wants to merge 1 commit into
Open
Conversation
hojjatabdollahi
force-pushed
the
hojjat/fix-charge-threshold
branch
from
August 7, 2026 07:29
cb9a63f to
d413b14
Compare
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.
When the battery sustainer parks the pack at a charge limit it enters
CHARGE_CONTROL_IDLE, which sets manual current and voltage to 0.charge_request()then takes the!voltage || !currentpath and, on NVDC chargers, requestsVBAT + one voltage_step. Per the comment on that branch, the margin exists so that "the BGATE FET body diode" does not "conduct and discharge the battery".However one voltage_step does not appear to be enough margin: if the rail sags below VBAT under load the diode conducts and the pack supplies part of the system current. Charge current is pinned at 0 in IDLE, so it is never replenished, SoC falls until it crosses the sustainer's lower threshold and triggers a full recharge.
This is what I observe: a shallow charge/discharge between min/max charge threshold. The EC automatically sets
max-5as the min. When I set the charge threshold to 60%, it charges to 60%, then goes to IDLE (observed in ec console) but then as soon as there is some load on the system, it starts drawing a constant 5-9W from the battery. Until it gets to 55% and charges back up to 60%.Stock EC, Min=55%, Max=60%
Stock EC, Min=Max=60%
Patched EC, Min=55%, Max=60%
This patch potentially applies to other boards too.
My framework forum post: https://community.frame.work/t/puzzling-battery-threshold-behavior/83941
EDIT: looks like this was found before: here.