[TRACKING] Battery flipping between charging and discharging / Draws from battery even on AC

When I get a mo I am going to play with the EC code to experiment with different behaviours:

  1. change it so that it never switches to battery while the psu is plugged in. I just don’t like its current behaviour and I think it is causing some of the battery cycling behaviour.
  2. the battery continually recalibrates itself so using battery percentages to decide whether to charge or not is doomed. The calculations need to be deterministic and use hysteresis.
  3. implement state transition counters and report them in the ectool chargecontrol command, so we can keep track of even the really short charge/discharge events that would otherwise go unnoticed.
  4. analyse why it appears to overcharge (above configured charge limit) while suspended with the psu plugged in.
  5. stop it from setting the CHARGE flag when it is idle and not charging.
  6. the EC source code for charging is a bit spidery and difficult to understand, so the above 5 things could take a while.
  7. if there is a mode where both the battery and psu is supposed to be on at the same time, powering the cpu, then i will add a state for that so one can see when it happens by looking at the counters.

I have found a way to play safely with the EC code without risking a bricked laptop. I have a modified version of the ec firmware writer that helps make it safe to use and not accidentally write bricked code.
Essentially, I only ever write to the RW second image in the firmware, and if anything goes wrong I can easily force it back to RO. Simply powering off resets it to RO.

3 Likes