Skip to content

fix battery drain when battery charge threshold is set - #84

Open
hojjatabdollahi wants to merge 1 commit into
FrameworkComputer:fwk-lotus-azalea-19573from
hojjatabdollahi:hojjat/fix-charge-threshold
Open

hojjatabdollahi wants to merge 1 commit into
FrameworkComputer:fwk-lotus-azalea-19573from
hojjatabdollahi:hojjat/fix-charge-threshold

Conversation

@hojjatabdollahi

@hojjatabdollahi hojjatabdollahi commented Aug 7, 2026 •

Copy link
Copy Markdown

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 || !current path and, on NVDC chargers, requests VBAT + 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-5 as 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%

  • Note it stayed parked for some time, but then suddenly started draining at a constant rate
image

Stock EC, Min=Max=60%

  • Ignore the first couple of charge/discharges, I was testing something.
  • Notice how much more it stayed parked, going below 60% switches to Normal mode and replenishes the diode
image

Patched EC, Min=55%, Max=60%

image

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.

@mitar

mitar commented Nov 17, 2026

Copy link
Copy Markdown

Data point from a Laptop 13 Pro (AMD Ryzen AI 300 Series): the same code path applies there, but I could not reproduce the drain on my unit. Some notes from the ISL9241 datasheet (FN8945 Rev 6.01) and from measurements, which may help with reviewing this.

Setup: Ryzen AI 9 HX 370, BIOS 04.02, EC lilac-4.0.2-fdbf549, battery FRANEDA, sustainer at 40-60% through cros_charge_control, 45 W charger (20 V / 2.25 A, input limit 2136 mA). I read the charger with framework_tool --host-command 0x9E ... (I2C passthrough, port 3, address 0x09): MaxSystemVoltage (0x15), ChargeCurrentLimit (0x14), Information1 (0x3A), Information2 (0x4D).

Where the thin margin applies: charge_request() requests MAX(closest(VBAT + step), voltage_normal), and charger_closest_voltage() rounds down to the 8 mV step, so the effective margin over the battery's reported voltage is 1-8 mV, not 8 mV. Below voltage_normal (15640 mV for this battery) the target is that floor instead: at 48% it sat 110-190 mV above the battery. So on this battery the thin margin only exists in roughly the upper part of a 40-60% band. Above the floor the target also follows the noise of the battery's voltage reading: the EC logged up to ~3 charge_request() changes per second, each a write of MaxSystemVoltage.

What the datasheet says about it:

  • With ChargeCurrentLimit = 0 charging is disabled and BGATE is off, except in the "turbo" (ideal diode) range (Table 17). Turbo starts when CSON falls about 175 mV (110-255 mV) below VBAT and ends after 150 mA of charging current, or after the battery's discharge current stays under 140 mA for 40 ms (section 8.3.1.2, Rs2 = 10 mOhm).
  • MaxSystemVoltage accuracy is +/-0.5% for 3 and 4 cells, about +/-80 mV at 16 V, which is ten times the 1-8 mV margin.
  • So my reading of the mechanism: after a load peak above the input limit enters turbo, the charger regulates to "reported VBAT + 1-8 mV", and while the battery discharges, the reported VBAT sags and the EC lowers the target with it (I saw it fall to the 15640 mV floor during bursts). On a unit whose regulation sits more than the margin plus 140 mA times the path resistance below the battery's reported voltage, the discharge would never fall under the exit threshold. This would make the drain depend on the unit's tolerances, which fits it being seen on some units and not on others. This is inference: the datasheet does not describe the voltage loop while BGATE is on with charging disabled.

Measurements at 60% (target 1-8 mV above the reported VBAT): steady and bursty (5 s on/off) 7-Zip loads on all threads put the charger into turbo (Information1 bit 0 = 1, input current loop active, battery 0.3-0.8 A). After both load ends (and one more at 48%), the battery current returned to 0 within 2-4 s, turbo was off, and it stayed at 0 over 10 minute watches. So on this unit the charger takes the load back each time.

On the fix itself: with voltage_max in IDLE, VSYS sits about 2 V above the battery at 60% (18040 mV against ~16 V here), so a peak above the input limit has to pull VSYS down about 2.2 V before turbo starts, instead of about 0.18 V. That is the same register value as for a full battery, but a different operating point, and it may be worth checking for input PROCHOT trips or stutter on small chargers. The datasheet offers a smaller alternative: Control0 bit 1 adds 384 mV to the VSYS regulation while not charging, "useful to avoid discharging a full battery in the VSYS state when there is a system load transient" (section 8.2.3). That would put the margin above the DAC tolerance while keeping VSYS close to the battery. I have not tested either on hardware.

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