Contribute
Register

[Guide] How to patch DSDT for working battery status

How to patch DSDT for working battery status

What tools do I need to install it correctly?

Read post #1 and work through the example.
 
How to patch DSDT for working battery status

thanks for the url i was looking for that without any luck

dsdt required patches for debug DONE
install debug kext DONE

i fail to understand last point where to place the log file

Hi

Could you tell me how to do the last part to use debug version?

which code i have to enter in my dsdt to get system.log about Method _BST?

thank you
bye
 
How to patch DSDT for working battery status

thanks for the url i was looking for that without any luck

dsdt required patches for debug DONE
install debug kext DONE

i fail to understand last point where to place the log file

You view system.log via Console.app.
 
How to patch DSDT for working battery status

Hi

Could you tell me how to do the last part to use debug version?

which code i have to enter in my dsdt to get system.log about Method _BST?

thank you
bye

Hopefully you have some programming experience so you understand the concept of printing variables and other debug traces to help understand what is going on (wrong) in the code.
 
How to patch DSDT for working battery status

Hopefully you have some programming experience so you understand the concept of printing variables and other debug traces to help understand what is going on (wrong) in the code.

this is what i get from console with battery and ac plugged in system.log

Jun 19 14:50:47 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBatteryManager::getBatteryBST called
Jun 19 14:50:47 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: acpibat_bst size = 4
Jun 19 14:50:47 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fPowerUnit = 0x1
Jun 19 14:50:47 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: currentStatus = 0x2
Jun 19 14:50:47 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentRate = 0x9da
Jun 19 14:50:47 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentCapacity = 0x684
Jun 19 14:50:47 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentVoltage = 0x2baf
Jun 19 14:50:47 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fAverageRate = 0x9da
Jun 19 14:51:17 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBatteryManager::getBatteryBST called
Jun 19 14:51:17 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: acpibat_bst size = 4
Jun 19 14:51:17 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fPowerUnit = 0x1
Jun 19 14:51:17 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: currentStatus = 0x2
Jun 19 14:51:17 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentRate = 0x98f
Jun 19 14:51:17 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentCapacity = 0x699
Jun 19 14:51:17 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentVoltage = 0x2bd9
Jun 19 14:51:17 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fAverageRate = 0x98f
Jun 19 14:51:47 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBatteryManager::getBatteryBST called
Jun 19 14:51:47 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: acpibat_bst size = 4
Jun 19 14:51:47 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fPowerUnit = 0x1
Jun 19 14:51:47 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: currentStatus = 0x2
Jun 19 14:51:47 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentRate = 0x9c5
Jun 19 14:51:47 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentCapacity = 0x6ac
Jun 19 14:51:47 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentVoltage = 0x2be0
Jun 19 14:51:47 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fAverageRate = 0x9aa


and this when only battery attached (without AC) when already showed low charge message
Jun 19 14:54:06 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBatteryManager::getBatteryBST called
Jun 19 14:54:06 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: acpibat_bst size = 4
Jun 19 14:54:06 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fPowerUnit = 0x1
Jun 19 14:54:06 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: currentStatus = 0x1
Jun 19 14:54:06 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentRate = 0xffffffff
Jun 19 14:54:06 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentCapacity = 0x6ad
Jun 19 14:54:06 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentVoltage = 0x2a12
Jun 19 14:54:06 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentRate is ACPI_UNKNOWN
Jun 19 14:54:06 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: adjusted fCurrentRate to 65536
Jun 19 14:54:06 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fAverageRate = 0x10000
 
How to patch DSDT for working battery status

Jun 19 13:51:11 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::pollingTimeOut called
Jun 19 13:51:11 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::pollBatteryState: path = 0x2
Jun 19 13:51:11 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::pollBatteryState: path = 0x1
Jun 19 13:51:11 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBatteryManager::getBatterySTA called
Jun 19 13:51:11 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatterySTA: battery_status = 0xf
Jun 19 13:51:11 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery: !fBatteryPresent

...

_STA is returning 0xF instead of 0x1F. Indicates no battery is present. Analyse code in battery _STA method.
 
How to patch DSDT for working battery status

_STA is returning 0xF instead of 0x1F. Indicates no battery is present. Analyse code in battery _STA method.

sorry, battery was not attached

i corrected it in original post
 
How to patch DSDT for working battery status

...


and this when only battery attached (without AC) when already showed low charge message
...
Jun 19 14:54:06 MacBook-Pro-de-Rosendo kernel[0]: AppleSmartBattery::setBatteryBST: fCurrentRate = 0xffffffff
...

Your DSDT is returning an incorrect value in this case. Debug/analyse _BST method to determine why.
 
How to patch DSDT for working battery status

Your DSDT is returning an incorrect value in this case. Debug/analyse _BST method to determine why.

This is the method

Method (_BST, 0, NotSerialized) // _BST: Battery Status
{
If (^^PCI0.LPCB.EC.ECOK)
{
UPBS ()
}
Else
{
IVBS ()
}


Return (PBST)
}


And UPBS and IVBS

Method (UPBS, 0, NotSerialized)
{
If (^^PCI0.LPCB.EC.BAT0)
{
Store (Zero, Local0)
Store (Zero, Local1)
If (^^PCI0.LPCB.EC.ADP)
{
If (LEqual (And (B1B4 (^^PCI0.LPCB.EC.ST00, ^^PCI0.LPCB.EC.ST01, ^^PCI0.LPCB.EC.ST02, ^^PCI0.LPCB.EC.ST03), 0x02),
0x02))
{
Or (Local0, 0x02, Local0)
And (B1B4 (^^PCI0.LPCB.EC.PR00, ^^PCI0.LPCB.EC.PR01, ^^PCI0.LPCB.EC.PR02, ^^PCI0.LPCB.EC.PR03), 0xFFFF, Local1)
}
}
Else
{
Or (Local0, One, Local0)
And (B1B4 (^^PCI0.LPCB.EC.PR00, ^^PCI0.LPCB.EC.PR01, ^^PCI0.LPCB.EC.PR02, ^^PCI0.LPCB.EC.PR03), 0xFFFF, Local1)
}


And (Local1, 0x8000, Local7)
If (LEqual (Local7, 0x8000))
{
Store (0xFFFFFFFF, Local1)
}


And (B1B4 (^^PCI0.LPCB.EC.RC00, ^^PCI0.LPCB.EC.RC01, ^^PCI0.LPCB.EC.RC02, ^^PCI0.LPCB.EC.RC03), 0xFFFF, Local2)
And (B1B4 (^^PCI0.LPCB.EC.PV00, ^^PCI0.LPCB.EC.PV01, ^^PCI0.LPCB.EC.PV02, ^^PCI0.LPCB.EC.PV03), 0xFFFF, Local3)
Store (Local0, Index (PBST, Zero))
Store (Local1, Index (PBST, One))
Store (Local2, Index (PBST, 0x02))
Store (Local3, Index (PBST, 0x03))
If (LNotEqual (BFCC, B1B4 (^^PCI0.LPCB.EC.FC00, ^^PCI0.LPCB.EC.FC01, ^^PCI0.LPCB.EC.FC02, ^^PCI0.LPCB.EC.FC03)))
{
Notify (BAT0, 0x81)
}
}
Else
{
IVBS ()
}

Method (IVBS, 0, NotSerialized)
{
Store (Zero, Index (PBST, Zero))
Store (0xFFFFFFFF, Index (PBST, One))
Store (0xFFFFFFFF, Index (PBST, 0x02))
Store (0x2710, Index (PBST, 0x03))
}

Here is the 0xFFFFFFFF value

should i replace it or erase it all?

Not a clue, i got here by asking for help and trying to repeat what others already did. I'm not saying i'll give up. On the contrary i keep working and learning all i can to improve and challenge myself.
Thanks for encouraging everybody, its very important thing to do

I CAME into this (from acpi.info)

BatteryPresentRate
Integer
(DWORD)
Returns the power or current being supplied or accepted through the battery’sterminals (direction depends on the Battery State value). The Battery PresentRate value is expressed as power [mWh] or current [mAh] depending on thePower Unit value.
Batteries that are rechargeable and are in the discharging state are required toreturn a valid Battery Present Rate value.
• 0x00000000 – 0x7FFFFFFF in [mW] or [mA]
0xFFFFFFFF – Unknown rate
BatteryRemainingCapacity
Integer
(DWORD)
Returns the estimated remaining battery capacity. The Battery RemainingCapacity value is expressed as power [mWh] or current [mAh] depending on thePower Unit value.
Batteries that are rechargeable are required to return a valid
Battery RemainingCapacity value.
  • 0x00000000 – 0x7FFFFFFF in [mWh] or [mAh]
  • 0xFFFFFFFF – Unknown capacity
BatteryPresentVoltage
Integer
(DWORD)
Returns the voltage across the battery’s terminals.
Batteries that are rechargeable must report
Battery Present Voltage.
  • 0x000000000 – 0x7FFFFFFF in [mV]
  • 0xFFFFFFFF – Unknown voltage
    Note: Only a primary battery can report unknown voltage.
 
How to patch DSDT for working battery status

This is the method
...

Not a clue, i got here by asking for help and trying to repeat what others already did. I'm not saying i'll give up. On the contrary i keep working and learning all i can to improve and challenge myself.
Thanks for encouraging everybody, its very important thing to do

In that code there are several ways to have a result of 0xFFFFFFFF. You will need to determine which one is happening and why. Use ACPIDebug to insert debug tracing as necessary.
 
Back
Top