[RESPONDED] API to control max battery charge level for better battery health

My laptop plugged in USB-C cable for the whole day. By default, it will keep 100% charge for battery. Keeping battery at 0% or 100% for a long time is very bad for battery health.

Many laptops have BIOS settings and API to control max battery charge. GNOME even has a nice extension to set limit for many laptops.

  1. Does Framework have an option in BIOS to set max charge level? I didn’t find it in BIOS.
  2. Does Framework have Linux API to set a limit? If yes we can add it to that extension.

If we don’t have a charge limit support (since I didn’t find it in BIOS), should we add it? It is good practice if you want to avoid buying new battery every few years (good for ecology).

  1. Yes, it’s already in BIOS.
  2. It can already be controlled via ECTool, but I don’t believe it’s exposed on it’s own via the kernel - you have to go through the EC’s interface. @DHowett would be the person to ask.

No, The battery charge level in the BIOS is not OS Dependent.
I run Windows 10 on my main drive Ubuntu 22.04 LTS on an expansion card, and occasionally for giggles and grins Fedora on a USB Flash drive.
My BIOS is set to 85% max charge, and all OS’s respect that.
Since it’s BIOS, it even stops at 85% when shut down.

It’s in the BIOS.

Tab from Main to Advanced tab, look down, second entry from the bottom - Battery Charge Limit. Click the enter key, type a new number, tab to Yes. F10 to save changes and reboot.

@Matt_Hartley thanks!

Any option to do it from Linux (so we can add it to GNOME extension)? It will be nice to avoid reboot for changing the settings.

I prefer to do it in BIOS, however untested by me but should be fine: Battery Care — TLP 1.6 documentation and additional details Battery Care — TLP 1.6 documentation .

@Matt_Hartley Is tlp an option for charge thresholds on the FW yet? I assumed no since the thresholds aren’t exposed in sysfs.

Have not tested or explored this in depth whatsoever. Ideally, BIOS is the recommended official method.

I remembered that TLP had such an option that the op could explore, but it may not do anything if thresholds are not exposed.

So I passed this along for the customer (on their own) to explore if they like. I have not had an opportunity to explore this with tlp at this time.

To get ectool, in GitLab, build section then artifacts, downloaded the last build, unzip the artifacts and place the ectool binary somewhere in PATH such as /usr/local/bin. I could make it work and show information about the computer.

However, ectool battery or ectool chargestate show do not display the charge limit I set in BIOS, I had to look for the source code to see how to manipulate that, here is how:

get charge limit:

$ sudo ectool fwchargelimit
95

Set charge limit

$ sudo ectool fwchargelimit 80
80
1 Like