Jump to content
onemanosx

[Guide] Laptop Battery Indicator - The DSDT Patching Horror

Recommended Posts

Disclaimer: This is not meant to be a thorough help guide. In fact, this write up is a simpler way to guide through new hackintoshers without going into details. Read in-depth guide from the established writer Rehabman in his original article here https://github.com/RehabMan/OS-X-ACPI-Battery-Driver.

++++++++++++++++++++++++++++++

Note:

1. If you are using virtualsmc instead of fakesmc, then you will need SMCBatteryManager.kext instead of ACPIBatteryManager.kext.

2. You should also remove voodoobattery kext from your system.

3. If you'd like assistance on how to start, you should at least find all the used byte called in your EmbeddedControl. Read the guide below on how to achieve that.

++++++++++++++++++++++++++++++

New hackintoshers may not realise that Rehabman's repo may already have patches ready for their laptops. This can be easily accessed by going through RH Github Repo here https://github.com/RehabMan/Laptop-DSDT-Patch/tree/master/battery.

 

Various laptop battery patches available in RH Repo using MacIASL

 

1. Download acpibatterymanager kext from RH bitbucket site https://bitbucket.org/RehabMan/os-x-acpi-battery-driver/downloads. Place the kext at Clover/kexts/other folder. Reboot.

2. Download a copy of MacIASL app. The app can be found in "Files" folder of Olarila's image USB stick or simply download a release from HERE

3. Open MacIASL app, click the Patch icon on the top section of the app and scroll to [bat] -->Battery Patches.

Click any model on the left pane and you will also see other laptop models, on the right pane where the patch is also compatible with.

 

Go through each section to see if your laptop model is available.

QO77BCc.png 

If you had gone through all the sections and did not find a match, you are then expected to create your own DSDT patches.

 

How to Start?

 

In this example, we will use a table attached here Sample - DSDT.aml.zip

 

1. Find EC region

 

OperationRegion (ERAM, EmbeddedControl, Zero, 0xFF)
 

1OyHMUE.png 

 

2. In the ERAM field, search for all bytes more than 8. Thus we will find the list below

 

SMD0,   32
MBCT,   16, 
RCAP,   16,
MBC2,   16,  
MBVT,   16, 
RCA2,   16, 
MBV2,   16,
DBAT,   16, 
FRMS,   16, 
FRS2,   16, 
MDCP,   16, 
MBCP,   16,
MBDV,   16, 
RSOC,   8, 
BTMP,   16,
BASN,   16, 
MBDN,   120,
NMON,   16, 
CYCL,   16,
 

3. From the list above, we determine if each integers are being called in the DSDT. Lets look for SMD0 and we will find its not called up in the EC0 region. We will omit this integer from our list.

r7lhmmW.png 

 

4. Next we continue to look for the next integer, MBCT and found its called up down the EC0 region.

BMjgi2D.png 

 

5. For MBC2, we find it is not called up anywhere else. So we can omit this integer.

9lGwAVj.png 

 

Going through all the list, we then find only these integers are being called and in use.

 

MBCT,   16, 
RCAP,   16, 
MBVT,   16, 
DBAT,   16, 
FRMS,   16, 
FRS2,   16, 
MDCP,   16, 
MBCP,   16,
MBDV,   16
 

Fixing 16-bit registers

 

Just use the below code format as an example. For MBCT we are "splitting" 16 bits to two 8 bits. The 8 bit renaming is easier to just use the last three alphabets (or first three. Your choice, really). Just make sure the renames do not start with a decimal but an alphabet instead.

 

So, MBCT will become BCT0 & BCT1. And the resulting format will be as such

 

into device label EC0 code_regex MBCT,\s+16, replace_matched begin BCT0,8,BCT1,8, end;
 

As for RCAP will become CAP0 & CAP1 and the resulting code format will be

 

into device label EC0 code_regex RCAP,\s+16, replace_matched begin CAP0,8,CAP1,8, end;
 

Do the same for all of our 16 bits findings

 

We will finally achieve the below codes for the rest of our findings.

 

into device label EC0 code_regex MBCT,\s+16, replace_matched begin BCT0,8,BCT1,8, end;
into device label EC0 code_regex RCAP,\s+16, replace_matched begin CAP0,8,CAP1,8, end;
into device label EC0 code_regex MBVT,\s+16, replace_matched begin BVT0,8,BVT1,8, end;
into device label EC0 code_regex DBAT,\s+16, replace_matched begin DBA0,8,DBA1,8, end;
into device label EC0 code_regex FRMS,\s+16, replace_matched begin RMS0,8,RMS1,8, end;
into device label EC0 code_regex FRS2,\s+16, replace_matched begin RS20,8,RS21,8, end;
into device label EC0 code_regex MDCP,\s+16, replace_matched begin DCP0,8,DCP1,8, end;
into device label EC0 code_regex MBCP,\s+16, replace_matched begin BCP0,8,BCP1,8, end;
into device label EC0 code_regex MBDV,\s+16, replace_matched begin BDV0,8,BDV1,8, end;
 

Patching DSDT with 16 bit registers

 

Open MacIASL, click the Patch tab and paste the codes in the box

s9S7Cqo.png 

When we hit apply, we will find errors when trying to compile the DSDT. This is expected.

Zn3SY5N.png 

What we need to do next is fix these errors individually.

 

Fixing 16 bit Method

 

Lets look at the first error

Fv1dJDG.png 

Since we had "split" 16 bit FRMS into two 8 bits RMS0 and RMS1,

 

into device label EC0 code_regex FRMS,\s+16, replace_matched begin RMS0,8,RMS1,8, end;
 

we will now need to introduce a standard B1B2 method into our DSDT

 

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

1FT3TwG.png 

Next we will manually patch the FRMS error with the code format below

 

B1B2(\_SB.PCI0.LPCB.EC0.RMS0,\_SB.PCI0.LPCB.EC0.RMS1)
 

Before

PgxcqIS.png 

 

After

AQnBNGd.png 

 

Next error also occurs for FRMS

JABnhva.png 

 

This time round we fix the error using the code format below

 

B1B2(^^PCI0.LPCB.EC0.RMS0,^^PCI0.LPCB.EC0.RMS1)
 

After patching

b7b2nJ4.png 

 

Again, for the rest of the 16 bit integers, we will find the codes below to manually fix our errors. (Manually, because I cannot find a solution to automate the tedious process :? )

 

FRMS -> B1B2(\_SB.PCI0.LPCB.EC0.RMS0,\_SB.PCI0.LPCB.EC0.RMS1) 
FRMS -> B1B2(^^PCI0.LPCB.EC0.RMS0,^^PCI0.LPCB.EC0.RMS1)
FRS2 -> B1B2(^^PCI0.LPCB.EC0.RS20,^^PCI0.LPCB.EC0.RS21)
DBAT -> B1B2(\_SB.PCI0.LPCB.EC0.DBA0,\_SB.PCI0.LPCB.EC0.DBA1) 
DBAT -> B1B2(^^PCI0.LPCB.EC0.DBA0,^^PCI0.LPCB.EC0.DBA1)
MDCP -> B1B2(^^PCI0.LPCB.EC0.DCP0,^^PCI0.LPCB.EC0.DCP1)
MBCP -> B1B2(^^PCI0.LPCB.EC0.BCP0,^^PCI0.LPCB.EC0.BCP1)
MBDV -> B1B2(^^PCI0.LPCB.EC0.BDV0,^^PCI0.LPCB.EC0.BDV1)
MBCP -> B1B2(^^PCI0.LPCB.EC0.BCP0,^^PCI0.LPCB.EC0.BCP1)
MBCT -> B1B2(^^PCI0.LPCB.EC0.BCT0,^^PCI0.LPCB.EC0.BCT1)
MBVT -> B1B2(^^PCI0.LPCB.EC0.BVT0,^^PCI0.LPCB.EC0.BVT1)
RCAP -> B1B2(^^PCI0.LPCB.EC0.CAP0,^^PCI0.LPCB.EC0.CAP1)
 

The Final Step

 

Add the below standard codes to our DSDT, press Apply and make sure no error in our compile.

(Note: You may need to change EC0 to H_EC or EC depending on your own DSDT)

 

#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 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
{\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
{
	Store(RE1B(Arg0), Index(TEMP, Local0))\n
	Increment(Arg0)\n
	Increment(Local0)\n
}\n
Return(TEMP)\n
}\n
end;

into device label EC0 insert
begin
Method (WE1B, 2, NotSerialized)\n
{\n
   OperationRegion(ERAM, EmbeddedControl, Arg0, 1)\n
   Field(ERAM, ByteAcc, NoLock, Preserve) { BYTE, 8 }\n
   Store(Arg1, BYTE)\n
}\n
Method (WECB, 3, Serialized)\n
{\n
   ShiftRight(Arg1, 3, Arg1)\n
   Name(TEMP, Buffer(Arg1) { })\n
   Store(Arg2, TEMP)\n
   Add(Arg0, Arg1, Arg1)\n
   Store(0, Local0)\n
   While (LLess(Arg0, Arg1))\n
   {\n
       WE1B(Arg0, DerefOf(Index(TEMP, Local0)))\n
       Increment(Arg0)\n
       Increment(Local0)\n
   }\n
}\n
end;
 

The DSDT is now ready to be placed in Clover/ACPI/Patched folder. Reboot and see if your hard work paid off.

 

If you face any issues and would like help from others in this community, attach your post with Laptop model and dump files using this app https://www.olarila.com/files/Utils/RunMe.app.zip

 

If you find this guide useful and would like to contribute your successful patch, just make a post with Laptop model details, patch codes and attach an original DSDT.

 

To be continued ...

  • Like 1
  • Thanks 1

Donate

Gitter Chat


Acer Aspire V15 Nitro- Black Edition VN7-592G/HM170 Chipset

Intel i7-6700HQ, 8GB RAM (UEFI Clover Catalina)


MSI B360 Gaming Arctic

Intel i5-8600 16GB RAM Asus Radeon RX580 8GB (UEFI Clover Catalina)

Link to comment
Share on other sites

Update 3 Jan 2019

 

Dealing with 32 Bits

 

Dealing with 32 bits is fairly similar to that of 16 bit. Lets say we have

 

BTY0,   32,
BTY1,   32,
 

The standard looking code with look like this

 

into device label H_EC code_regex BTY0,\s+32 replace_matched begin TY00,8,TY01,8,TY02,8,TY03,8 end;
into device label H_EC code_regex BTY1,\s+32 replace_matched begin TY10,8,TY11,8,TY12,8,TY13,8 end;
 

And we will have the fix 32 bit method code which looks similar to this

 

BTY0 - (B1B4(\_SB.PCI0.LPCB.H_EC.TY00,\_SB.PCI0.LPCB.H_EC.TY01,\_SB.PCI0.LPCB.H_EC.TY02,\_SB.PCI0.LPCB.H_EC.TY03), end;
BTY1 - (B1B4(\_SB.PCI0.LPCB.H_EC.TY10,\_SB.PCI0.LPCB.H_EC.TY11,\_SB.PCI0.LPCB.H_EC.TY12,\_SB.PCI0.LPCB.H_EC.TY13), end;
 

And the Standard Code for fixing 32 bit register

 

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;
 

++++++++++++++++++++++++++++++++++++

 

Fixing Larger than 32 bits

 

I was going through my note for an update to fix integers larger than 32 bit, when I realized RH perhaps has the best explanation laid out.

 

In short, for integers larger than 32 bit, we will need to find each offset values which is the tricky part (HINT: Observe the pattern)

 

We have these 2 values larger than 32 bits

 


Field (ERAM, ByteAcc, Lock, Preserve)
                   {
                       Offset (0x02), <<--Hex
                       PSTD,   8, 
                       Offset (0x18), <<-- HEX
                       SMPR,   8, 
                       SMST,   8, 
                       SMAD,   8, 
                       SMCM,   8, 
                       SMD0,   264, 
                       Offset (0xA0), <<-- HEX
	        BBAR,   136,
 

This is how the offset values are attained

 

Field (ERAM, ByteAcc, Lock, Preserve)
                   {
                       Offset (0x02),  
                       PSTD,   8, 
                       Offset (0x18), <<-->> HEX to DEC -->> //24
                       SMPR,   8, // 24 <<-->> DEC to HEX -->>(0X18)
                       SMST,   8, //24+(8/8) = 25 <<-->> DEC to HEX -->>(0X19)
                       SMAD,   8, // 24+(8/8)+(8/8) = 26 <<-->> DEC to HEX -->>(0X1A)
                       SMCM,   8, //24+(8/8)+(8/8)+(8/8)= 27 <<-->> DEC to HEX -->>(0X1B)
                       SMD0,   264, //24+(8/8)+(8/8)+(8/8)+(8/8) = 28 <<-->> DEC to HEX -->>(0X1C) <<-- 
		Offset (0xA0), //
		BBAR,   136,// (0XA0)

 

From the above, our offset values for SMD0 and BBAR is achieved by a simple calculation. HINT: Unless specified by an Offset directive, the offset of any register is the offset of the previous register + previous register size

 

Next, we will rename SMD0 and BBAR to SMDX and BBAX respectively

 

into device label EC0 code_regex (SMD0,)\s+(264) replace_matched begin SMDX,%2,//%1%2 end;
into device label EC0 code_regex (BBAR,)\s+(136) replace_matched begin BBAX,%2,//%1%2 end;
 

And the fix method code will look similarly as

 

SMD0 -  \_SB.PCI0.LPCB.EC0.RECB(0X1C,264)
BBAR -  \_SB.PCI0.LPCB.EC0.RECB(0XA0,136)

 

That is all on fixing larger than 32 bit integers.

 

Are you sure the offset values are derived that way?

 

If you are not yet convinced on how I attained the offset values, you may compare the below calculation and its result with RH's example. I hope its useful for some of our readers.

 

Field (ECF2, ByteAcc, Lock, Preserve)
  {
      Offset (0x10), 
      BDN0,   56,     // (0x10)
      Offset (0x18),
      BME0,   8, // (0x18) 
      Offset (0x20),// <<—- Hex to decimal is 32
      BMN0,   32,     // 32 (0x20) 
      BMN2,   8,     // 32+(32/8)=36 //result in Dec and convert to Hex —>> (0x24)
      BMN4,   88,    //32+(32/8)+(8/8) = 37 //result in Dec and convert to Hex —>>(0x25)
      BCT0,   128,     //!! 32+(32/8)+(8/8)+(88/8) = 48 //result in Dec and convert to Hex —>>(0x30)
      BDN1,   56,     //!! 32+(32/8)+(8/8)+(88/8)+(128/8) = 64 //result in Dec and convert to Hex —>>(0x40)
      Offset (0x48),
      BME1,   8, //(0x48)
      Offset (0x50),
      BMN1,   32,     // (0x50)>> <<—- Hex to decimal is 80 
      BMN3,   8,     // 80+(32/8) = 84 //result in Dec and convert to Hex —>>(0x54)
      BMN5,   88,     // 80+(32/8)+(8/8) = 85 //result in Dec and convert to Hex —>>(0x55)
      BCT1,   128,     //!! 80+(32/8)+(8/8)+(88/8) = 96 //result in Dec and convert to Hex —>>(0x60)

 
  • Like 1

Donate

Gitter Chat


Acer Aspire V15 Nitro- Black Edition VN7-592G/HM170 Chipset

Intel i7-6700HQ, 8GB RAM (UEFI Clover Catalina)


MSI B360 Gaming Arctic

Intel i5-8600 16GB RAM Asus Radeon RX580 8GB (UEFI Clover Catalina)

Link to comment
Share on other sites

:guitar:guitar:guitar:guitar

AMD Ryzen 7 3700X, MSI MPG X570 Gaming Plus, Corsair Vengeance RGB PRO 16GB DDR4 3200MHz, Sapphire rx 5700 XT, fractal celcius s36

:superman:superman

HP Notebook - 15-ay028ca (Touch), 16 GB 2133 MHz DDR4, Intel HD Graphics 520 1536 MB

Asus z97-c i5, i5 4460, 32 GB 1648 MHz DDR3, Radeon RX 560 4096 MB, Corsair H75 Liquid CPU Cooler

Link to comment
Share on other sites

And it seemed stranged that mine is working without any battery patch.

There is no harm double checking against your DSDT and the guide though.

Donate

Gitter Chat


Acer Aspire V15 Nitro- Black Edition VN7-592G/HM170 Chipset

Intel i7-6700HQ, 8GB RAM (UEFI Clover Catalina)


MSI B360 Gaming Arctic

Intel i5-8600 16GB RAM Asus Radeon RX580 8GB (UEFI Clover Catalina)

Link to comment
Share on other sites

  • Administrators
:guitar:cap

-Donations-

PayPal HERE - Stripe HERE - Ko-Fi HERE - BuyMeaCoffee HERE - Mercado Livre HERE

Skrill danielnmaldonado@gmail.com - BTC 33HeGCuCSh4tUBqdYkQqKpSDa1E7WeAJQ3 - BNB 0x10D1d656eCa00bD521f9b4A43B83098B8142e115 - USDT BSC BEP20 0xb57cfdfa371fad1981910f0e8332409ab99f74d9 - USDT TRC20 TUR6Z9AVS4AYzqPnULoHrfFvppRbhXmNbZ - KASPA kaspa:qpxzufgfj8p6r0krg58yzvs0009h2mwqgvcawa0xc2pth7sgzpv56j4f6dtvk - PicPay @danielnmaldonado - PiX @danielnmaldonado@gmail.com

Premium Users HERE - Problems with Paypal HERE

xcd5u2Y.png

Sign up for a Bybit account and claim exclusive rewards HERE

New ways to earn money with Linkvertise HERE

Link to comment
Share on other sites

I don't use dsdt , I use hotpatch with no battery patch at all.

When you dont specify DSDT file in Clover/ACPI/Patched, Clover automatically uses your native DSDT for use.

Donate

Gitter Chat


Acer Aspire V15 Nitro- Black Edition VN7-592G/HM170 Chipset

Intel i7-6700HQ, 8GB RAM (UEFI Clover Catalina)


MSI B360 Gaming Arctic

Intel i5-8600 16GB RAM Asus Radeon RX580 8GB (UEFI Clover Catalina)

Link to comment
Share on other sites

Your guides are great.

Wish you make a guide for acpi hot patching , too. I would like a bit of a help with mine.

Thank you. That's very heartwarming to hear :D


Its too wide of a topic to talk about clover's hot patching in one single post and [ref]MaLd0n[/ref] is the best man for it. :mrgreen:

Donate

Gitter Chat


Acer Aspire V15 Nitro- Black Edition VN7-592G/HM170 Chipset

Intel i7-6700HQ, 8GB RAM (UEFI Clover Catalina)


MSI B360 Gaming Arctic

Intel i5-8600 16GB RAM Asus Radeon RX580 8GB (UEFI Clover Catalina)

Link to comment
Share on other sites

[ref]mathewgx[/ref], The reason you dont require any patching for battery status is probably due to all the 8 bits count only in your embedded field values. ;)

Donate

Gitter Chat


Acer Aspire V15 Nitro- Black Edition VN7-592G/HM170 Chipset

Intel i7-6700HQ, 8GB RAM (UEFI Clover Catalina)


MSI B360 Gaming Arctic

Intel i5-8600 16GB RAM Asus Radeon RX580 8GB (UEFI Clover Catalina)

Link to comment
Share on other sites

I don't have any clue about what you said , but you know better.

I am still learning, the reason I know is because I opened up your DSDT from the previous post where you uploaded your send_me file ;)

Donate

Gitter Chat


Acer Aspire V15 Nitro- Black Edition VN7-592G/HM170 Chipset

Intel i7-6700HQ, 8GB RAM (UEFI Clover Catalina)


MSI B360 Gaming Arctic

Intel i5-8600 16GB RAM Asus Radeon RX580 8GB (UEFI Clover Catalina)

Link to comment
Share on other sites

[ref]sarakabir[/ref],


Check for battery fix. sarakabir BATFIX - DSDT.aml.zip

 

Download kext here https://github.com/RehabMan/OS-X-ACPI-Battery-Driver/releases

Donate

Gitter Chat


Acer Aspire V15 Nitro- Black Edition VN7-592G/HM170 Chipset

Intel i7-6700HQ, 8GB RAM (UEFI Clover Catalina)


MSI B360 Gaming Arctic

Intel i5-8600 16GB RAM Asus Radeon RX580 8GB (UEFI Clover Catalina)

Link to comment
Share on other sites

[ref]ziomalex[/ref], Please upload new send me files for checking. Thanks.


Sleep wake function may or may not work in hackintosh. Its a known issue, I think.

Donate

Gitter Chat


Acer Aspire V15 Nitro- Black Edition VN7-592G/HM170 Chipset

Intel i7-6700HQ, 8GB RAM (UEFI Clover Catalina)


MSI B360 Gaming Arctic

Intel i5-8600 16GB RAM Asus Radeon RX580 8GB (UEFI Clover Catalina)

Link to comment
Share on other sites

ok good to know. I have been trying to make it work but there was no luck, I have been trying even to update to Mojave but not working after boot I have backlighted black screen whatever platform id I choose so I stick whith high Sierra and at least is 98% functional.

Thank you again for helping with battery

Link to comment
Share on other sites

[ref]ziomalex[/ref], No problem.


Update Status for : Dell Inspiron 5577 Battery Status



30vKwTo.png

795198174_ScreenShot2019-01-13at12_49_18PM.thumb.png.3194d437a57528fc828cad351a808bc7.png

Edited by Guest

Donate

Gitter Chat


Acer Aspire V15 Nitro- Black Edition VN7-592G/HM170 Chipset

Intel i7-6700HQ, 8GB RAM (UEFI Clover Catalina)


MSI B360 Gaming Arctic

Intel i5-8600 16GB RAM Asus Radeon RX580 8GB (UEFI Clover Catalina)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.





×
  • Create New...