给刷过coreboot的x220t设置电池充电限制
0x00 起因⌗
在给电脑刷了coreboot后,发现原本传统的控制电池充电极限的方法不管用了。在用tlp-stat会得到以下提:
Battery Features: Charge Thresholds and Recalibrate
natacpi = active (data, thresholds)
tpacpi-bat = inactive (superseded by natacpi)
tp-smapi = inactive (kernel module 'tp_smapi' load error)
这是因为coreboot在其中把联想电源管理模块(SMM/SMI)给去掉了,而这一部分是一个大大的黑盒算法,这很危险。
tp smapi depends on lot of SMM/SMI code. So tp-smapi kernel module asked the Lenovo BIOS to tell the EC to do something. coreboot don’t want to support SMM/SMI APIs, because they are quite dangerous. But there is another way to get those features back. We know how to enable it, but we haven’t yet create a way to control this by the user.
0x01 解决方法⌗
好在我们可以用直接控制ec的方法来设置。这将会用到ectool,已经包括在coreboot的git仓库中。ectool的使用方法是这样的:
ectool -w 0x3 -z 0x44 #设置停止充电百分比
ectool -w 0x24 -z 0xd0 #设置在80%做上面的事
ectool -w 0x3 -z 0x40 # 设置开始充电百分比
ectool -w 0x24 -z 0xb2#设置在50%做上面的事
然后再用tlp-stat就会看到这样的显示 /sys/class/power_supply/BAT0/status = Unknown (threshold effective) 这就代表充电限制生效了!
Enjoy!
0x02 附:百分比数值的表⌗
| 百分比 | 0x24的值 |
|---|---|
| 10 | 0x8a |
| 15 | 0x8f |
| 20 | 0x94 |
| 25 | 0x99 |
| 30 | 0x9e |
| 35 | 0xa3 |
| 40 | 0xa8 |
| 45 | 0xad |
| 50 | 0xb2 |
| 55 | 0xb7 |
| 60 | 0xbc |
| 65 | 0xc1 |
| 70 | 0xc6 |
| 75 | 0xcb |
| 80 | 0xd0 |
| 85 | 0xd5 |
| 90 | 0xda |
| 95 | 0xdf |
| 100 | 0xe4 |
Read other posts