You are not logged in.

#1 2013-10-20 19:41:01

mcloaked
Member
From: Yorkshire, UK
Registered: 2012-02-02
Posts: 1,240

[SOLVED] Incorrect battery indication after booting laptop on ac power

I am trying to track down where the origin of a problem of my battery showing zero charge after booting with ac power plugged in lies - I don't know if this is a kernel or possibly a upower issue but I have reported on the KDE bug reporting system at:

https://bugs.kde.org/show_bug.cgi?id=326332

since I initially thought it was a KDE battery monitor problem. If anyone can point me in a direction to find where the bug lies I would be grateful.  Also I don't know if this should be reported as a kernel bug or for upower upstream. The  problem started in the last week or so but not sure which update is responsible - the upower package is one possibility.

Thanks for any hints to help me with this.

Edit - I also see that the upower package is marked out of date as of the 18th October.

Last edited by mcloaked (2013-10-24 20:51:31)


Mike C

Offline

#2 2013-10-20 19:46:55

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Incorrect battery indication after booting laptop on ac power

Hardware?

I had a similar issue when this machine was brand new (Thinkpad E430).  I too thought it was something to do with the operating system. But it turned out that it was actually the bios being wonky.  An bios update fixed it.  But during that time, I was able to get things to reset back to normal if I turned off the machine and then did what the DD-WRT world calls a 30-30-30 reset.  I'm not sure why it worked, but it did.  The biggest problem with the inaccuracy was that it would sometimes indicate the battery was full when it wasn't and stop charging.

Offline

#3 2013-10-20 19:48:03

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] Incorrect battery indication after booting laptop on ac power

Is /sys/class/blahblahblah being read correctly?


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#4 2013-10-20 19:48:53

mcloaked
Member
From: Yorkshire, UK
Registered: 2012-02-02
Posts: 1,240

Re: [SOLVED] Incorrect battery indication after booting laptop on ac power

WonderWoofy wrote:

Hardware?

I had a similar issue when this machine was brand new (Thinkpad E430).  I too thought it was something to do with the operating system. But it turned out that it was actually the bios being wonky.  An bios update fixed it.  But during that time, I was able to get things to reset back to normal if I turned off the machine and then did what the DD-WRT world calls a 30-30-30 reset.  I'm not sure why it worked, but it did.  The biggest problem with the inaccuracy was that it would sometimes indicate the battery was full when it wasn't and stop charging.

Dell Inspiron M4300 laptop. BIOS has never been an issue and has not changed for a long time. I don't know the 30-30-30 reset!  However the battery indication has been fine on boot as far back as I can remember until the last week. I have put a fair bit of detail in the KDE bug report that I quoted.

Last edited by mcloaked (2013-10-20 19:49:51)


Mike C

Offline

#5 2013-10-20 19:51:49

mcloaked
Member
From: Yorkshire, UK
Registered: 2012-02-02
Posts: 1,240

Re: [SOLVED] Incorrect battery indication after booting laptop on ac power

jasonwryan wrote:

Is /sys/class/blahblahblah being read correctly?

I put some of those results into the bug report that I quoted. Look at the two screenshots - but also I put some upower -d output into that report also.  That would indicate that /sys/class/xxxxxxxx is correct but upower output is wrong. If that is the case does that point to upower being the culprit?  I guess that since the value of /sys/class/power_supply/BAT0/charge_now looks correct(ish) then that is filled by the kernel, and then I guess upower is not utilising the value correctly?

Added comment: checking the pacman log shows upower updated at around the time I started seeing this problem.

[2013-10-16 18:29] [PACMAN] upgraded upower (0.9.20-2 -> 0.9.22-1)

Looks like 0.9.23 was released on 18th October:

http://upower.freedesktop.org/releases/

I'll wait until this version is in the arch repos and test  - if the bug remains after that then I'll report to the freedesktop upstream bug reporter.

Last edited by mcloaked (2013-10-20 20:24:05)


Mike C

Offline

#6 2013-10-20 20:48:13

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Incorrect battery indication after booting laptop on ac power

If you try something else, does the correct value come up?  I keep acpi installed on my system so that I can check battery precentage from the TTY (the package and command is actually called acpi, I'm not referring to the kernel functionality which is obviously on my system).

Offline

#7 2013-10-20 20:57:31

mcloaked
Member
From: Yorkshire, UK
Registered: 2012-02-02
Posts: 1,240

Re: [SOLVED] Incorrect battery indication after booting laptop on ac power

WonderWoofy wrote:

If you try something else, does the correct value come up?  I keep acpi installed on my system so that I can check battery precentage from the TTY (the package and command is actually called acpi, I'm not referring to the kernel functionality which is obviously on my system).

Thanks for the suggestion - I used to have acpi but removed it quite a while back.  If the latest version of upower hits the mirrors in the next few days I will test that first - in the meantime I can get to a correct indication if I boot up, then remove the power cord at which point the system beeps and the KDE indication switches to a correct value, and then plugging the power cord back in then keeps the correct indication. So it is a 5 second fiddle to pull out the power cord and put it back in. However it would be nice to see the fix in place so that it shows correctly at boot.  I haven't tried to boot without the power cord in as a secondary test, and then plug the power cord in only after the system has booted up.

Added comment - I have tested by booting without the power cord in and it shows the correct battery level once logged into KDE - and continues to show the correct level if the power cord is plugged in at that point. So it is only when booting with the power cord in that gives the wrong value.

Added comment about upower source patches: In the git patch list for upower from two days ago there were several patches listed that might fix these issues so it is important to test 0.9.23
Thank you for the replies to this point from WonderWoofy and jasonwryan.

Last edited by mcloaked (2013-10-20 21:06:04)


Mike C

Offline

#8 2013-10-20 21:19:07

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Incorrect battery indication after booting laptop on ac power

Soooo.... why do you post a thread if you are just going to ignore a reasonable suggestion and repeat what you already know?  You seem to suspect that upower is somehow borked.  So if your plan was to wait for an update anyway, what is it you are trying to achieve here?

The acpi package is a whopping 24KiB that depends only on glibc.  It would literally take but a few seconds to install and test what I suggested.

So I guess just do whatever it is you're going to do.  I quit.

Offline

#9 2013-10-20 21:28:52

mcloaked
Member
From: Yorkshire, UK
Registered: 2012-02-02
Posts: 1,240

Re: [SOLVED] Incorrect battery indication after booting laptop on ac power

WonderWoofy wrote:

Soooo.... why do you post a thread if you are just going to ignore a reasonable suggestion and repeat what you already know?  You seem to suspect that upower is somehow borked.  So if your plan was to wait for an update anyway, what is it you are trying to achieve here?

The acpi package is a whopping 24KiB that depends only on glibc.  It would literally take but a few seconds to install and test what I suggested.

So I guess just do whatever it is you're going to do.  I quit.

I didn't know about upower being the most likely candidate for the problem when I first posted.  I was looking for how to track down the likely culprit so that I could file a bug report in the right place to get it fixed. Only at a late stage with further information did I realise it was likely upower, and also very late realised there was a newer upstream version than is in the arch repos.  Only at that point did I think that it was then worth waiting a day or two to test if that had the fix.

I was not ignoring your suggestion but I removed acpi because I have some slightly involved scheme to set screen brightness  through a script called through the KDE power settings widget that acpi originally interfered with, which was why I removed acpi from the system. If I re-installed it then I would have issues with screen brightness that I would prefer to avoid. I could accept the brightness problem as a temporary reversion and indeed see if acpi helps or not, and indeed I will do exactly that once I've been able to see if upower 0.9.23 provides the solution. 

I hope that explains why I really was not ignoring that suggestion.


Mike C

Offline

#10 2013-10-20 21:30:37

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Incorrect battery indication after booting laptop on ac power

acpi != acpid

Offline

#11 2013-10-20 21:35:34

mcloaked
Member
From: Yorkshire, UK
Registered: 2012-02-02
Posts: 1,240

Re: [SOLVED] Incorrect battery indication after booting laptop on ac power

I have acpi and acpid installed as well as upower - the problem remains exactly as before - so now I am more confused - and I now don't know whether the conclusion I drew earlier that it was likely upower that was the problem or not. Should I test with upower uninstalled?

Added: I realise that I can't uninstall upower as "kdelibs: requires upower"!

Also the old problems I had with brightness are not present even with acpi installed now so I will leave acpi and acpid installed and continue to test over the coming days with both still in the system.

Last edited by mcloaked (2013-10-20 21:44:32)


Mike C

Offline

#12 2013-10-20 22:33:12

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,140

Re: [SOLVED] Incorrect battery indication after booting laptop on ac power

I think WonderWoofy was suggesting that you use the acpi command to see if it reports the charge correctly. If not, it is unlikely upower is the culprit. If so, it then seems more likely upower is to blame.

$ acpi -b
Battery 0: Full, 100%

$ upower -i /org/freedesktop/UPower/devices/battery_BAT1 | grep energy
    energy:              41.45 Wh
    energy-empty:        0 Wh
    energy-full:         41.45 Wh
    energy-full-design:  62.16 Wh
    energy-rate:         0 W

$ cat /sys/class/power_supply/BAT1/energy_*
41450000
62160000
41450000

In your case, the second command gives the wrong information but the third gives the correct information. What about the first one?


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#13 2013-10-21 09:25:25

mcloaked
Member
From: Yorkshire, UK
Registered: 2012-02-02
Posts: 1,240

Re: [SOLVED] Incorrect battery indication after booting laptop on ac power

Thank you Cfr, I was clearly befuddled last night. 

Here is the result of executing the equivalent commands just after boot and login:

[mike@lapmike3 ~]$ acpi -b
Battery 0: Full, 100%
[mike@lapmike3 ~]$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 
  native-path:          BAT0
  vendor:               SMP
  model:                DELL XD7368
  serial:               3261
  power supply:         yes
  updated:              Mon 21 Oct 2013 10:12:44 BST (62 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               fully-charged
    energy:              57.72 Wh
    energy-empty:        0 Wh
    energy-full:         57.72 Wh
    energy-full-design:  57.72 Wh
    energy-rate:         0.0111 W
    voltage:             12.566 V
    percentage:          0%
    capacity:            92.4615%
    technology:          lithium-ion
  History (charge):
    1382346759  0.000   unknown
  History (rate):
    1382346760  0.011   fully-charged
    1382346759  0.000   unknown

[mike@lapmike3 ~]$ cat /sys/class/power_supply/BAT0/charge_*
4808000
5200000
5200000
[mike@lapmike3 ~]$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep energy
    energy:              57.72 Wh
    energy-empty:        0 Wh
    energy-full:         57.72 Wh
    energy-full-design:  57.72 Wh
    energy-rate:         0.0111 W
[mike@lapmike3 ~]$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep percentage
    percentage:          0%

and then after the power cable has been unplugged and then re-plugged:

[mike@lapmike3 ~]$ acpi -b
Battery 0: Full, 100%
[mike@lapmike3 ~]$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 
  native-path:          BAT0
  vendor:               SMP
  model:                DELL XD7368
  serial:               3261
  power supply:         yes
  updated:              Mon 21 Oct 2013 10:15:15 BST (186 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               fully-charged
    energy:              57.72 Wh
    energy-empty:        0 Wh
    energy-full:         57.72 Wh
    energy-full-design:  57.72 Wh
    energy-rate:         0.0111 W
    voltage:             12.552 V
    percentage:          95%
    capacity:            92.4615%
    technology:          lithium-ion
[mike@lapmike3 ~]$ cat /sys/class/power_supply/BAT0/charge_*
4808000
5200000
5200000

[mike@lapmike3 ~]$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep energy
    energy:              57.72 Wh
    energy-empty:        0 Wh
    energy-full:         57.72 Wh
    energy-full-design:  57.72 Wh
    energy-rate:         0.0111 W
[mike@lapmike3 ~]$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep percentage
    percentage:          95%

This now indicates quite clearly that although the battery is close to full, and acpi indicates this both before and after the power cable is unplugged and replugged, upower shows the battery percentage as 0% immediately after boot, and only corrects this to 95% after the power cable action, which does point to upower being the problem package.

Thank you WonderWoofy for bringing this good test to my attention - I do now need to test the newer version. If once that is done when upower 0.9.23 is released to the repos and the problem remains then I will report the bug upstream.

I will close this thread once I have completed the test on 0.9.23 and reported back.


Mike C

Offline

#14 2013-10-24 20:51:12

mcloaked
Member
From: Yorkshire, UK
Registered: 2012-02-02
Posts: 1,240

Re: [SOLVED] Incorrect battery indication after booting laptop on ac power

This evening after the following packages were updated:

( 1/15) upgrading curl                                                          [##############################################] 100%
( 2/15) upgrading dialog                                                        [##############################################] 100%
( 3/15) upgrading faad2                                                         [##############################################] 100%
( 4/15) upgrading jasper                                                        [##############################################] 100%
( 5/15) upgrading lcms2                                                         [##############################################] 100%
( 6/15) upgrading libarchive                                                    [##############################################] 100%
( 7/15) upgrading libmad                                                        [##############################################] 100%
( 8/15) upgrading libmng                                                        [##############################################] 100%
( 9/15) upgrading lua51-socket                                                  [##############################################] 100%
(10/15) upgrading qt4                                                           [##############################################] 100%
(11/15) upgrading shadow                                                        [##############################################] 100%
(12/15) upgrading util-linux                                                    [##############################################] 100%
New optional dependencies for util-linux
    python: python bindings to libmount [installed]
(13/15) upgrading systemd                                                       [##############################################] 100%
(14/15) upgrading sysvinit-tools                                                [##############################################] 100%
(15/15) upgrading systemd-sysvcompat                                            [##############################################] 100%

The battery indication in the KDE widget is now working perfectly normally, even though upower was not among the updates!  Hence this is resolved but not for the reason I expected! I don't know which of the packages in the list above made the fix but all is well (this was confirmed on a second and different laptop which was exhibiting the same issue - a Dell D610).

Last edited by mcloaked (2013-10-24 20:55:48)


Mike C

Offline

#15 2013-10-28 18:51:37

mcloaked
Member
From: Yorkshire, UK
Registered: 2012-02-02
Posts: 1,240

Re: [SOLVED] Incorrect battery indication after booting laptop on ac power

It turned out that the problem was not in fact fixed - and was due to an incorrect reporting of battery percentage in the situation that the battery is over-full.  However the latest version of upower pushed to the repos today provides the complete resolution for this problem.

pacman -Q upower
upower 0.9.23-2

The upstream report in case anyone is interested is https://bugs.freedesktop.org/show_bug.cgi?id=70952


Mike C

Offline

Board footer

Powered by FluxBB