# 10 hours to fully charge my laptop battery - Asus ZenBook UX431DA



## jcamos (Oct 28, 2021)

Hi everyone!

So this is quite strange and I'm not sure this was ever discussed here. Kind of new to FreeBSD so please take that into consideration.

So each time I plug my power cord it takes an abnormal amount of time to charge the battery. Like an hour per 10% charge, which in my honest opinion it's a lot of time! This doesn't happen if the computer is turned off, so it's not a battery issue. Also, if I try to boot into another OS (for example I tried to use Tails OS) it charges with no problem (I'm talking about less than 2h)! Ever weirder is that after I reboot from Tails OS without unplugging the power cable, after I login to FreeBSD the remaining time for charging is the same as Tails, so roughly 2h or less to fully charge!!! So I'm obviously missing something here.

Can anyone point me to the right direction? Is this some driver related thing?
Really appreciate your help!

Many thanks,
Juan.


----------



## SirDice (Oct 28, 2021)

Might be because on FreeBSD the CPU is on "full blast", i.e. not throttling down when idle. That would suck a lot more power, resulting in less additional power to charge the battery. On one of my laptops running windows and playing a game the battery barely gets charged because there's isn't a lot of "surplus" power to change it, the CPU, graphics and screen are all on full blast and using up most of the power coming from the power brick.

Did you enable things like powerd(8)?


----------



## jcamos (Oct 28, 2021)

Hi! Thanks for the quick reply.

Yes, I did enabled «powerd(8). Actually I also tried powerdxx(). Figured I could lower power usage but no luck on that I'm afraid :/ it does work while on battery as I see some time gain but when it comes to charging that's a different story.



jcamos said:


> Ever weirder is that after I reboot from Tails OS without unplugging the power cable, after I login to FreeBSD the remaining time for charging is the same as Tails, so roughly 2h or less to fully charge!!!


But how can you explain this? I mean, this doesn't make sense at all...

Thanks!


----------



## SirDice (Oct 28, 2021)

Battery state is just something you can read off of the battery itself. So if it's been charged on OS-A to say 50%, it's going to show 50% on OS-B too because that value doesn't change when you read its status. The _speed_ at which it charges can be different between OS-A en OS-B though, if there are differences in the way power consumption is handled. The "time to charge" number is just a calculation based on some parameters. 

Obligatory XKCD:


----------



## astyle (Oct 28, 2021)

OP might also want to check some power drainers beyond powerd(8): Bluetooth, bittorrent, network scanners (like  tcpdump(1) or security/snort), network servers like Apache, and other daemons that run constantly. Default installation of FreeBSD doesn't enable them, but if OP has something like that starting at boot, that can do a number on the battery.


----------



## argwings (Oct 28, 2021)

In my humble opinion this sounds like a FreeBSD bug, especially since it's working properly elsewhere. I had a similar Asus VivoBook before that had some battery logic in place to never let the battery charge completely, so maybe they do something a little strangely. Perhaps a BIOS update would fix it, if available.


----------



## jcamos (Oct 28, 2021)

Thanks.


SirDice said:


> Battery state is just something you can read off of the battery itself. So if it's been charged on OS-A to say 50%, it's going to show 50% on OS-B too because that value doesn't change when you read its status. The _speed_ at which it charges can be different between OS-A en OS-B though, if there are differences in the way power consumption is handled. The "time to charge" number is just a calculation based on some parameters.
> 
> Obligatory XKCD:


Thanks! Well, I get what you mean but maybe I wasn't clear enough about the change between OSs. Taking your example, what happens in my case is if I power up freebsd and start charging from 50% it takes 5h to fully charge. On the other hand, if I do the same after rebooting from the other OS it literally takes 1h. I know the "time remaining" is not 100% accurate so I did by watch and it does charge in one hour. I'm not talking about 30min difference here


----------



## jcamos (Oct 28, 2021)

astyle said:


> OP might also want to check some power drainers beyond powerd(8): Bluetooth, bittorrent, network scanners (like  tcpdump(1) or security/snort), network servers like Apache, and other daemons that run constantly. Default installation of FreeBSD doesn't enable them, but if OP has something like that starting at boot, that can do a number on the battery.


Thanks! No network servers, nothing fancy going around... I would check that but what's bothering me is the sudden change from when I swap from OSs


----------



## argwings (Oct 28, 2021)

Oh, and you could take a look at the sysutils/devcpu-data port to see if an Intel microcode update helps.


----------



## jcamos (Oct 28, 2021)

I'll check that and bios and let you know as soon as I'm on my machine. 
Many thanks!


----------



## astyle (Oct 28, 2021)

jcamos said:


> Thanks! No network servers, nothing fancy going around... I would check that but what's bothering me is the sudden change from when I swap from OSs


In that case, I would suggest updating the laptop's BIOS. It is an awfully new device, though. FreeBSD tends to lag behind Linux when it comes to proper support for _very recent_ hardware. Even on these forums, I've seen jokes about buying a laptop and waiting a couple years before installing FreeBSD on it. Going by your posts, seems like FreeBSD *is *trying to catch up, which is encouraging to me.


----------



## jcamos (Oct 28, 2021)

astyle said:


> In that case, I would suggest updating the laptop's BIOS. It is an awfully new device, though. FreeBSD tends to lag behind Linux when it comes to proper support for _very recent_ hardware. Even on these forums, I've seen jokes about buying a laptop and waiting a couple years before installing FreeBSD on it. Going by your posts, seems like FreeBSD *is *trying to catch up, which is encouraging to me.


Yeah, it's fairly new. And I know some support takes some time to be fully implemented. I have some unresolved issues like my Fn key not working the way it should (multimedia, sound, brightness, keyboard back-light, etc.) and although I found alternatives to use those (except keyboard back-light control) by using simple shortcuts using Super key, it tends to be somehow annoying to have a new computer and not be able to use simple stuff like that. And I get laptops are not "priority" but it would be nice to have this kind of stuff working


----------



## jcamos (Oct 28, 2021)

So there was a BIOS update available and all went well. I'll do some testing and see if it makes any difference.

Thank you all for the advises!


----------



## jcamos (Oct 28, 2021)

So the first thing I've noticed was an impressive +2h of battery on the battery status (obviously not 100% accurate these estimations but it's promising!)... now let's discharge half battery and plug the power cable to see if there's any changes.

Cheers and thanks once again! Fingers crossed


----------



## jcamos (Oct 28, 2021)

No use. It took a huge amount of time just to charge 1%. and I wasn't doing nothing.

View attachment 11851

Also, updating the BIOS gave me two news... a good and a bad. Good one is that now the battery almost doubled on duration. The bad one is that after the BIOS update my keyboard back-light just turned off. The problem is that I don't know how to change that on the command-line...


----------



## astyle (Oct 28, 2021)

jcamos said:


> No use. It took a huge amount of time just to charge 1%. and I wasn't doing nothing.
> 
> View attachment 11851
> 
> Also, updating the BIOS gave me two news... a good and a bad. Good one is that now the battery almost doubled on duration. The bad one is that after the BIOS update my keyboard back-light just turned off. The problem is that I don't know how to change that on the command-line...


Ummm... woudn't the BIOS provide a way to control the keyboard backlight? I actually went through a similar experience about 10 years ago, lost the backlight on my laptop... in my case, the backlight somehow came back on by itself a few years later... go figga.


----------



## jcamos (Oct 28, 2021)

astyle said:


> Ummm... woudn't the BIOS provide a way to control the keyboard backlight? I actually went through a similar experience about 10 years ago, lost the backlight on my laptop... in my case, the backlight somehow came back on by itself a few years later... go figga.


Just checked and nothing there to change...  Still, I can live with that!


What I don't want is to either shutdown/suspend each time I want to charge in a fast way or wait 5 hours just to charge half battery I even tried the following config on /etc/rc.conf:

```
## Power Managment
powerd_enable="NO"
powerdxx_enable="YES"
powerdxx_flags="-n min -a min -b min"
performance_cx_lowest=Cmax
economy_cx_lowest=Cmax
```
Nothing.... Anyway it doesn't make sense to have everything on minimum. What's the point? This is truly frustrating


----------



## astyle (Oct 28, 2021)

jcamos said:


> Just checked and nothing there to change...  Still, I can live with that!
> 
> 
> What I don't want is to either shutdown/suspend each time I want to charge in a fast way or wait 5 hours just to charge half battery I even tried the following config on /etc/rc.conf:
> ...


One battery-management strategy I can suggest is to charge it while you sleep. After 8 hours, you'd be fresh and ready to think your ass off.


----------



## jcamos (Oct 29, 2021)

Well, I tryed to prevent devd(8) from launching /etc/rc.d/power_profile but it didn't make any difference.

Any ideas hot to "fix" this? I mean, if you think about it, after the BIOS update, powerdxx(8) does his job to idle the system and thus saving power. In theory if you don't change nothing on your cpu performance it should charge a lot faster if the system is on idle, right (just a thought)?


----------



## a6h (Oct 29, 2021)

I know you've said that you've tried with different OSes, etc, but that 10% per hour is ridiculous!
I don't rule out a dying battery, but you may have a faulty charger. Swap with another one.
Faulty chargers sometimes (not always!) work, sometimes they don't. Drop in voltage is one sign.

Charges have few capacitors (filtering, ...) in them -- X-caps and Y-caps, etc.
Capacitors can die, but they won't drop dead necessarily. They could go leaky.

Drop in voltage is one consequence. You can measure the voltage of the charger with a mustimeter, though.
But it's easier to use another charger. By the way charger's voltage must match. (Amperage is different story!).


----------



## jcamos (Oct 29, 2021)

vigole said:


> I know you've said that you've tried with different OSes, etc, but that 10% per hour is ridiculous!
> I don't rule out a dying battery, but you may have a faulty charger. Swap with another one.
> Faulty chargers sometimes (not always!) work, sometimes they don't. Drop in voltage is one sign.
> 
> ...


Hi vigole,

Thanks for the input. I'll check my charger voltage, although it seems strange that every time I swap to another OS this doesn't happen. 

This is my readings for `acpiconf -i 0` while on battery state:

```
# acpiconf -i 0
Design capacity:    6000 mAh
Last full capacity:    5182 mAh
Technology:        secondary (rechargeable)
Design voltage:        7850 mV
Capacity (warn):    518 mAh
Capacity (low):        207 mAh
Cycle Count:        215
Mesurement Accuracy:    99 %
Max Average Interval:    -1 ms
Min Average Interval:    -1 ms
Low/warn granularity:    60 mAh
Warn/full granularity:    0 mAh
Model number:        UX431
Serial number:        123456789
Type:            LIon
OEM info:        ASUSTeK
State:            discharging
Remaining capacity:    52%
Remaining time:        3:44
Present rate:        724 mA (5683 mW)
Present voltage:    7850 mV
```

And here while it charges:

```
# acpiconf -i 0
Design capacity:    6000 mAh
Last full capacity:    5182 mAh
Technology:        secondary (rechargeable)
Design voltage:        7850 mV
Capacity (warn):    518 mAh
Capacity (low):        207 mAh
Cycle Count:        215
Mesurement Accuracy:    99 %
Max Average Interval:    -1 ms
Min Average Interval:    -1 ms
Low/warn granularity:    60 mAh
Warn/full granularity:    0 mAh
Model number:        UX431
Serial number:        123456789
Type:            LIon
OEM info:        ASUSTeK
State:            charging
Remaining capacity:    51%
Remaining time:        unknown
Present rate:        442 mA (3469 mW)
Present voltage:    7850 mV
```

P.S.: odd thing not showing the remaining time while charging though....


----------



## jbo (Oct 29, 2021)

argwings said:


> Oh, and you could take a look at the sysutils/devcpu-data port to see if an Intel microcode update helps.


How would this help at all? From a systems perspective, the CPU doesn't know anything about a battery or how to charge it.


----------



## jcamos (Oct 29, 2021)

jbodenmann said:


> How would this help at all? From a systems perspective, the CPU doesn't know anything about a battery or how to charge it.


I tried it anyway (I'm up for anything )... nothing changed.


argwings said:


> Oh, and you could take a look at the sysutils/devcpu-data port to see if an Intel microcode update helps.


Thanks anyway for the tip


----------



## argwings (Oct 29, 2021)

jbodenmann said:


> How would this help at all? From a systems perspective, the CPU doesn't know anything about a battery or how to charge it.


It knows about ACPI.


----------



## argwings (Oct 29, 2021)

I think your laptop is actually AMD Ryzen based? As far as I know their microcode updates appear in the linux-firmware tree without technical documentation of what they're supposed to fix, the port installing them to /usr/local/share/cpucontrol/microcode_amd*. Reading your laptop's manual, F7 (or probably Fn key + F7) is supposed to control your keyboard light, but I would be surprised if it works. I don't really know what other things to suggest. Some of these functions are probably supposed to be handled by the acpi_asus and acpi_asus_wmi drivers. At any rate, I'd report a bug.


----------



## astyle (Oct 30, 2021)

The UX431 model is available with both Ryzen and Intel processors.


----------



## jcamos (Oct 30, 2021)

argwings said:


> I think your laptop is actually AMD Ryzen based?


Yes.


argwings said:


> but I would be surprised if it works


Nope, doesn't work and that's another annoying thing. Also the Fn+F1/2/3/4/5/6 for the remaining hotkeys don't work either... I was able to manually allocate shortcuts for screen brightness and volume, but for the keyboard backlight and touchpad ON/OFF no luck.


argwings said:


> Some of these functions are probably supposed to be handled by the acpi_asus and acpi_asus_wmi drivers


Well, if there is, I'm not sure exactly how. Honestly I tried to look at the /etc/devd/asus.conf but I have no clue how to tweak with it...


----------



## argwings (Oct 31, 2021)

According to the acpi_asus_wmi manual there is a sysctl knob dev.acpi_asus_wmi.0.handle_keys. `sysctl dev.acpi_asus_wmi.0.handle_keys` - if it's not 1 already you can try setting it to that: `sysctl dev.acpi_asus_wmi.0.handle_keys=1`. `sysctl -a | grep asus` will show more variables which I can't test or comment on myself. `acpiconf -i 0` can show you more information about your battery and how long it thinks it will take to charge. Indication of a major problem there might be a lot of "unknown" printed there, or wildly incorrect numbers. hw.acpi.verbose set to 1 will print messages in dmesg when you plug and unplug the AC. These are a few things I can think of that might be helpful when reporting a bug.


----------

