Contribute
Register

<< Solved >> OpenCore battery patch

Status
Not open for further replies.
@moh.96

I'd use this SSDT, or the one you provided, didn't yet look into it, but you probably did a great job again.

BTW, just kind of want to share this. I started working on the automated patcher, and I'm still worlds away from something working. I just took like 30 minutes last night to experiment with interpreting ASL code, and I tried to automatically get all fields that need patching, with their offset, from EC mem.

This is what I currently have: https://github.com/BlvckBytes/AcpiHelper

I don't know if you have knowledge about programming, but it would be nice if you can execute it from time to time and just check if the offsets are actually correct. If not, no worries, I'll do so myself anyways. Maybe I should provide an executable for easier use... Later! :p. Btw, it needs a *untouched* DSDT.dsl as an input, it relies on the standard formatting.

As soon as I will find more time, I will start working on the next steps, to come closer to automated patching...

Thank you :))

I wish I can help you with the automated patcher you are working on but my programming skills are nearly zero LOL, I started learning some swift/objective C last year and as a medical student I don't have a lot of free time (I do now but not for so long), I'd be happy to try and test AcpiHelper but let me figure out how to deal with Kotlin first lol
 
@moh.96

That's exactly why I should provide an executable for releases :D. I will do so later on, so you can just execute the jar with the file path as an argument.
 
Thank you for the quick reply!
Should I also follow the steps mentioned or just add the ssdt file and reconfigure config.plist?

Just add SSDT-EC and SMCBatteryManager to your EFI (doing OC Clean Snapshot is preffered), I found like 2 or 3 registers that may need a patch but try with SMCBattery first
 
Just add SSDT-EC and SMCBatteryManager to your EFI (doing OC Clean Snapshot is preffered), I found like 2 or 3 registers that may need a patch but try with SMCBattery first
Thank you so much!!! It finally Worked!!! I observed it for a while and the percentage dropped from 100 to 96% I thought I would never get a functional battery indicator
Really appreciated a lot!!!!
Also just this much is fine or some more testing should be done to check if this working properly??? I saw that charging status also changes when plugged in and unplugged
 
Thank you so much!!! It finally Worked!!! I observed it for a while and the percentage dropped from 100 to 96% I thought I would never get a functional battery indicator
Really appreciated a lot!!!!
Also just this much is fine or some more testing should be done to check if this working properly??? I saw that charging status also changes when plugged in and unplugged

You are welcome !

tbh idk if those two registers you have that are above 8-bits should be patched or not (ERIB,16, and SMD0,256,)

since you have a working battery without problems so far, you don't need a patch but for the sake of learning I patched them so if you wanna use it then add SSDT-BAT to your ACPI, copy the patches from patches.plist to your config and do OC Clean Snapshot (remember to keep a backup of your EFI)

@BlvckBytes could you take a look at his DSDT ?
 

Attachments

  • Dell Inspiron 15 3521-Battery-Patch.zip
    5 KB · Views: 46
You are welcome !

tbh idk if those two registers you have that are above 8-bits should be patched or not (ERIB,16, and SMD0,256,)

since you have a working battery without problems so far, you don't need a patch but for the sake of learning I patched them so if you wanna use it then add SSDT-BAT to your ACPI, copy the patches from patches.plist to your config and do OC Clean Snapshot (remember to keep a backup of your EFI)
Ok I will try it with this too and see if it works
Thanks again for helping me this far now I have a perfect little hackintosh working
 
@moh.96

ERIB is only used in fan-related stuff, I guess you *could* scratch that, although it's not much work to fix it. SMD0 is something I have a hard time judging, looks like it's related with a bigger method, and I don't know what it's for.

But awesome that you've patched them both, this will make sure it's futureproof. I'd always patch all EC fields, since they probably cause errors in the background - even if not noticed.
 
@moh.96

BTW, just saw the following in your patch:

Code:
OperationRegion (ERAX, EmbeddedControl, Zero, 0xFF)
Field (ERAX, ByteAcc, Lock, Preserve)
{
    Offset (0x5D),
    ER00,   8,
    ER01,   8,
    Offset (0x64),
    SMDX,   256
}

You don't need to override SMD0, since it changes nothing. SMD0 is not being used, since no method using it will be invoked, because you rename them all. Thus, the allocated memory will not be active. Allocating it again here will do nothing.

BTW, just something *really* small: What do you mean by ERAX? The name has no effects, obviously, just like to know. I always call mine ECOR, for EmbeddedControl Override. The X suggests something disabled for me, intuitively, even tho it's trailing.
 
@moh.96

BTW, just saw the following in your patch:

Code:
OperationRegion (ERAX, EmbeddedControl, Zero, 0xFF)
Field (ERAX, ByteAcc, Lock, Preserve)
{
    Offset (0x5D),
    ER00,   8,
    ER01,   8,
    Offset (0x64),
    SMDX,   256
}

You don't need to override SMD0, since it changes nothing. SMD0 is not being used, since no method using it will be invoked, because you rename them all. Thus, the allocated memory will not be active. Allocating it again here will do nothing.

BTW, just something *really* small: What do you mean by ERAX? The name has no effects, obviously, just like to know. I always call mine ECOR, for EmbeddedControl Override. The X suggests something disabled for me, intuitively, even tho it's trailing.

Actually I know I don't need SMDX but idk why I always include it lol

For the ERAX well I don't rename the whole EC I just replace the last letter with X, probably it's a good idea to rename it to ECOR, I know it won't make a difference but it sound more professional lol
 
@moh.96

Alright, I added another small thing to my acpihelper. It now prints the partitioned smaller fields with offsets. Next goal is to translate that into source code for the SSDT, which should be rather easy.

Here is an example, the input:

Code:
OperationRegion (ECW1, EmbeddedControl, Zero, 0xFF)
Field (ECW1, ByteAcc, Lock, Preserve)
{
    Offset (0x3A),
    CMDR,   8,
    Offset (0x40),
    UPDV,   16,
    URDC,   16,
    MAXP,   16,
    SUSP,   16,
    Offset (0x80),
    LDET,   1,
    LDST,   1,
    Offset (0x81),
    EPWS,   8,
    EB0S,   8,
    Offset (0x90),
    ATES,   16,
    BTES,   16, 
    CTES,   16,
    DTES,   16,
    LOLO,   32,
    C1ES,   8,
    B0PN,   16,
    B0VL,   16,
    B0RC,   16,
    B0FC,   16,
    B0ST,   16,
    B0CC,   16,
    B0TM,   16,
    B0C1,   16,
    B0CV,   16,
    B0DC,   16,
    B0DV,   16,
    B0SN,   16,
    B0MD,   16,
    B0CT,   16,
    Offset (0xE7),
    EKVA,   16,
    EALS,   1,
        ,   1,
        ,   1,
        ,   1,
        ,   1,
        ,   1,
        ,   1,
    BALS,   1,
    EULV,   16,
    ELLV,   16,
    CALS,   16,
    ELUX,   16
}

And the output would be:
Code:
----------- AcpiHelper -----------
> An experimental tool by BlvckBytes
----------- AcpiHelper -----------

EcField(offset=0x40, name=UPDV, size=16):
> EcField(offset=0x40, name=0PDV, size=8)
> EcField(offset=0x41, name=1PDV, size=8)
end of field

EcField(offset=0x42, name=URDC, size=16):
> EcField(offset=0x42, name=0RDC, size=8)
> EcField(offset=0x43, name=1RDC, size=8)
end of field

EcField(offset=0x44, name=MAXP, size=16):
> EcField(offset=0x44, name=0AXP, size=8)
> EcField(offset=0x45, name=1AXP, size=8)
end of field

EcField(offset=0x46, name=SUSP, size=16):
> EcField(offset=0x46, name=0USP, size=8)
> EcField(offset=0x47, name=1USP, size=8)
end of field

EcField(offset=0x90, name=ATES, size=16):
> EcField(offset=0x90, name=0TES, size=8)
> EcField(offset=0x91, name=1TES, size=8)
end of field

EcField(offset=0x92, name=BTES, size=16):
> EcField(offset=0x92, name=B0ES, size=8)
> EcField(offset=0x93, name=B1ES, size=8)
end of field

EcField(offset=0x94, name=CTES, size=16):
> EcField(offset=0x94, name=CT0S, size=8)
> EcField(offset=0x95, name=CT1S, size=8)
end of field

EcField(offset=0x96, name=DTES, size=16):
> EcField(offset=0x96, name=D0ES, size=8)
> EcField(offset=0x97, name=D1ES, size=8)
end of field

EcField(offset=0x98, name=LOLO, size=32):
> EcField(offset=0x98, name=0OLO, size=8)
> EcField(offset=0x99, name=1OLO, size=8)
> EcField(offset=0x9A, name=2OLO, size=8)
> EcField(offset=0x9B, name=3OLO, size=8)
end of field

EcField(offset=0x9D, name=B0PN, size=16):
> EcField(offset=0x9D, name=00PN, size=8)
> EcField(offset=0x9E, name=10PN, size=8)
end of field

EcField(offset=0x9F, name=B0VL, size=16):
> EcField(offset=0x9F, name=00VL, size=8)
> EcField(offset=0xA0, name=10VL, size=8)
end of field

EcField(offset=0xA1, name=B0RC, size=16):
> EcField(offset=0xA1, name=00RC, size=8)
> EcField(offset=0xA2, name=10RC, size=8)
end of field

EcField(offset=0xA3, name=B0FC, size=16):
> EcField(offset=0xA3, name=00FC, size=8)
> EcField(offset=0xA4, name=10FC, size=8)
end of field

EcField(offset=0xA5, name=B0ST, size=16):
> EcField(offset=0xA5, name=00ST, size=8)
> EcField(offset=0xA6, name=10ST, size=8)
end of field

EcField(offset=0xA7, name=B0CC, size=16):
> EcField(offset=0xA7, name=B00C, size=8)
> EcField(offset=0xA8, name=B01C, size=8)
end of field

EcField(offset=0xA9, name=B0TM, size=16):
> EcField(offset=0xA9, name=00TM, size=8)
> EcField(offset=0xAA, name=10TM, size=8)
end of field

EcField(offset=0xAB, name=B0C1, size=16):
> EcField(offset=0xAB, name=B001, size=8)
> EcField(offset=0xAC, name=B011, size=8)
end of field

EcField(offset=0xAD, name=B0CV, size=16):
> EcField(offset=0xAD, name=00CV, size=8)
> EcField(offset=0xAE, name=10CV, size=8)
end of field

EcField(offset=0xAF, name=B0DC, size=16):
> EcField(offset=0xAF, name=B0D0, size=8)
> EcField(offset=0xB0, name=B0D1, size=8)
end of field

EcField(offset=0xB1, name=B0DV, size=16):
> EcField(offset=0xB1, name=00DV, size=8)
> EcField(offset=0xB2, name=10DV, size=8)
end of field

EcField(offset=0xB3, name=B0SN, size=16):
> EcField(offset=0xB3, name=00SN, size=8)
> EcField(offset=0xB4, name=10SN, size=8)
end of field

EcField(offset=0xB5, name=B0MD, size=16):
> EcField(offset=0xB5, name=00MD, size=8)
> EcField(offset=0xB6, name=10MD, size=8)
end of field

EcField(offset=0xB7, name=B0CT, size=16):
> EcField(offset=0xB7, name=00CT, size=8)
> EcField(offset=0xB8, name=10CT, size=8)
end of field

EcField(offset=0xE7, name=EKVA, size=16):
> EcField(offset=0xE7, name=0KVA, size=8)
> EcField(offset=0xE8, name=1KVA, size=8)
end of field

EcField(offset=0xEA, name=EULV, size=16):
> EcField(offset=0xEA, name=0ULV, size=8)
> EcField(offset=0xEB, name=1ULV, size=8)
end of field

EcField(offset=0xEC, name=ELLV, size=16):
> EcField(offset=0xEC, name=0LLV, size=8)
> EcField(offset=0xED, name=1LLV, size=8)
end of field

EcField(offset=0xEE, name=CALS, size=16):
> EcField(offset=0xEE, name=0ALS, size=8)
> EcField(offset=0xEF, name=1ALS, size=8)
end of field

EcField(offset=0xF0, name=ELUX, size=16):
> EcField(offset=0xF0, name=0LUX, size=8)
> EcField(offset=0xF1, name=1LUX, size=8)
end of field


Goodbye!

As you can see, this is very experimental and probably contains bugs. But still, it's a start, something to build on in the future. I also created an executable now.

 
Last edited:
Status
Not open for further replies.
Back
Top