[ltp] Battery recalibration (was: T470 multi-battery, discharging order)

Kevin Locke kevin at kevinlocke.name
Wed Mar 30 16:22:43 CEST 2022


On Wed, 2022-03-30 at 13:02 +0200, Axel Braun wrote:
> Am Mittwoch, 30. März 2022, 12:00:02 CEST schrieb linux-thinkpad-request at linux-thinkpad.org:
>> You can also get the battery information with:
>> tlp-stat -b
> 
> Interesting. When running this I see as last sentence:
> 
> +++ Recommendations
> * Install acpi_call kernel module for ThinkPad battery recalibration
> 
> I was not aware that Battery recalibration und Linux works, and I dont have a 
> acpi_call kernel module (running kernel 5.16.15)
> 
> Does anyone know how to get this working?

I believe battery recalibration simply discharges the battery then
recharges it.[1]  To do so without disconnecting AC power, tlp can use
Linux-native force-discharge added in b55d416d48f5[2] (5.17-rc1),
acpi_call[3][4] (via tpacpi-bat[5], if installed), or tp_smapi[6] for
older models, which it tries in that order.

On a T470 with kernel 5.16.15 you'd likely want to install tpacpi-bat
with the acpi_call kernel module, as described in Diego's reply, then
run `tpacpi-bat -g FD 1` to force-discharge battery 1.  However, if
you can upgrade to Linux 5.17, no additional software or modules are
required and the process should be as simple as:

if charge thresholds are being used, clear them during recalibration:
    echo 0 >/sys/class/power_supply/BAT0/charge_control_start_threshold
    echo 100 >/sys/class/power_supply/BAT0/charge_control_end_threshold
echo force-discharge >/sys/class/power_supply/BAT0/charge_behaviour
# Wait until battery is fully discharged
# Wait until battery is fully recharged
# Restore change thresholds as desired

Change BAT0 to BAT1 to recalibrate a second battery.

Of course, if you have physical access to the machine, you could
recalibrate without software by simply disconnecting AC power,
discharging the battery, then reconnecting.

Be aware that with any of the above methods, power management tools
(GNOME Power Manager, KDE Power Devil, XFCE Power Manager, etc.) may
automatically sleep, hibernate, or shutdown the machine when the
battery charge drops below a configured level.  This may reduce the
effectiveness of the recalibration, but avoids issues due to abrupt
power loss.  You may get a more accurate recalibration by disabling
this behavior.  If doing so, you would likely want to mount any
persistent filesystems as read-only or take other steps to minimize
the risk of corruption due to abrupt power loss.

Cheers,
Kevin

[1]: https://github.com/linrunner/TLP/blob/1.5.0/tlp.in#L496
[2]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b55d416d48f5907f66218ae3d878e3bfb69ae4e6
[3]: https://github.com/mkottman/acpi_call
[4]: https://github.com/nix-community/acpi_call
[5]: https://github.com/teleshoes/tpacpi-bat
[6]: https://github.com/linux-thinkpad/tp_smapi


More information about the Linux-Thinkpad mailing list