Resources for **30 EC battery control
Posted: Sat Oct 03, 2020 4:08 pm
I've recently gotten some slice batteries for my X230 as well as my T430 and W530 (the W530 really needs the extra battery life...). One of my favorite aspects of my T61 is the ability to balance between the traditional battery and the ultrabay battery, using the tp_smapi linux kernel module coupled with the tp-bat-balance script . I would like to find some way to do that with these laptops as well, so that I don't run down the slice batteries to 0%. Controlling charge thresholds works as expected (well except for the X230 slice battery -- I can't seem to prevent that from charging up to 100%). But I can't find a way to force discharge of one battery or another. The battery calibration mechanism does work as expected, but it can't really be used for battery balancing (I think it only works when plugged into AC).
My X230 and T430 both have coreboot installed instead of the stock BIOS. The W530 still has a Lenovo BIOS (well the ivyrain mod to remove the wifi whitelist). All three also have the EC mod for the classic keyboard and battery whitelist removal.
I've spent a while playing around with ectool (part of coreboot) to poke at various bits of the EC memory. I've also looked through the coreboot source for general EC documentation, as well as the tp_smapi source code (which doesn't work on the *30 series). I feel like this must be possible somehow. One of the interesting things I noticed is that on the 28++ slice (for the T430 and the W530) there is a latch to lock and unlock the battery. When I unlock the latch, the EC stops discharging from that battery. I wonder if its possible to emulate this in software somehow. I looked through the X230 schematics online (yes I know wrong model, but close-enough) and can see that there is a slice_eject_lever signal in the dock connector, which appears to be routed to one of the EC GPIOs. I took several EC RAM dumps (using ectool) and compared them with the latch open and closed. I can see the status bits change, but I can't find any way to trigger the same behavior without actually moving the lever.
Has anyone looked into the EC at this level, or know of any other online resources that might be helpful? I was thinking of taking the EC flash dumps that are on the hamishcoleman github page and trying to use the radare scripts that he has posted, or possibly trying to inspect them with Ghidra, but this is pretty far beyond anything I've attempted to do before.
My X230 and T430 both have coreboot installed instead of the stock BIOS. The W530 still has a Lenovo BIOS (well the ivyrain mod to remove the wifi whitelist). All three also have the EC mod for the classic keyboard and battery whitelist removal.
I've spent a while playing around with ectool (part of coreboot) to poke at various bits of the EC memory. I've also looked through the coreboot source for general EC documentation, as well as the tp_smapi source code (which doesn't work on the *30 series). I feel like this must be possible somehow. One of the interesting things I noticed is that on the 28++ slice (for the T430 and the W530) there is a latch to lock and unlock the battery. When I unlock the latch, the EC stops discharging from that battery. I wonder if its possible to emulate this in software somehow. I looked through the X230 schematics online (yes I know wrong model, but close-enough) and can see that there is a slice_eject_lever signal in the dock connector, which appears to be routed to one of the EC GPIOs. I took several EC RAM dumps (using ectool) and compared them with the latch open and closed. I can see the status bits change, but I can't find any way to trigger the same behavior without actually moving the lever.
Has anyone looked into the EC at this level, or know of any other online resources that might be helpful? I was thinking of taking the EC flash dumps that are on the hamishcoleman github page and trying to use the radare scripts that he has posted, or possibly trying to inspect them with Ghidra, but this is pretty far beyond anything I've attempted to do before.