Contribute
Register

Lenovo X230 Battery Cycle Count (Last Problem to be Solved)

Status
Not open for further replies.
Joined
Mar 28, 2017
Messages
42
Motherboard
1. Lenovo X230 2. HP Folio 9470m
CPU
1. i5 3320M 2.i5- i5-3337U
Graphics
both HD4000
Mac
  1. MacBook Air
Mobile Phone
  1. Android
Hi RehabMan,

Following my previous post regarding Shutdown issue,

https://www.tonymacx86.com/threads/...art-after-shutdown.252410/page-2#post-1763226

I borrow some codes from here:

https://github.com/ARM-software/edk2/blob/master/Vlv2DeviceRefCodePkg/AcpiTablesPCAT/Gpe.asl

It seems solve the shutdown problem after sleep.

However, when I think all the problems have been solved, I find that the battery cycle count is disappeared. I have already increased the battery information fields from 13 to 15, but the cycle count is still not there. Kindly advise which EC register is storing this information or help me to retrieve the info from your ACPIBatteryManager.kext (I think the cycle count info ever shown was also from ACPIBatteryManager) . You may find that my output from IORegistryExplorer is showing the cycle count info already, but there is only a test by adding a new register on EC. It should not be a correct one because when I changed an old battery, the count remains unchanged.

Your help is highly appreciated!
 

Attachments

  • debug_31720.zip
    2.3 MB · Views: 112
Hi RehabMan,

Following my previous post regarding Shutdown issue,

https://www.tonymacx86.com/threads/...art-after-shutdown.252410/page-2#post-1763226

I borrow some codes from here:

https://github.com/ARM-software/edk2/blob/master/Vlv2DeviceRefCodePkg/AcpiTablesPCAT/Gpe.asl

It seems solve the shutdown problem after sleep.

However, when I think all the problems have been solved, I find that the battery cycle count is disappeared. I have already increased the battery information fields from 13 to 15, but the cycle count is still not there. Kindly advise which EC register is storing this information or help me to retrieve the info from your ACPIBatteryManager.kext (I think the cycle count info ever shown was also from ACPIBatteryManager) . You may find that my output from IORegistryExplorer is showing the cycle count info already, but there is only a test by adding a new register on EC. It should not be a correct one because when I changed an old battery, the count remains unchanged.

Your help is highly appreciated!

Use the debug ACPIBatteryManager.kext to determine what is coming back from the _BIF method.
 
Welcome back RehabMan!

The debug ACPIBatteryManager.kext shows that the Design Capacity is lower than the Max Capacity. I think this is the reason of "Cycle Count" not showing.
 

Attachments

  • debug_6003.zip
    1.8 MB · Views: 111
Welcome back RehabMan!

The debug ACPIBatteryManager.kext shows that the Design Capacity is lower than the Max Capacity. I think this is the reason of "Cycle Count" not showing.

Your _BIF implementation is likely returning 0 for cycle count.
In that case, CycleCount is not written to ioreg.
Code:
Note:
    //rehabman: zprood's technique of expanding the _BIF to include cycle count
    uint32_t cycleCnt = 0;
    if (acpibat_bif->getCount() > BIF_CYCLE_COUNT)
        cycleCnt = GetValueFromArray(acpibat_bif, BIF_CYCLE_COUNT);
    else if (fDesignCapacity > fMaxCapacity && fEstimateCycleCountDivisor)
        cycleCnt = (fDesignCapacity - fMaxCapacity) / fEstimateCycleCountDivisor;
    if (cycleCnt)
        setCycleCount(cycleCnt);
 
Hi RehabMan,

Thank you for your confirmation!

By using the old battery's design capacity 6216, the calculation of the cycle count is making more sense. I suspect that manufacturer forgot to update the design capacity bits when upgrade to higher capacity cells. I then use the following code for the cycle count calculation, but it will only work for a 4 cell battery. Although it is not perfect, it still can be used for reference.

Code:
                            //cycle count
                           If (LGreater (Local0, Local1))
                            {
                             
                            Store (Add (Divide (Subtract (Local0, Local1), 0x06), Divide (Subtract (0x00001848, Local0), 0x06)), Index (Arg1, 0x0D))

                             }
                            Else
                            { 
                             
                                Store (Divide (Subtract (0x00001848, Local1), 0x06), Index (Arg1, 0x0D))
                            }
 
Hi RehabMan,

Thank you for your confirmation!

By using the old battery's design capacity 6216, the calculation of the cycle count is making more sense. I suspect that manufacturer forgot to update the design capacity bits when upgrade to higher capacity cells. I then use the following code for the cycle count calculation, but it will only work for a 4 cell battery. Although it is not perfect, it still can be used for reference.

Code:
                            //cycle count
                           If (LGreater (Local0, Local1))
                            {
                           
                            Store (Add (Divide (Subtract (Local0, Local1), 0x06), Divide (Subtract (0x00001848, Local0), 0x06)), Index (Arg1, 0x0D))

                             }
                            Else
                            {
                           
                                Store (Divide (Subtract (0x00001848, Local1), 0x06), Index (Arg1, 0x0D))
                            }

I thought you were attempting to provide actual cycle count in your _BIF code?
Not the case?
 
Yes, of course I want to. But I think it is impossible, then should find a workaround.
 
Your professional opinion is sought!
 
Yes, of course I want to. But I think it is impossible, then should find a workaround.
Your professional opinion is sought!

Requires that you reverse engineer the EC in hopes you find where the cycle count is stored (if it is there at all).
 
I did use 15 fields of _BIF to retrieve total length (256bits; 32 bytes) of EC (EmbeddedController claims that the total length is 0x100), but no one seems to be the correct cycle count.
 
Status
Not open for further replies.
Back
Top