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

I think one frustrating thing here is that FW released a new version of the EC firmware in the latest FW13 BIOS update, but have not published into the github repo what changes they made to the EC firmware.
People have reported battery problems with that latest firmware and I now understand the EC firmware source code enough to finally test and fix the bugs they might have introduced.

As an example as to how crazy the firmware is.
It has 3 different algorithms for battery management that all run at the same time. It applies the result of one algorithm, then a second later applies the result of the second algorithm, and occasionally applies the results of the third algorithm.
As all 3 are very different algorithms, they of course argue and are flipping back and fourth between the various algorithm results. This is what is causing the flipping between charging and discharging. One algorithm is telling it to charge, and the other algorithm is telling it to discharge.
So, one of the bug fixes I did to the firmware was:

  1. disable the third algorithm entirely. (leaving just 2 algorithms to fight is better than 3)
  2. when the second algorithm is running, suppress the first algorithm.
    My patch actually prints a EC console message when it is suppressing the first algorithm.
  3. when the second algorithm is not running, use the first algorithm.

The result of the bug fix is that only one algorithm is actually permitted to run at a time, resulting in a sensible outcome.

It is only really me putting a plaster on it.

The correct answer is to have a single algorithm that handles all the needed edge cases that the 3 algorithms are trying to handle.

So, that is just one example of how crazy the EC firmware is.

4 Likes