Skip to content

Instantly share code, notes, and snippets.

@klausenbusk
Created February 18, 2020 23:16
Show Gist options
  • Save klausenbusk/643f15320ae8997427155c38be13e445 to your computer and use it in GitHub Desktop.
Save klausenbusk/643f15320ae8997427155c38be13e445 to your computer and use it in GitHub Desktop.
See https://github.com/linrunner/TLP/issues/321#issuecomment-587184825 for context..
@userofryzen
Copy link

okey, I see that linux-amd kernel doesn't serve you, I will tell him to know if there is a possibilty of have other kernel but only with that patch.
Wait and let's hope that he can doi it.

@userofryzen
Copy link

http://nhameh.ovh/linuxkernels/x86_64/linux-test-5.6.v.14-1-x86_64.pkg.tar.xz
http://nhameh.ovh/linuxkernels/x86_64/linux-test-headers-5.6.v.14-1-x86_64.pkg.tar.xz

@surajrv6
Download them, install them ( with pacman -U etc etc), update the grub by the way
And in grub menu select linux-test, you should have the entry now, let's hope that fix your problem

@userofryzen
Copy link

please, tell me when you read this and can test it so I can leave to see my mail XD

@surajrv6
Copy link

Okay :) I will let you know when I finish testing. No electricity at my place.. Laptop is also running low on battery...

@surajrv6
Copy link

Okay, I just now installed it. change_control_end_treshold file has appeared in BAT1 folder. I will test the charging process once the power comes back.

@userofryzen
Copy link

tell me when you can test :) it appear to be working.

PD: in my girlfriend's laptop the only numbers were working was 60, 80 and 90 I advice you

@surajrv6
Copy link

Okay, I am testing and side by side doing office work :)
I tried 60, 75 and now 77 and it seems to stop charging. I don't have time to sit near laptop. My laptop has led which turns orange while charging and white when not charging. I am currently relying on that... Charging look like stopped but status says charging(1 hr left)

I will test thoroughly, tomorrow..

@userofryzen
Copy link

sufficient for me
@klausenbusk
The patch used is in linux-amd aur
@egnappahz is the creator and know what was the patch.
It feels like the same thng that before, right?
Can you send the patch again having the next iteration with BAT1?
Mention the other patch to see if it "accelerates" the things and make easier to understand in the Linux mantainer part

Thanks to everybody helping, testing etc

@userofryzen
Copy link

I have been testing the patch too, it appear not to be generating any regression at all.

@userofryzen
Copy link

have you tested it a little more? @surajrv6

@surajrv6
Copy link

Sorry @userofryzen I didn't test much because you said the testing was sufficient :) I rarely use my laptop

@userofryzen
Copy link

Oh. Please. Be sure of the charging limit at least

@userofryzen
Copy link

@surajrv6
Copy link

@userofryzen,
Okay, i will test now and let you know in an hour..

@surajrv6
Copy link

I set the charging limit to 80% when the battery was 74%. here is the reading using upower as soon as battery reached 79% (charging stopped)
Please note that the laptop is pluged in all the time during the test

[suraj@asus Desktop]$ upower -i /org/freedesktop/UPower/devices/battery_BAT1
  native-path:          BAT1
  vendor:               ASUS
  model:                A32-K55
  power supply:         yes
  updated:              Sun May 24 20:21:00 2020 (27 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    warning-level:       none
    energy:              33.5654 Wh
    energy-empty:        0 Wh
    energy-full:         42.2196 Wh
    energy-full-design:  48.0007 Wh
    energy-rate:         26.0208 W
    voltage:             3.889 V
    time to full:        20.0 minutes
    percentage:          79%
    capacity:            87.9562%
    technology:          lithium-ion
    icon-name:          'battery-full-charging-symbolic'
  History (charge):
    1590331860	79.000	charging
    1590331823	78.000	charging
  History (rate):
    1590331860	26.021	charging
    1590331823	27.294	charging

Here is the reading after 30 minutes

[suraj@asus Desktop]$ upower -i /org/freedesktop/UPower/devices/battery_BAT1
  native-path:          BAT1
  vendor:               ASUS
  model:                A32-K55
  power supply:         yes
  updated:              Sun May 24 21:07:00 2020 (102 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    warning-level:       none
    energy:              33.5654 Wh
    energy-empty:        0 Wh
    energy-full:         42.2196 Wh
    energy-full-design:  48.0007 Wh
    energy-rate:         29.5721 W
    voltage:             3.802 V
    time to full:        17.5 minutes
    percentage:          79%
    capacity:            87.9562%
    technology:          lithium-ion
    icon-name:          'battery-full-charging-symbolic'

After another 30 minutes, here is the upower reading

[suraj@asus Desktop]$ upower -i /org/freedesktop/UPower/devices/battery_BAT1
  native-path:          BAT1
  vendor:               ASUS
  model:                A32-K55
  power supply:         yes
  updated:              Sun May 24 21:31:00 2020 (32 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    warning-level:       none
    energy:              33.5654 Wh
    energy-empty:        0 Wh
    energy-full:         42.2196 Wh
    energy-full-design:  48.0007 Wh
    energy-rate:         29.5721 W
    voltage:             3.801 V
    time to full:        17.5 minutes
    percentage:          79%
    capacity:            87.9562%
    technology:          lithium-ion
    icon-name:          'battery-full-charging-symbolic'

After that I tried setting the threshold to 100. Below is the result as soon as I set the treshold

[suraj@asus Desktop]$ upower -i /org/freedesktop/UPower/devices/battery_BAT1
  native-path:          BAT1
  vendor:               ASUS
  model:                A32-K55
  power supply:         yes
  updated:              Sun May 24 21:33:25 2020 (54 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    warning-level:       none
    energy:              33.5654 Wh
    energy-empty:        0 Wh
    energy-full:         42.2196 Wh
    energy-full-design:  48.0007 Wh
    energy-rate:         0.035037 W
    voltage:             3.804 V
    percentage:          79%
    capacity:            87.9562%
    technology:          lithium-ion
    icon-name:          'battery-full-charging-symbolic'
  History (rate):
    1590336205	0.035	charging

Just to make sure the upower reading is correct, I restarted the laptop after 2 minutes and went in bios to check the battery. The battery was 82%

Here is the upower reading after restart

[suraj@asus Desktop]$ upower -i /org/freedesktop/UPower/devices/battery_BAT1
  native-path:          BAT1
  vendor:               ASUS
  model:                A32-K55
  power supply:         yes
  updated:              Sun May 24 21:35:48 2020 (101 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    warning-level:       none
    energy:              34.6516 Wh
    energy-empty:        0 Wh
    energy-full:         42.2196 Wh
    energy-full-design:  48.0007 Wh
    energy-rate:         24.0704 W
    voltage:             3.98 V
    time to full:        18.9 minutes
    percentage:          82%
    capacity:            87.9562%
    technology:          lithium-ion
    icon-name:          'battery-full-charging-symbolic'
  History (charge):
    1590336348	0.000	unknown
  History (rate):
    1590336348	0.000	unknown

After 15 min, I checked the upower reading again..

[suraj@asus Desktop]$ upower -i /org/freedesktop/UPower/devices/battery_BAT1
  native-path:          BAT1
  vendor:               ASUS
  model:                A32-K55
  power supply:         yes
  updated:              Sun May 24 21:49:49 2020 (72 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    warning-level:       none
    energy:              38.4706 Wh
    energy-empty:        0 Wh
    energy-full:         42.2196 Wh
    energy-full-design:  48.0007 Wh
    energy-rate:         12.0644 W
    voltage:             3.991 V
    time to full:        18.6 minutes
    percentage:          91%
    capacity:            87.9562%
    technology:          lithium-ion
    icon-name:          'battery-full-charging-symbolic'
  History (charge):
    1590337189	91.000	charging
  History (rate):
    1590337189	12.064	charging

after recording the result I restarted the laptop and checked the battery reading in bios. It was 92% (same as the reading)

Here is the result recorded as soon as the restart

[suraj@asus Desktop]$ upower -i /org/freedesktop/UPower/devices/battery_BAT1
  native-path:          BAT1
  vendor:               ASUS
  model:                A32-K55
  power supply:         yes
  updated:              Sun May 24 21:52:54 2020 (73 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    warning-level:       none
    energy:              39.0429 Wh
    energy-empty:        0 Wh
    energy-full:         42.2196 Wh
    energy-full-design:  48.0007 Wh
    energy-rate:         10.5812 W
    voltage:             3.992 V
    time to full:        18.0 minutes
    percentage:          92%
    capacity:            87.9562%
    technology:          lithium-ion
    icon-name:          'battery-full-charging-symbolic'
  History (charge):
    1590337374	0.000	unknown
  History (rate):
    1590337374	0.000	unknown

I checked the result again in 30 min when the laptop battery indicator was turned white (means charge is full or charging is stopped)

[suraj@asus Desktop]$ upower -i /org/freedesktop/UPower/devices/battery_BAT1
  native-path:          BAT1
  vendor:               ASUS
  model:                A32-K55
  power supply:         yes
  updated:              Sun May 24 22:20:54 2020 (37 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    warning-level:       none
    energy:              41.7875 Wh
    energy-empty:        0 Wh
    energy-full:         42.2196 Wh
    energy-full-design:  48.0007 Wh
    energy-rate:         3.32851 W
    voltage:             3.998 V
    time to full:        7.8 minutes
    percentage:          98%
    capacity:            87.9562%
    technology:          lithium-ion
    icon-name:          'battery-full-charging-symbolic'
  History (rate):
    1590339054	3.329	charging

I went in bios again to check the battery. it was showing 99%

@surajrv6
Copy link

Here is after battery fully charged

[suraj@asus Desktop]$ upower -i /org/freedesktop/UPower/devices/battery_BAT1
  native-path:          BAT1
  vendor:               ASUS
  model:                A32-K55
  power supply:         yes
  updated:              Sun May 24 22:31:51 2020 (30 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               fully-charged
    warning-level:       none
    energy:              42.0678 Wh
    energy-empty:        0 Wh
    energy-full:         42.2196 Wh
    energy-full-design:  48.0007 Wh
    energy-rate:         2.31244 W
    voltage:             3.984 V
    percentage:          100%
    capacity:            87.9562%
    technology:          lithium-ion
    icon-name:          'battery-full-charged-symbolic'

@userofryzen
Copy link

okey, thank you! here we have the tests so.. kristian, can you send the pach upstream?

@userofryzen
Copy link

@klausenbusk
Have you send the patches to Linux? or havent you time for this cause of exams or work?
I ask because the user surakrv6

@surajrv6
Copy link

I have been also checking the source code to see if changes have been added for the past couple of weeks :)

Here..
https://github.com/torvalds/linux/blob/master/drivers/platform/x86/asus-wmi.c

@userofryzen
Copy link

@klausenbusk are you here?
Is there any news about this? or can't you do it now?
May be this thread have been missed by you for lost time or Idk.

@klausenbusk
Copy link
Author

Hi @userofryzen. I haven't got time to look at it and I don't like just adding every "battery name" (it is a "temporary" solution, we need a permanent solution).

@userofryzen
Copy link

okey, have you something on mind?
I think a recursive function that looks in every BAT x being x letters and numbers?
I don't know if it's efficient or not etc.. I hope someone can solves it

@klausenbusk
Copy link
Author

Someone beat me to it: torvalds/linux@9a33e37

@surajrv6
Copy link

Glad to hear it's implemented finally :)

@egnappahz
Copy link

It's going to become a loooong list if they keep those batterynames coming..

@linrunner
Copy link

linrunner commented Sep 3, 2020

Hi,

for a proper implementation in TLP i need answers to the following questions:

  1. What are the valid values / the range for charge_control_end_threshold?
  2. May i assume that the threshold works exactly the same way – values, range, charge behaviour – for all ASUS laptops that expose /sys/class/power_supply/BAT0/charge_control_end_threshold?
    2a. If not, how do I distinguish the variants e.g. in /sys/class/dmi/id/*
  3. How do i check that asus_wmi is loaded – does /sys/module/asus_wmi exist?
  4. Is the battery always named BATx or else?

@klausenbusk
Copy link
Author

klausenbusk commented Sep 3, 2020

Hi

for a proper implementation in TLP i need answers to the following questions:

Is there any issue I can track?

What are the valid values / the range for charge_control_end_threshold?

0-100, but there is one report of it only supporting 60, 80 and 100.

May i assume that the threshold works exactly the same way – values, range, charge behaviour – for all ASUS laptops that expose /sys/class/power_supply/BAT0/charge_control_end_threshold?

I don't know, but probably (if you ignore that one report).

How do i check that asus_wmi is loaded – does /sys/module/asus_wmi exist?

/sys/module/asus_wmi does indeed exists.

Is the battery always named BATx or else?

The code is currently hard-coded to only create charge_control_end_threshold if the battery name is BAT0, BAT1 or BATT.

@linrunner
Copy link

Is there any issue I can track?

Well, yes ... here you are. I added another question there.

@linrunner
Copy link

The wait is over: the stop charge threshold is implemented for TLP 1.4.

Please participate in the alpha test. All necessary information is here.

Have fun.

@therealak12
Copy link

therealak12 commented Aug 10, 2024

Asus UX3404VA supports only 60, 80, and 100 in the /sys/class/power_supply/BAT0/charge_control_end_threshold file (as reported above).

Does anyone know that this is a hardware or software limitation? Do you have any workarounds to bypass it?

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