How to clear / reset smart battery memory

batterypower-managementsmbios

So, I got a new battery for my laptop, and right from the get go, I'm having problems.

The battery came almost entirely discharged from the manufacturer. I plugged it into my computer and the batter would report that the charge rate is 0, and hence would never reach "fully charged"

After a couple minutes and having X11 crash, I'm now at this (upower -i /org/freedesktop/UPower/devices/battery_BAT0):

  native-path:          BAT0
  vendor:               Hewlett-Packard
  model:                Primary
  power supply:         yes
  updated:              Fri 21 Oct 2016 08:28:33 AM CEST (106 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    warning-level:       none
    energy:              17.8704 Wh
    energy-empty:        0 Wh
    energy-full:         24.192 Wh
    energy-full-design:  95.04 Wh
    energy-rate:         0.0996923 W
    voltage:             15.947 V
    percentage:          73%
    capacity:            25.4545%
    technology:          lithium-ion
    icon-name:          'battery-full-charging-symbolic'

So the battery is charging, the energy capacity is only about a quarter of what it was designed (even though the battery is only a couple days old), it sits at 73%, and the charge rate is so small, it doesn't even report how much it'd take till fully charged.

Now, I know you can kinda "calibrate" a battery, by charging it for a couple hours, then letting it run flat, and then charge it up again.

This doesn't seem to be the right way to do, though. I'm wondering if I can't access the smart data directly, via the SMBus.

i2cdetect -l reports:

i2c-0   smbus       SMBus I801 adapter at 8000          SMBus adapter
i2c-1   i2c         NVIDIA i2c adapter 0 at 1:00.0      I2C adapter
i2c-2   i2c         NVIDIA i2c adapter 2 at 1:00.0      I2C adapter
i2c-3   i2c         NVIDIA i2c adapter 3 at 1:00.0      I2C adapter
i2c-4   i2c         NVIDIA i2c adapter 5 at 1:00.0      I2C adapter

So, I tried probing SMBus (i2cdetect -r 0):

WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0 using read byte commands.
I will probe address range 0x03-0x77.
Continue? [Y/n] y   
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

This is quite strange to me, does that mean there's nothing connected to the bus?

No matter which address I'm trying to dump, the result is always the same:

i2cdump 0 0x03 (all other valid addresses produce the same output):

No size specified (using byte-data access)
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0, address 0x1a, mode byte
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
10: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
20: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
30: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
40: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
50: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
60: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
70: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
80: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
90: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
a0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
b0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
c0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
d0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
e0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
f0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX

That's how far I got.

The system gets it's battery information from somewhere, but I can't figure out how and from where.

As for the I²C / SMBus access to the battery: no idea if I'm doing something wrong, or it's impossible like that.

I'd like to know how to access smart battery data, how to set it (presumably with i2cset), and possibly how it's formatted (what data encodes which information, etc.)


acpi -V is even more confused:

Battery 0: Unknown, 73%
Battery 0: design capacity 6600 mAh, last full capacity 1680 mAh = 25%
Adapter 0: on-line

(design capacity reported incorrectly, etc.)


Last bit of information I can come up with, is dmidecode output:

Handle 0x0010, DMI type 39, 22 bytes
System Power Supply
    Location: OEM_Define0
    Name: OEM_Define1
    Manufacturer: OEM_Define2
    Serial Number: OEM_Define2
    Asset Tag: OEM_Define3
    Model Part Number: OEM_Define4
    Revision: OEM_Define5
    Max Power Capacity: 75 W
    Status: Present, OK
    Type: Regulator
    Input Voltage Range Switching: Auto-switch
    Plugged: No
    Hot Replaceable: No

You can see all these "OEM_Define2", etc. strings in there, that aren't telling much.

dmidecode -t connector reports:

Getting SMBIOS data from sysfs.
SMBIOS 2.4 present.

Best Answer

The Smart Battery Specification (SBS) bus is not directly accessible from the OS. It is however, possible to communicate directly with the battery via a USB-I2C adapter connected directly to the battery pins.

EDIT: https://media.blackhat.com/bh-us-11/Miller/BH_US_11_Miller_Battery_Firmware_Public_WP.pdf

EDIT 2: I personally managed to talk directly to the battery using a Raspberry PI's i2c pins and the commands you mentioned.

Related Question