Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

TLP 1.4 Test: Battery Care for ASUS Laptops

Read the overview document first.

Supported Features

ASUS laptops using the asus_wmi driver have a stop charge threshold ranging from 0% (threshold off) to 100%. The hardware behaviour is:

  1. Connected to the charger, charging stops when the charge level reaches the stop threshold

  2. If the charge level is higher than the stop threshold, the battery will not discharge automatically; it will only be discharged when the charger is removed i.e. the laptop runs on battery

When suitable hardware has been detected, tlp-stat -b shows:

+++ Battery Care
Plugin: asus
Supported features: charge threshold
Driver usage:
* natacpi (asus_wmi) = active (charge threshold)
Parameter value range:
* STOP_CHARGE_THRESH_BAT0/1: 0(off)..100(default)

+++ Battery Status: BAT0
...
/sys/class/power_supply/BAT0/charge_control_end_threshold   =    100 [%]
...

How it works

Battery charging is a process not controlled by TLP itself, but by the laptop's embedded controller (EC). This makes the process work even when switched off or no operating system is running. You cannot change the basic behavior, it is hard-coded into the EC firmware by the vendor. TLP just writes the charge threshold into the EC with the help of the kernel driver, the EC takes care of the rest.

Installation

Packages are provided at the download page.

Linux kernel 5.4 or higher required.

Test Cases

Important: please provide all terminal input and output from the test cases via an individual Gist and link it in your post below.

1. Configure and apply a charge stop threshold

Edit /etc/tlp.conf (or a config file of your choice under /etc/tlp.d/):

STOP_CHARGE_THRESH_BAT0="80"

Note: if necessary replace with your own value that suits the test case.

Enter the following commands in a terminal (as root or with sudo):

tlp start
tlp-stat -s -c -b

Verify that charge_control_end_threshold = 80.

2. Verify the charging process

  1. Let the laptop run on battery power until the charge level falls below the stop threshold by at least 10%
  2. Connect the charger and see if charging starts
  3. Verify that charging stops at 80% (or your configured value)

Enter the command (as root or with sudo):

tlp-stat -b

3. Change charge stop threshold manually

Enter the commands (as root or with sudo):

tlp setcharge 0 85
tlp-stat -b

Verify that charge_control_end_threshold = 85 and charging starts.

Notes:

  • If necessary replace 85 with a value higher than your first value chosen above
  • The first command argument '0' is a dummy for the start threshold not available on ASUS laptops

Enter the commands (as root or with sudo):

tlp setcharge
tlp-stat -b

Verify that charge_control_end_threshold = 80 and charging halts.

4. Disable stop threshold and return to full charge

Edit the config file used above and comment the parameter to disable it:

#STOP_CHARGE_THRESH_BAT0="80"

Enter the commands (as root or with sudo):

tlp fullcharge
tlp-stat -b

Verify that charge_control_end_threshold = 100 and the battery gets fully charged.

What else should I check?

  • A user has reported an ASUS laptop recognizing only discrete values 60, 80, 100; other values just being ignored by the hardware - can other users confirm this?
  • Are there ASUS laptops with more than one battery (tlp-stat -b should show)?
@wRAR
Copy link

wRAR commented Apr 24, 2021

I got

+++ Battery Wear Control
Plugin: asus
Supported features: none
Driver usage:
* natacpi (asus_wmi) = inactive (ASUS laptop not supported)
Parameter value range:
* STOP_CHARGE_THRESH_BAT0/1: 0(off)..100(default)

UX305CA, kernel 5.10.

@linrunner
Copy link
Author

linrunner commented Apr 24, 2021

Thanks for testing. Could you please show the full, unabridged output of

tlp-stat -s -b

and also

tlp-stat --psup

@linrunner
Copy link
Author

linrunner commented Apr 24, 2021

OK, battery is BAT0, so no obstacle. Unfortunately, either hardware or kernel does not support the feature for your model.

Just so I do not miss anything please show

grep . /sys/class/power_supply/BAT0/*

@wRAR
Copy link

wRAR commented Apr 24, 2021

@linrunner
Copy link
Author

linrunner commented Apr 25, 2021

No new findings. Thanks.

@klausenbusk
Copy link

klausenbusk commented May 1, 2021

I tested this on my ASUS Zenbook UX430UNR and it seems to work as expected. Please reach out if you need more details.

A user has reported an ASUS laptop recognizing only discrete values 60, 80, 100; other values just being ignored by the hardware - can other users confirm this?

I can't reproduce that behavior on my system.

@mufidu
Copy link

mufidu commented Jul 16, 2021

Tried it yesterday and it worked, but somehow my bluetooth mouse is not detected anymore. I tried all troubleshooting I can do but nothing worked. So now I just do it by editing /etc/systemd/system/battery-charge-threshold.service. It works fine, limiting the charge to 60%.

@linrunner
Copy link
Author

linrunner commented Jul 16, 2021

@mufidu: thanks for reporting. Unfortunately your outputs are missing.

@mufidu
Copy link

mufidu commented Jul 17, 2021

Didn't save it. Sorry, my bad.
But these are the outputs now, in case you wanna take a look.
https://gist.github.com/mufidu/9940e1d1332c55ee372f15c7063bbc1e

@linrunner
Copy link
Author

linrunner commented Jul 20, 2021

@mufidu: your outputs are for TLP 1.3.1 which doesn't support charge thresholds for ASUS. The point here is to test TLP 1.4 with the packages from the download page (see above).

@mufidu
Copy link

mufidu commented Jul 20, 2021

Sorry I didn't mention that I'm not using version 1.4 anymore as it causes some problems on my side. Above are my outputs after reinstalling TLP from apt. Sharing them so maybe you cand find something about my machine. Anyway, great works!

@linrunner
Copy link
Author

linrunner commented Jul 20, 2021

@mufidu: does not help for the test of the charging thresholds. Thanks anyway.

Btw: you may very well file an issue concerning your bt mouse problem against the unreleased 1.4. I just don't like to discuss the subject here.

@OdinVex
Copy link

OdinVex commented Jul 22, 2021

@linrunner
Copy link
Author

linrunner commented Jul 22, 2021

@OdinVex: you did not use version 1.4, with 1.3.1 it does not work. Please read the instructions at the top.

@OdinVex
Copy link

OdinVex commented Jul 22, 2021

@OdinVex: you did not use version 1.4, with 1.3.1 it does not work. Please read the instructions at the top.

My bad, long frustrating day. Shortly after installing tlp and taking that first gist, the battery is now stuck at 0 and the laptop won't even run on it anymore. Even a dual-boot to another OS, BIOS reset, reset of pins, etc. Same (new) battery. Updated the gist with 1.4.

@linrunner
Copy link
Author

linrunner commented Jul 22, 2021

@OdinVex: outputs are still 1.3.1. With defective hardware the tests don't make sense. Sorry, i can feel your frustration.

@OdinVex
Copy link

OdinVex commented Jul 22, 2021

@OdinVex: outputs are still 1.3.1. With defective hardware the tests don't make sense. Sorry, i can feel your frustration.

I found out what was wrong with this battery. It is a new replacement for a 'nearly exploded' battery. After I ran tlp and gave you the first 1.3 numbers, one of the cold-soldered joints of one of the wires in the battery popped off. I could've returned it, but I took the time to just open it up, reverse-engineer it. Re-soldered, live and well again. As for the gist, the second revision onward have all been 1.4, GitHub simply didn't paste correctly from clipboard and I neglected to check. Fixed now and laptop is tested but no-go on charging limit. I'm using the TLP 1.4.0-alpha.2 debs. This is for a GL702ZC.

@linrunner
Copy link
Author

linrunner commented Jul 22, 2021

@OdinVex: the kernel does not provide charge_control_end_threshold, so your hardware is not supported

@OdinVex
Copy link

OdinVex commented Jul 22, 2021

@OdinVex: the kernel does not provide charge_control_end_threshold, so your hardware is not supported

Thank you for clarifying. I do wish ASUS was a bit more open with their hardware.

@linrunner
Copy link
Author

linrunner commented Jul 22, 2021

@OdinVex: the head of the output states the vendor, the driver and the reason

+++ Battery Care
Plugin: asus
Supported features: none available
Driver usage:

  • natacpi (asus_wmi) = inactive (laptop not supported)

Would you phrase it differently? If so, how?

@OdinVex
Copy link

OdinVex commented Jul 22, 2021

none available

The output was obvious, just wishing ASUS was more open with their hardware, so we could write drivers without needing to black-box it all.. >_>

@linrunner
Copy link
Author

linrunner commented Sep 10, 2021

Beta 2 is out. Enjoy!

@linrunner
Copy link
Author

linrunner commented Sep 24, 2021

TLP 1.4 is released. Have fun and please keep testing!

@foxhoundsk
Copy link

foxhoundsk commented Sep 1, 2022

Hi @linrunner, does /sys/class/power_supply/BAT0/charge_control_start_threshold not presenting means that the kernel (corresponding driver) can't recognize the EC so that it can't modify the threshold? Is it possible that the threshold is not modifiable for specific model?

I'm curious about the chance that we can reverse-engineer the EC to figure the way to set the threshold.

My laptop is ASUS X550JX, which is a circa 7-year-old model.

The output of TLP says:
https://gist.github.com/foxhoundsk/fcedcea96cd9e238ba7092f68643887b

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment