Contribute
Register

[Guide] How to patch DSDT for working battery status

Hello RehabMan. I checked my battery patch. It seems everything works. Do not show just how much time is left to work.
Thank you for your help. In the archive, my patch can be added if you want to add it to your patch archive.
 

Attachments

  • RehabMan.zip
    21.2 MB · Views: 332
Hello RehabMan. I checked my battery patch. It seems everything works. Do not show just how much time is left to work.
Thank you for your help. In the archive, my patch can be added if you want to add it to your patch archive.

Read post #1, "Contributing".
 
Thanks (looks good)... added to the github repo.

Hi RehabMan. Today I saw that in SSDT-4 there are the same variables as I renamed into DSDT with the patch of the battery. It is necessary or not to fix ssdt-4 as in dsdt. For example, B1FC is in DSDT and in SSDT-4.
 

Attachments

  • Patch battery status.txt
    9.6 KB · Views: 159
  • DSDT1.dsl
    1.2 MB · Views: 119
  • SSDT-4.dsl
    198.1 KB · Views: 167
Hi RehabMan. Today I saw that in SSDT-4 there are the same variables as I renamed into DSDT with the patch of the battery. It is necessary or not to fix ssdt-4 as in dsdt. For example, B1FC is in DSDT and in SSDT-4.

Check if any of the code is reachable. If not reachable, then you don't need to do anything with it.
 
Hey! It's me again!
I'm working on battery patch for another machine - ASUS T300CHI Notebook. Unfortunately I get a little bit confused about fields which I should patch. The EC0 Has the following Fields:

Code:
OperationRegion (ECOR, EmbeddedControl, Zero, 0xFF)
            Field (ECOR, ByteAcc, Lock, Preserve)
            {
                Offset (0x04),
                CMD1,   8,
                CDT1,   8,
                CDT2,   8,
                CDT3,   8,
                Offset (0x80),
                Offset (0x81),
                Offset (0x82),
                Offset (0x83),
                EB0R,   8,
                EB1R,   8,
                EPWF,   8,
                Offset (0x87),
                Offset (0x88),
                Offset (0x89),
                Offset (0x8A),
                HKEN,   1,
                Offset (0x93),
                TAH0,   16,
                TAH1,   16,
                TSTP,   8,
                Offset (0x9C),
                CDT4,   8,
                CDT5,   8,
                Offset (0xA0),
                Offset (0xA1),
                Offset (0xA2),
                Offset (0xA3),
                EACT,   8,
                TH1R,   8,
                TH1L,   8,
                TH0R,   8,
                TH0L,   8,
                Offset (0xB0),
                B0PN,   16,
                Offset (0xB4),
                Offset (0xB6),
                Offset (0xB8),
                Offset (0xBA),
                Offset (0xBC),
                Offset (0xBE),
                B0TM,   16,
                B0C1,   16,
                B0C2,   16,
                B0C3,   16,
                B0C4,   16,
                Offset (0xD0),
                B1PN,   16,
                Offset (0xD4),
                Offset (0xD6),
                Offset (0xD8),
                Offset (0xDA),
                Offset (0xDC),
                Offset (0xDE),
                B1TM,   16,
                B1C1,   16,
                B1C2,   16,
                B1C3,   16,
                B1C4,   16,
                Offset (0xF0),
                Offset (0xF2),
                Offset (0xF4),
                B0SN,   16,
                Offset (0xF8),
                Offset (0xFA),
                Offset (0xFC),
                B1SN,   16
            }

            Name (SMBF, Zero)
            OperationRegion (SMBX, EmbeddedControl, 0x18, 0x28)
            Field (SMBX, ByteAcc, NoLock, Preserve)
            {
                PRTC,   8,
                SSTS,   5,
                    ,   1,
                ALFG,   1,
                CDFG,   1,
                ADDR,   8,
                CMDB,   8,
                BDAT,   256, //Offset 0x1C I guess
                BCNT,   8,
                    ,   1,
                ALAD,   7,
                ALD0,   8,
                ALD1,   8
            }

            OperationRegion (SMB2, EmbeddedControl, 0x40, 0x28)
            Field (SMB2, ByteAcc, NoLock, Preserve)
            {
                PRT2,   8,
                SST2,   5,
                    ,   1,
                ALF2,   1,
                CDF2,   1,
                ADD2,   8,
                CMD2,   8,
                BDA2,   256, // Offset 0x44 I guess
                BCN2,   8,
                    ,   1,
                ALA2,   7,
                ALR0,   8,
                ALR1,   8
            }

            Field (SMB2, ByteAcc, NoLock, Preserve)
            {
                Offset (0x04),
                DA20,   8,
                DA21,   8
            }

            Field (SMBX, ByteAcc, NoLock, Preserve)
            {
                Offset (0x04),
                DAT0,   8,
                DAT1,   8
            }

            Field (SMBX, ByteAcc, NoLock, Preserve)
            {
                Offset (0x04),
                DT2B,   16
            }

            OperationRegion (NSBS, EmbeddedControl, 0x40, 0x04)
            Field (NSBS, ByteAcc, NoLock, Preserve)
            {
                A2AD,   8,
                A2D0,   8,
                A2D1,   8,
                A3AD,   8
            }

            OperationRegion (BRAM, SystemIO, 0x025A, 0x02)
            Field (BRAM, ByteAcc, Lock, Preserve)
            {
                BRAI,   8,
                BRAD,   8
            }

            IndexField (BRAI, BRAD, ByteAcc, NoLock, Preserve)
            {
                Offset (0x8F),
                PBSY,   8,
                EPWS,   8,
                EB0S,   8,
                EB1S,   8,
                EB0T,   8,
                EB1T,   8,
                Offset (0x98),
                ECPU,   8,
                ECRT,   8,
                EPSV,   8,
                Offset (0xA0),
                B0VL,   16,
                B0RC,   16,
                B0FC,   16,
                B0MD,   16,
                B0ST,   16,
                B0CC,   16,
                B0DC,   16,
                B0DV,   16,
                B1VL,   16,
                B1RC,   16,
                B1FC,   16,
                B1MD,   16,
                B1ST,   16,
                B1CC,   16,
                B1DC,   16,
                B1DV,   16
            }

First of all I'm not sure wether I should replace all the fields that are accessed by the methods, or just change those where RegionSpace is EmbeddedControl.
Second thing is that According to ACPI Documentation I'm not sure if I calculated the Offset of the 256-bit values correctly. I was following that OperationRegion defines Starting offset in declaration, so for SMBX the starting offset should be 0x18 and for SMB2 the starting offset should be 0x40

Another thing that bothers me is the OperationRegion BRAM. It defines IndexField(BRAI, BRAD,...) that also has fields which are accessed by Battery methods. I dunno if I should poke them or not.
If anyone would be so kind and explain everything I would be happy. I attach clean disassembled DSDT.dsl.

Cheers.

EDIT: This configuration is really confusing. I noticed that _BIX method was broken so I used Clover's Rename and replace Method to change _BIX to XBIX to let _BIF handle the battery status. The battery status has shown and OS detects when I plug the AC adapter without even changing anything with the fields. Weird.
 

Attachments

  • DSDT.dsl
    699.1 KB · Views: 107
Last edited:
Hey! It's me again!
I'm working on battery patch for another machine - ASUS T300CHI Notebook. Unfortunately I get a little bit confused about fields which I should patch. The EC0 Has the following Fields:

Code:
OperationRegion (ECOR, EmbeddedControl, Zero, 0xFF)
            Field (ECOR, ByteAcc, Lock, Preserve)
            {
                Offset (0x04),
                CMD1,   8,
                CDT1,   8,
                CDT2,   8,
                CDT3,   8,
                Offset (0x80),
                Offset (0x81),
                Offset (0x82),
                Offset (0x83),
                EB0R,   8,
                EB1R,   8,
                EPWF,   8,
                Offset (0x87),
                Offset (0x88),
                Offset (0x89),
                Offset (0x8A),
                HKEN,   1,
                Offset (0x93),
                TAH0,   16,
                TAH1,   16,
                TSTP,   8,
                Offset (0x9C),
                CDT4,   8,
                CDT5,   8,
                Offset (0xA0),
                Offset (0xA1),
                Offset (0xA2),
                Offset (0xA3),
                EACT,   8,
                TH1R,   8,
                TH1L,   8,
                TH0R,   8,
                TH0L,   8,
                Offset (0xB0),
                B0PN,   16,
                Offset (0xB4),
                Offset (0xB6),
                Offset (0xB8),
                Offset (0xBA),
                Offset (0xBC),
                Offset (0xBE),
                B0TM,   16,
                B0C1,   16,
                B0C2,   16,
                B0C3,   16,
                B0C4,   16,
                Offset (0xD0),
                B1PN,   16,
                Offset (0xD4),
                Offset (0xD6),
                Offset (0xD8),
                Offset (0xDA),
                Offset (0xDC),
                Offset (0xDE),
                B1TM,   16,
                B1C1,   16,
                B1C2,   16,
                B1C3,   16,
                B1C4,   16,
                Offset (0xF0),
                Offset (0xF2),
                Offset (0xF4),
                B0SN,   16,
                Offset (0xF8),
                Offset (0xFA),
                Offset (0xFC),
                B1SN,   16
            }

            Name (SMBF, Zero)
            OperationRegion (SMBX, EmbeddedControl, 0x18, 0x28)
            Field (SMBX, ByteAcc, NoLock, Preserve)
            {
                PRTC,   8,
                SSTS,   5,
                    ,   1,
                ALFG,   1,
                CDFG,   1,
                ADDR,   8,
                CMDB,   8,
                BDAT,   256, //Offset 0x1C I guess
                BCNT,   8,
                    ,   1,
                ALAD,   7,
                ALD0,   8,
                ALD1,   8
            }

            OperationRegion (SMB2, EmbeddedControl, 0x40, 0x28)
            Field (SMB2, ByteAcc, NoLock, Preserve)
            {
                PRT2,   8,
                SST2,   5,
                    ,   1,
                ALF2,   1,
                CDF2,   1,
                ADD2,   8,
                CMD2,   8,
                BDA2,   256, // Offset 0x44 I guess
                BCN2,   8,
                    ,   1,
                ALA2,   7,
                ALR0,   8,
                ALR1,   8
            }

            Field (SMB2, ByteAcc, NoLock, Preserve)
            {
                Offset (0x04),
                DA20,   8,
                DA21,   8
            }

            Field (SMBX, ByteAcc, NoLock, Preserve)
            {
                Offset (0x04),
                DAT0,   8,
                DAT1,   8
            }

            Field (SMBX, ByteAcc, NoLock, Preserve)
            {
                Offset (0x04),
                DT2B,   16
            }

            OperationRegion (NSBS, EmbeddedControl, 0x40, 0x04)
            Field (NSBS, ByteAcc, NoLock, Preserve)
            {
                A2AD,   8,
                A2D0,   8,
                A2D1,   8,
                A3AD,   8
            }

            OperationRegion (BRAM, SystemIO, 0x025A, 0x02)
            Field (BRAM, ByteAcc, Lock, Preserve)
            {
                BRAI,   8,
                BRAD,   8
            }

            IndexField (BRAI, BRAD, ByteAcc, NoLock, Preserve)
            {
                Offset (0x8F),
                PBSY,   8,
                EPWS,   8,
                EB0S,   8,
                EB1S,   8,
                EB0T,   8,
                EB1T,   8,
                Offset (0x98),
                ECPU,   8,
                ECRT,   8,
                EPSV,   8,
                Offset (0xA0),
                B0VL,   16,
                B0RC,   16,
                B0FC,   16,
                B0MD,   16,
                B0ST,   16,
                B0CC,   16,
                B0DC,   16,
                B0DV,   16,
                B1VL,   16,
                B1RC,   16,
                B1FC,   16,
                B1MD,   16,
                B1ST,   16,
                B1CC,   16,
                B1DC,   16,
                B1DV,   16
            }

First of all I'm not sure wether I should replace all the fields that are accessed by the methods, or just change those where RegionSpace is EmbeddedControl.
Second thing is that According to ACPI Documentation I'm not sure if I calculated the Offset of the 256-bit values correctly. I was following that OperationRegion defines Starting offset in declaration, so for SMBX the starting offset should be 0x18 and for SMB2 the starting offset should be 0x40

Another thing that bothers me is the OperationRegion BRAM. It defines IndexField(BRAI, BRAD,...) that also has fields which are accessed by Battery methods. I dunno if I should poke them or not.
If anyone would be so kind and explain everything I would be happy. I attach clean disassembled DSDT.dsl.

Cheers.

EDIT: This configuration is really confusing. I noticed that _BIX method was broken so I used Clover's Rename and replace Method to change _BIX to XBIX to let _BIF handle the battery status. The battery status has shown and OS detects when I plug the AC adapter without even changing anything with the fields. Weird.

This one is easy, as are most ASUS...

The "ASUS N55SL/VivoBook" patch is a match.
 
Thanks (looks good)... added to the github repo.

Hello RehabMan. All week I tested my
1. Battery. I think it works less than in Windows 10 for about 30 minutes. HWMonitor usually shows a 4-6% charge less than the system and at the end of the reading the system can jump and show 0% then 8%
2. The Activity Monitor program started once, worked for 30 seconds and does not start again, it gives an error. (Error report is attached)
3. The touchpad works with errors, but the main thing is that after turning off the laptop it does not always work, but it always works when rebooting.

Look, there may be ideas how to fix this.
 

Attachments

  • RehabMan.zip
    3.4 MB · Views: 90
Hello RehabMan. All week I tested my
1. Battery. I think it works less than in Windows 10 for about 30 minutes. HWMonitor usually shows a 4-6% charge less than the system and at the end of the reading the system can jump and show 0% then 8%
2. The Activity Monitor program started once, worked for 30 seconds and does not start again, it gives an error. (Error report is attached)
3. The touchpad works with errors, but the main thing is that after turning off the laptop it does not always work, but it always works when rebooting.

Look, there may be ideas how to fix this.

1. Power management (effective use of power) has nothing to do with battery status. If you think your battery status is getting suck, try disabling PublishBatteryFactors in the plist associated with your board-id in X86PlatformPlugin.kext (Resources).

2. https://www.tonymacx86.com/threads/readme-common-some-unsolved-problems-in-10-12-sierra.202316/

3. You're using the ELAN driver. You should bring your issues to the ELAN kext author (it is not open source, in violation of the APSL).

Comments on your files:
- you have duplicate EC devices (bad idea). Choose either EC rename or SSDT-EC.aml, not both.
- ACPI/origin is too old to compare (you forgot to press F4)
- ForceKextsToLoad, as per guide, is only for pre-install (you should have removed it after installation)
- port limit patch should not be used long term
- you should be fixing your NVRAM with EmuVariableUefi-64 and "RC scripts" instead of setting BacklightLevel to a fixed value
 
Back
Top