Contribute
Register

[Guide] How to patch DSDT for working battery status

Joined
Aug 2, 2013
Messages
66
Motherboard
Intel Skylake-U Premium PCH
CPU
Core i7-6500U
Graphics
Intel HD Graphics 520 (1920x1080)
Mac
MacBook Pro
Mobile Phone
iOS
No DSDT.aml provided.

Note: It seems to me that the patch file already in the repo is a match: battery_Microxperts-u731ga1.txt
Ok, true. Looks like a perfect match. I just looked into the Clevo patches. So mine would be redundant. I have one recommondation: Since the MicroXpert computer also looks like a Clevo rebrand and I know many different companies which do Clevo rebrands (TuxedoComputers, mySN, MicroXpert, one.de, ...) it seems if you rename the file in the repository to Clevo it would be much easier to find for most users.

Find in the attachment my updated folder including DSDT.aml and decompiled DSDT.dsl file (tough it is not needed anymore because its already in your repository).

Regarding my issue about lagging behind status in the top menu bar, it is gone if I put the ACPIBatteryManager.kext into /Library/Extensions/ instead of /EFI/Clover/kext/Others.

Thanks again.
BR Fox
 

Attachments

Joined
Jul 16, 2010
Messages
391
Motherboard
OP-LP3 Laptop
CPU
i7-8750H
Graphics
UHD630 (1920 x 1080)
Mac
Mac Pro
Mobile Phone
iOS
I would like to contribute my battery patch for HP Pavillion G6-1d28dx. Native and patched DSDT and the Patch itself all zipped. Its basically a modified HP Envy 14 as in your OP.

I have a few questions though, I don't understand why the code into method label _Q09 is being used for BRC0 and sBFC0 under 16 bit methods? Is the "s" in sBFC0 needed for spacing or shifting?

Since these are 16 bit they are not considered stored into H_EC buffers, BFC0, BDV0, BSN0,BMD0, BPR0, BRC0, BPV0 and FANR? Only 32 bit and above if they were stored into H_EC, EC0 or EC then one would need the WECB utility instead of the RECB one?

Also confused on the Offsets they do seem to be in a numerical order goes from 0x18 to 0x20 unless its rounds up to the next byte then from there to 0x70 doesn't seem to add up correctly?

Searchings posts from this thread found useful links below to help understand the way this works.

https://www.tonymacx86.com/threads/need-help-with-laptop-dsdt-edit-i-dont-understand-the-guide.190844/page-3#post-1239016

https://www.tonymacx86.com/threads/dell-inspiron-15-7559-fan-info.199904/page-3#post-1307846

https://www.tonymacx86.com/threads/solved-asus-ux410u-hot-patch-keyboard-backlight.233373/page-2#post-1596776

Battery works perfect charging/discharging %.

re-Edited:

I think I have the Offsets figured out re-attached files. BMN0 0x20 + 8/8 = 0x21

BCT0 0x20 +120/8 = 15 0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f

BMN0 offset is 0x21
BCT0 offset is 0x2f
 

Attachments

Last edited:

RehabMan

Moderator
Joined
May 3, 2012
Messages
191,691
Motherboard
Intel DH67BL
CPU
Core i7-2600K
Graphics
Intel HD 3000
Mac
MacBook Air
Mobile Phone
iOS
Ok, true. Looks like a perfect match. I just looked into the Clevo patches. So mine would be redundant. I have one recommondation: Since the MicroXpert computer also looks like a Clevo rebrand and I know many different companies which do Clevo rebrands (TuxedoComputers, mySN, MicroXpert, one.de, ...) it seems if you rename the file in the repository to Clevo it would be much easier to find for most users.
Files are named based on the make/model laptop of the person that created the patch.
I will add "(Clevo rebrand)" to this description which may help.

Regarding my issue about lagging behind status in the top menu bar, it is gone if I put the ACPIBatteryManager.kext into /Library/Extensions/ instead of /EFI/Clover/kext/Others.
Not surprising.
It is the correct way to install kexts as per FAQ:
https://www.tonymacx86.com/threads/faq-read-first-laptop-frequent-questions.164990/
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
191,691
Motherboard
Intel DH67BL
CPU
Core i7-2600K
Graphics
Intel HD 3000
Mac
MacBook Air
Mobile Phone
iOS
I would like to contribute my battery patch for HP Pavillion G6-1d28dx. Native and patched DSDT and the Patch itself all zipped. Its basically a modified HP Envy 14 as in your OP.
If the Envy 14 patch will work with slight modifications, we should be just modifying the patch to add any additional required patches instead of adding an entirely new patch.

I have a few questions though, I don't understand why the code into method label _Q09 is being used for BRC0 and sBFC0 under 16 bit methods? Is the "s" in sBFC0 needed for spacing or shifting?
\s corresponds to ' ' in regex.

Since these are 16 bit they are not considered stored into H_EC buffers, BFC0, BDV0, BSN0,BMD0, BPR0, BRC0, BPV0 and FANR? Only 32 bit and above if they were stored into H_EC, EC0 or EC then one would need the WECB utility instead of the RECB one?
As per guide, 16-bit can be handled via splitting to 2x 8-bit and B1B2.
32-bit, split into 4x 8-bit and B1B4.
Larger than 32-bit are handled with WECB/RECB.

Also confused on the Offsets they do seem to be in a numerical order goes from 0x18 to 0x20 unless its rounds up to the next byte then from there to 0x70 doesn't seem to add up correctly?
You need to be specific with your question. I have no idea which code you're referring to.
Offsets are very simple to calculate. The offset of a given field is the offset of the previous field + size of the previous field, or Offset value if specified prior to the field.
 
Joined
Jul 16, 2010
Messages
391
Motherboard
OP-LP3 Laptop
CPU
i7-8750H
Graphics
UHD630 (1920 x 1080)
Mac
Mac Pro
Mobile Phone
iOS
I was speaking of the offset from the Embedded Controller 0x70 above BCCL, I was unsure how the offset value goes from 0x37 to 0x70?

Does these calculations look correct to you?

Code:
                    Field (ECF2, ByteAcc, Lock, Preserve)
                    {
                        Offset (0x10),
                        BDN0,   56,          //0x10
                        Offset (0x18),
                        BME0,   8,           //0x18
                        Offset (0x20),
                        BMNC,   8,          //0x20
                        BMN0,   120,      //0x21
                        BCT0,   128,      //0x37
                        Offset (0x70),
                        BCCL,   8,
                        IDGS,   16,
                        Offset (0x7E),
Edited:

If it follows the normal hex format counting order 0123456789ABCDEF then I have my offset incorrect for BCT0? Should that be 0x30?
 
Last edited:

RehabMan

Moderator
Joined
May 3, 2012
Messages
191,691
Motherboard
Intel DH67BL
CPU
Core i7-2600K
Graphics
Intel HD 3000
Mac
MacBook Air
Mobile Phone
iOS
I was speaking of the offset from the Embedded Controller 0x70 above BCCL, I was unsure how the offset value goes from 0x37 to 0x70?
Offset is used to change the offset of the next field.
By definition, any field that directly follows Offset(X) is at offset X.
Read the ACPI specification.

Does these calculations look correct to you?

Code:
                    Field (ECF2, ByteAcc, Lock, Preserve)
                    {
                        Offset (0x10),
                        BDN0,   56,          //0x10
                        Offset (0x18),
                        BME0,   8,           //0x18
                        Offset (0x20),
                        BMNC,   8,          //0x20
                        BMN0,   120,      //0x21
                        BCT0,   128,      //0x37
                        Offset (0x70),
                        BCCL,   8,
                        IDGS,   16,
                        Offset (0x7E),
Edited:

If it follows the normal hex format counting order 0123456789ABCDEF then I have my offset incorrect for BCT0? Should that be 0x30?
Wrong. BCT0 is at offset 0x2f (0x20 + (120/8)).
 
Joined
May 22, 2011
Messages
273
Motherboard
Gigabyte Z370 AORUS Gaming 5
CPU
Intel Core i7-8700
Graphics
Gigabyte RX 580 Gaming 8GB
Mac
MacBook Pro
Hi,

Has anyone given a try on a Thinkpad E580 (i7-5550U, Intel UHD 620) ?

I am currently not yet skilled enough to fix it myself, however I was able to fix DSDT to compile it (38 Warnings though). I tried a few existing DSDT patch such as https://github.com/RehabMan/Laptop-DSDT-Patch/blob/master/battery/battery_Lenovo-E430.txt and https://github.com/RehabMan/Laptop-DSDT-Patch/blob/master/battery/battery_Lenovo-T440p.txt however it seems to break the DSDT and brings many errors.

I have attached the untouched Clover dump of my DSDT files in case someone wants to look into it :)
 

Attachments

Joined
Jul 16, 2010
Messages
391
Motherboard
OP-LP3 Laptop
CPU
i7-8750H
Graphics
UHD630 (1920 x 1080)
Mac
Mac Pro
Mobile Phone
iOS
Offset is used to change the offset of the next field.
By definition, any field that directly follows Offset(X) is at offset X.
Read the ACPI specification.



Wrong. BCT0 is at offset 0x2f (0x20 + (120/8)).

I understand now not the Offset calculated at BMN0 which is 0x21 above BCTO but rather the first given offset which is 0x20 plus the value at BMN0 above BCT0 thus, 0x20 + (120/8). I took it as both the value and calculated offset above BCT0.
 
Last edited:
Joined
May 22, 2011
Messages
273
Motherboard
Gigabyte Z370 AORUS Gaming 5
CPU
Intel Core i7-8700
Graphics
Gigabyte RX 580 Gaming 8GB
Mac
MacBook Pro
Hi,

Has anyone given a try on a Thinkpad E580 (i7-5550U, Intel UHD 620) ?

I am currently not yet skilled enough to fix it myself, however I was able to fix DSDT to compile it (38 Warnings though). I tried a few existing DSDT patch such as https://github.com/RehabMan/Laptop-DSDT-Patch/blob/master/battery/battery_Lenovo-E430.txt and https://github.com/RehabMan/Laptop-DSDT-Patch/blob/master/battery/battery_Lenovo-T440p.txt however it seems to break the DSDT and brings many errors.

I have attached the untouched Clover dump of my DSDT files in case someone wants to look into it :)
Nevermind !! I followed the tutorial and it went flawlessly ! I had to add some extra fixes which I commented that were not spoken in this Tutorial but it went alright ! I understand that every configuration is different, which make the tutorial coverage impossible to reach 100% cases perfectly.

@RehabMan Thank you so much !

You may want to add this to your repo

Lenovo Thinkpad E580 (i7 8550U, Intel UHD 620) High Sierra 10.13.4
Screen Shot 2018-05-31 at 3.10.59 AM.png
Code:
# OperationRegion (ECOR, EmbeddedControl, 0x00, 0x0100)

# HWAC,   16,
# HWAK,   16,
# HDEN,   32,
# HDEP,   32,

# SBRC,   16,
# SBFC,   16,
# SBAE,   16,
# SBRS,   16,
# SBAC,   16,
# SBVO,   16,
# SBAF,   16,
# SBBS,   16

# SBBM,   16,
# SBMD,   16,
# SBCC,   16

# SBDC,   16,
# SBDV,   16,
# SBOM,   16,
# SBSI,   16,
# SBDT,   16,
# SBSN,   16

# SBCH,   32

# SBMN,   128

# SBDN,   128




# B1B2 Method
into method label B1B2 remove_entry;
into definitionblock code_regex . insert
begin
Method (B1B2, 2, NotSerialized) { Return(Or(Arg0, ShiftLeft(Arg1, 8))) }\n
end;

# B1B4 Method
into method label B1B4 remove_entry;
into definitionblock code_regex . insert
begin
Method (B1B4, 4, NotSerialized)\n
{\n
    Store(Arg3, Local0)\n
    Or(Arg2, ShiftLeft(Local0, 8), Local0)\n
    Or(Arg1, ShiftLeft(Local0, 8), Local0)\n
    Or(Arg0, ShiftLeft(Local0, 8), Local0)\n
    Return(Local0)\n
}\n
end;

# utility methods to read/write buffers from/to EC
into method label RE1B parent_label H_EC remove_entry;
into method label RECB parent_label H_EC remove_entry;
into device label EC 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(Add(Arg1,7), 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 device label EC code_regex HWAC,\s+16, replace_matched begin WAC0,8,WAC1,8, end;
into device label EC code_regex HWAK,\s+16, replace_matched begin WAK0,8,WAK1,8, end;
into device label EC code_regex HDEN,\s+32 replace_matched begin EN00,8,DEN1,8,DEN2,8,DEN3,8 end;
into device label EC code_regex HDEP,\s+32 replace_matched begin DEP0,8,DEP1,8,DEP2,8,DEP3,8 end;

into device label EC code_regex SBRC,\s+16, replace_matched begin BRC0,8,BRC1,8, end;
into device label EC code_regex SBFC,\s+16, replace_matched begin BFC0,8,BFC1,8, end;
into device label EC code_regex SBAE,\s+16, replace_matched begin BAE0,8,BAE1,8, end;
into device label EC code_regex SBRS,\s+16, replace_matched begin BRS0,8,BRS1,8, end;
into device label EC code_regex SBAC,\s+16, replace_matched begin BAC0,8,BAC1,8, end;
into device label EC code_regex SBVO,\s+16, replace_matched begin BVO0,8,BVO1,8, end;
into device label EC code_regex SBAF,\s+16, replace_matched begin BAF0,8,BAF1,8, end;
into device label EC code_regex SBBS,\s+16 replace_matched begin BBS0,8,BBS1,8 end;

into device label EC code_regex SBBM,\s+16, replace_matched begin BBM0,8,BBM1,8, end;
into device label EC code_regex SBMD,\s+16, replace_matched begin BMD0,8,BMD1,8, end;
into device label EC code_regex SBCC,\s+16 replace_matched begin BCC0,8,BCC1,8 end;

into device label EC code_regex SBDC,\s+16, replace_matched begin BDC0,8,BDC1,8, end;
into device label EC code_regex SBDV,\s+16, replace_matched begin BDV0,8,BDV1,8, end;
into device label EC code_regex SBOM,\s+16, replace_matched begin BOM0,8,BOM1,8, end;
into device label EC code_regex SBSI,\s+16, replace_matched begin BSI0,8,BSI1,8, end;
into device label EC code_regex SBDT,\s+16, replace_matched begin BDT0,8,BDT1,8, end;
into device label EC code_regex SBSN,\s+16 replace_matched begin BSN0,8,BSN1,8 end;

into device label EC code_regex SBCH,\s+32 replace_matched begin BCH0,8,BCH1,8,BCH2,8,BCH3,8 end;

into device label EC code_regex (SBMN,)\s+(128) replace_matched begin SBMX,%2,//%1%2 end;

into device label EC code_regex (SBDN,)\s+(128) replace_matched begin SBDX,%2,//%1%2 end;


# fix 16-bit methods
# into method label GBTI code_regex \(HWAC, replaceall_matched begin (B1B2(WAC0,WAC1), end; # Unused in DSDT
into method label GBST code_regex \(SBRC, replaceall_matched begin (B1B2(BRC0,BRC1), end;
into method label GBIF code_regex \(SBFC, replaceall_matched begin (B1B2(BFC0,BFC1), end;
into method label GBIX code_regex \(SBFC, replaceall_matched begin (B1B2(BFC0,BFC1), end;
# into method label GBTI code_regex \(SBAE, replaceall_matched begin (B1B2(BAE0,BAE1), end; # Unused in DSDT
# into method label GBTI code_regex \(SBRS, replaceall_matched begin (B1B2(BRS0,BRS1), end; # Unused in DSDT
into method label GBST code_regex \(SBAC, replaceall_matched begin (B1B2(BAC0,BAC1), end;
into method label GBST code_regex \(SBVO, replaceall_matched begin (B1B2(BVO0,BVO1), end;
# into method label GBTI code_regex \(SBAF, replaceall_matched begin (B1B2(BAF0,BAF1), end; # Unused in DSDT
# into method label GBTI code_regex \(SBBS, replaceall_matched begin (B1B2(BBS0,BBS1), end; # Unused in DSDT
into method label GBIF code_regex \(SBBM, replaceall_matched begin (B1B2(BBM0,BBM1), end;
into method label GBIX code_regex \(SBBM, replaceall_matched begin (B1B2(BBM0,BBM1), end;
# into method label GBTI code_regex \(SBMD, replaceall_matched begin (B1B2(BMD0,BMD1), end; # Unused in DSDT
into method label GBIX code_regex \(SBCC, replaceall_matched begin (B1B2(BCC0,BCC1), end;
into method label GBIF code_regex \(SBDC, replaceall_matched begin (B1B2(BDC0,BDC1), end;
into method label GBIX code_regex \(SBDC, replaceall_matched begin (B1B2(BDC0,BDC1), end;
into method label GBIF code_regex \(SBDV, replaceall_matched begin (B1B2(BDV0,BDV1), end;
into method label GBIX code_regex \(SBDV, replaceall_matched begin (B1B2(BDV0,BDV1), end;
into method label GBIF code_regex \SBDV, replaceall_matched begin B1B2(BDV0,BDV1), end; # Extra fix for compilation
into method label GBIX code_regex \SBDV, replaceall_matched begin B1B2(BDV0,BDV1), end; # Extra fix for compilation
into method label GBIF code_regex \(SBDV\) replaceall_matched begin (B1B2(BDV0,BDV1)) end; # Extra fix for compilation
into method label GBIX code_regex \(SBDV\) replaceall_matched begin (B1B2(BDV0,BDV1)) end; # Extra fix for compilation
# into method label GBTI code_regex \(SBOM, replaceall_matched begin (B1B2(BOM0,BOM1), end; # Unused in DSDT
# into method label GBTI code_regex \(SBSI, replaceall_matched begin (B1B2(BSI0,BSI1), end; # Unused in DSDT
# into method label GBTI code_regex \(SBDT, replaceall_matched begin (B1B2(BDT0,BDT1), end; # Unused in DSDT
into method label GBIF code_regex \(SBSN, replaceall_matched begin (B1B2(BSN0,BSN1), end;
into method label GBIX code_regex \(SBSN, replaceall_matched begin (B1B2(BSN0,BSN1), end;


# fix 32-bit methods
# into method label GBTI code_regex \(HDEN, replaceall_matched begin (B1B4(DEN0,DEN1,DEN2,DEN3), end;
# into method label GBTI code_regex \(HDEP, replaceall_matched begin (B1B4(DEP0,DEP1,DEP2,DEP3), end;
into method label GBIF code_regex \(SBCH, replaceall_matched begin (B1B4(BCH0,BCH1,BCH2,BCH3), end;
into method label GBIX code_regex \(SBCH, replaceall_matched begin (B1B4(BCH0,BCH1,BCH2,BCH3), end;

# fix 128-bit methods
into method label GBIF code_regex \(SBMN, replaceall_matched begin (RECB(0xA0,128), end;
into method label GBIX code_regex \(SBMN, replaceall_matched begin (RECB(0xA0,128), end;
into method label GBIF code_regex \(SBDN, replaceall_matched begin (RECB(0xA0,128), end;
into method label GBIX code_regex \(SBDN, replaceall_matched begin (RECB(0xA0,128), end;

# Fix compilation for renamed HWAK (HWAK reading)
into method label OWAK code_regex \(\\\_SB.PCI0.LPCB.EC.HWAK replaceall_matched begin (B1B2(\\_SB.PCI0.LPCB.EC.WAK0,\\_SB.PCI0.LPCB.EC.WAK1) end;
into method label _L43 code_regex \(\\\_SB.PCI0.LPCB.EC.HWAK replaceall_matched begin (B1B2(\\_SB.PCI0.LPCB.EC.WAK0,\\_SB.PCI0.LPCB.EC.WAK1) end;
I joined my original untouched ACPI files extracted from Clover in case you want to double check my code yourself. It definitely works !

Edit : WOHOO! PrefPane -> Trackpad now accessible :D
 

Attachments

Last edited:
Top