Contribute
Register

[Guide] How to patch DSDT for working battery status

Sorry to bug you with this again, but could you take a look at the patch I put together to patch the BMFN buffer field, when I applied it it came back that the one in BATT method is still needs to be changed, so something must be wrong:

into device label EC0 code_regex (BMFN,)\s+(72) replace_matched begin BMFX,%2,//%1%2 end;

# utility methods to read/write buffers from/to EC
into method label RE1B parent_label EC0 remove_entry;
into method label RECB parent_label EC0 remove_entry;
into device label EC0 insert
begin
Method (RE1B, 1, NotSerialized)\n
{\n
OperationRegion(ERAM, EmbeddedControl, Arg0, 1)\n
Field(ERAM, ByteAcc, NoLock, Preserve) { BYTE, 8 }\n
Return(BYTE)\n
}\n
Method (RECB, 2, Serialized)\n
// Arg0 - offset in bytes from zero-based EC\n
// Arg1 - size of buffer in bits\n
{\n
ShiftRight(Arg1, 3, Arg1)\n
Name(TEMP, Buffer(Arg1) { })\n
Add(Arg0, Arg1, Arg1)\n
Store(0, Local0)\n
While (LLess(Arg0, Arg1))\n
{\n
Store(RE1B(Arg0), Index(TEMP, Local0))\n
Increment(Arg0)\n
Increment(Local0)\n
}\n
Return(TEMP)\n
}\n
end;


into method label BATT code_regex \(BMFN, replaceall_matched begin (RECB(0x10,72), end;

Thank you
 

Attachments

  • DSDT.aml
    43.1 KB · Views: 87
...
into method label BATT code_regex \(BMFN, replaceall_matched begin (RECB(0x10,72), end;

The pattern you're looking for "(BMFN," does not exist in the DSDT.

This is the code you're trying to change:
Code:
                        Store (^^PCI0.LPC.EC0.BMFN, Local1)
 
The pattern you're looking for "(BMFN," does not exist in the DSDT.

This is the code you're trying to change:
Code:
                        Store (^^PCI0.LPC.EC0.BMFN, Local1)

Sorry I still don't get it, what would patch look like for that.
Thank you
 
Sorry I still don't get it, what would patch look like for that.
Thank you

I'll let you test/debug/finish, but you're looking for "(^^PCI0.LPC.EC0.BMFN,"

so regex for that pattern is "\(\^\^PCI0\.LPC\.EC0\.BMFN,"

And you want to replace it with: "(^^PCI0.LPC.EC0.RECB(0x10,72),"

So you end up with:
Code:
into method label BATT code_regex \(\^\^PCI0\.LPC\.EC0\.BMFN, replaceall_matched begin (^^PCI0.LPC.EC0.RECB(0x10,72), end;
 
I'll let you test/debug/finish, but you're looking for "(^^PCI0.LPC.EC0.BMFN,"

so regex for that pattern is "\(\^\^PCI0\.LPC\.EC0\.BMFN,"

And you want to replace it with: "(^^PCI0.LPC.EC0.RECB(0x10,72),"

So you end up with:
Code:
into method label BATT code_regex \(\^\^PCI0\.LPC\.EC0\.BMFN, replaceall_matched begin (^^PCI0.LPC.EC0.RECB(0x10,72), end;

Thank you, that worked great, but battery status is still not showing up, the ACPIBatteryManager.kext loads, but the AppleSmartBatteryManager doesn't load.
As far as you can tell, is the DSDT fully patched now?
 

Attachments

  • DSDT.aml
    43.2 KB · Views: 82
Your patches create errors in the DSDT. You need an error free compile before you can use the patched DSDT.

How can I fix this error "Object is not accessible from this scope"?
 

Now i've rebuild my dsdt following the guide that you link..i've also applied the battery patch but the problem seems to be the same...i've attached the dsdt fully patched and the log...(my battery status always work, but i don't know if it has a correct indication...i think that i must find a way to erase the "capacity read zero" error)...thanks

EDIT: this is what iron from terminal show:

Code:
[FONT=Menlo]MacBook-Pro-di-Federico:~ federicoangeloni$ ioreg -n AppleSmartBattery -r AppleSmartBattery[/FONT]
[FONT=Menlo]+-o AppleSmartBattery  <class rehab_ACPIBattery, id 0x1000001f8, registered, ma$[/FONT]
[FONT=Menlo]    {[/FONT]
[FONT=Menlo]      "ExternalConnected" = Yes[/FONT]
[FONT=Menlo]      "TimeRemaining" = 5[/FONT]
[FONT=Menlo]      "InstantTimeToEmpty" = 65535[/FONT]
[FONT=Menlo]      "ExternalChargeCapable" = Yes[/FONT]
[FONT=Menlo]      "CellVoltage" = (3739,3739,3739,3741)[/FONT]
[FONT=Menlo]      "AtWarnLevel" = No[/FONT]
[FONT=Menlo]      "BatteryInvalidWakeSeconds" = 30[/FONT]
[FONT=Menlo]      "PermanentFailureStatus" = 0[/FONT]
[FONT=Menlo]      "MaxCapacity" = 2781[/FONT]
[FONT=Menlo]      "Voltage" = 14958[/FONT]
[FONT=Menlo]      "Quick Poll" = No[/FONT]
[FONT=Menlo]      "Manufacturer" = "LENOVO "[/FONT]
[FONT=Menlo]      "LatestErrorType" = "Capacity Read Zero"[/FONT]
[FONT=Menlo]      "CurrentCapacity" = 1041[/FONT]
[FONT=Menlo]      "LegacyBatteryInfo" = {"Amperage"=20652,"Flags"=7,"Capacity"=2781,"Curren$[/FONT]
[FONT=Menlo]      "FirmwareSerialNumber" = 266599[/FONT]
[FONT=Menlo]      "BatteryInstalled" = Yes[/FONT]
[FONT=Menlo]      "CycleCount" = 0[/FONT]
[FONT=Menlo]      "DesignCapacity" = 0[/FONT]
[FONT=Menlo]      "AvgTimeToFull" = 5[/FONT]
[FONT=Menlo]      "ManufactureDate" = 0[/FONT]
[FONT=Menlo]      "AtCriticalLevel" = No[/FONT]
[FONT=Menlo]      "BatteryType" = "Li-Ion"[/FONT]
[FONT=Menlo]      "InstantTimeToFull" = 5[/FONT]
[FONT=Menlo]      "BatterySerialNumber" = "PABAS0241231-41167"[/FONT]
[FONT=Menlo]      "PostDischargeWaitSeconds" = 120[/FONT]
[FONT=Menlo]      "InstantAmperage" = 20652[/FONT]
[FONT=Menlo]      "MaxErr" = 0[/FONT]
[FONT=Menlo]      "FullyCharged" = No[/FONT]
[FONT=Menlo]      "DeviceName" = "PABAS0241231"[/FONT]
[FONT=Menlo]      "IOGeneralInterest" = "IOCommand is not serializable"[/FONT]
[FONT=Menlo]      "Amperage" = 20652[/FONT]
[FONT=Menlo]      "IsCharging" = Yes[/FONT]
[FONT=Menlo]      "PostChargeWaitSeconds" = 120[/FONT]
[FONT=Menlo]      "AvgTimeToEmpty" = 65535[/FONT]
[FONT=Menlo]    }[/FONT]
 

Attachments

  • DSDT.zip
    16.7 KB · Views: 62
  • Log Battery.txt
    3 KB · Views: 96
Thank you, that worked great, but battery status is still not showing up, the ACPIBatteryManager.kext loads, but the AppleSmartBatteryManager doesn't load.
As far as you can tell, is the DSDT fully patched now?

AppleSmartBatteryManager is not expected to load.

Use the debug ACPIBatteryManager.kext to determine which methods are failing.
 
How can I fix this error "Object is not accessible from this scope"?

You need to patch each case correctly. Work on them one one at a time. Make sure you run through the example DSDT first.

The error indicates you're trying to access and identifier that doesn't exist.
 
Back
Top