Contribute
Register

[Guide] How to patch DSDT for working battery status

Joined
Sep 5, 2016
Messages
19
Motherboard
XPS 15 9550 4825T
CPU
Intel(R) Core(TM) i7-6700HQ @ 2.60GHz
Graphics
Intel HD 530 & NVIDIA GTX 960M
Mac
  1. MacBook Pro
Mobile Phone
  1. Android
  2. iOS
HI Rehabman.

Then latest ACPIBatteryManager 20180915 Version have problem with AC adapter detection and always show bettery 100% but cant show AC.
However the ACPIBatteryManager 20171001 Version have no this problem.

I saw your post said some ASUS laptop have this problem and related with FBST but my ONDA laptop BIF have no FBST so i dont know how to deal with the latest ACPIBatteryManager wo make my AC adapter works.

Here are my DSDT and SSDT-BATT works with 20171001.

Thanks.
 

Attachments

  • SSDT-BATT.dsl.zip
    1,019 bytes · Views: 58
  • battery_ONDA-V919-3G-CoreM.txt.zip
    1.2 KB · Views: 55
  • DSDT.aml.zip
    25.2 KB · Views: 59
Last edited:

RehabMan

Moderator
Joined
May 2, 2012
Messages
183,805
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
HI Rehabman.

Then latest ACPIBatteryManager 20180915 Version have problem with AC adapter detection and always show bettery 100% but cant show AC.
However the ACPIBatteryManager 20171001 Version have no this problem.

I saw your post said some ASUS laptop have this problem and related with FBST but my ONDA laptop BIF have no FBST so i dont know how to deal with the latest ACPIBatteryManager wo make my AC adapter works.

Here are my DSDT and SSDT-BATT works with 20171001.

Thanks.

"Problem Reporting" files are incomplete.
Read FAQ, "Problem Reporting" again. Carefully. Attach all requested files/output.
https://www.tonymacx86.com/threads/faq-read-first-laptop-frequent-questions.164990/
Use the gen_debug.sh tool mentioned in the FAQ, that way it is less likely you'll omit something.
 
Joined
Oct 2, 2015
Messages
69
Motherboard
Yoga C930
CPU
i7- 8550U
Graphics
UHD620
Eliminate the SSDT that is not actually loading.
Your profile indicates you don't have Nvidia, so, assuming your profile is accurate, you can simply drop NvOptTbl SSDT.



It is because BAT0._STA is returning zero.
Look at the code for BAT0._STA:
Code:
                Method (_STA, 0, NotSerialized)  // _STA: Status
                {
                    If (LEqual (ECON, One))
                    {
                        If (ECAV)
                        {
                            If (LEqual (Acquire (LFCM, 0xA000), Zero))
                            {
                                Store (BA1P, Local0)
                                Release (LFCM)
                            }
                        }

                        If (And (Local0, One))
                        {
                            Return (0x1F)
                        }
                        Else
                        {
                            Return (0x0F)
                        }
                    }
                    Else
                    {
                        Return (Zero)
                    }
                }

Ok... so if ECON is not set, it will return zero.
If it returns zero, macOS doesn't even enter it into ACPIplane, it never gets to IOService, and ACPIBatteryManager.kext never starts.

ECON is not set until _REG is called.
See:
Code:
            Method (_REG, 2, NotSerialized)  // _REG: Region Availability
            {
...
                    Store (One, ECON)

Unfortunately, _STA determination is done way before _REG.

You need to fix _STA so it returns 0xF instead of zero in the case ECON is not set yet.
As in:
Code:
                Method (_STA, 0, NotSerialized)  // _STA: Status
                {
                    If (LEqual (ECON, One))
                    {
                        If (ECAV)
                        {
                            If (LEqual (Acquire (LFCM, 0xA000), Zero))
                            {
                                Store (BA1P, Local0)
                                Release (LFCM)
                            }
                        }

                        If (And (Local0, One))
                        {
                            Return (0x1F)
                        }
                        Else
                        {
                            Return (0x0F)
                        }
                    }
                    Else
                    {
                        Return (0xf)
                    }
                }

Hello, sorry to disturb you again. Recently I did a second review of my DSDT and found other devices are also affected by the same issue.

Code:
                Method (_STA, 0, NotSerialized)  // _STA: Status
                {
                    If ((ECON == One))
                    {
                        Return (0x0F)
                    }

                    Return (Zero)
                }

This _STA is also used by ADP0(ACPI003) and PWRB device. I tried the same method to enable these devices by return 0x0F directly. However, by enable ADP0, the login progress would stuck at about 80%. Meanwhile, correct PWRB will cause no battery status are reported.

It's strange that all these devices under EC shares the same logic but could not be enabled at the same time. Is there anything I could collect to diagnose this issue?
 

RehabMan

Moderator
Joined
May 2, 2012
Messages
183,805
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
Hello, sorry to disturb you again. Recently I did a second review of my DSDT and found other devices are also affected by the same issue.

Code:
                Method (_STA, 0, NotSerialized)  // _STA: Status
                {
                    If ((ECON == One))
                    {
                        Return (0x0F)
                    }

                    Return (Zero)
                }

This _STA is also used by ADP0(ACPI003) and PWRB device. I tried the same method to enable these devices by return 0x0F directly. However, by enable ADP0, the login progress would stuck at about 80%. Meanwhile, correct PWRB will cause no battery status are reported.

It's strange that all these devices under EC shares the same logic but could not be enabled at the same time. Is there anything I could collect to diagnose this issue?

What exactly are you trying to fix with these edits?

No "Problem Reporting" files attached.
Read FAQ, "Problem Reporting" again. Carefully. Attach all requested files/output.
https://www.tonymacx86.com/threads/faq-read-first-laptop-frequent-questions.164990/
Use the gen_debug.sh tool mentioned in the FAQ, that way it is less likely you'll omit something.
 
Joined
Oct 2, 2015
Messages
69
Motherboard
Yoga C930
CPU
i7- 8550U
Graphics
UHD620
What exactly are you trying to fix with these edits?

No "Problem Reporting" files attached.
Read FAQ, "Problem Reporting" again. Carefully. Attach all requested files/output.
https://www.tonymacx86.com/threads/faq-read-first-laptop-frequent-questions.164990/
Use the gen_debug.sh tool mentioned in the FAQ, that way it is less likely you'll omit something.

Sorry to disturb you, but I think I might have just figured out the reason.

I found both ADP0, PWRB and BAT0 use the same expression (ECON == One) to decide whether it is available. As BAT0 must exist for battery status, ADP0 and PWRB shall also available for adapter and power button. That's why I think their _STA need patches. But the output is not stable, one situation is described above.

However, one time I tired to boot with both _STA patch on, the system started successful, and AC status is displayed now. By analyzing kp logs, it seems that ADP0 status have connection with whether Thunderbolt is up. This laptop features a tb3 port and it's the only charging method by USB-PD. Although it can be charged when tb3 is not implemented, but the battery information may only valid when tb3 driver is up and gather information through USB interface. The latter part is a guess based on a recent kp after unplug the charger. So maybe I have to get a stable tb3 (at least USB part) first?
 

Attachments

  • debug_2664 1.zip
    4.1 MB · Views: 71

RehabMan

Moderator
Joined
May 2, 2012
Messages
183,805
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
Sorry to disturb you, but I think I might have just figured out the reason.

I found both ADP0, PWRB and BAT0 use the same expression (ECON == One) to decide whether it is available. As BAT0 must exist for battery status, ADP0 and PWRB shall also available for adapter and power button. That's why I think their _STA need patches. But the output is not stable, one situation is described above.

However, one time I tired to boot with both _STA patch on, the system started successful, and AC status is displayed now. By analyzing kp logs, it seems that ADP0 status have connection with whether Thunderbolt is up. This laptop features a tb3 port and it's the only charging method by USB-PD. Although it can be charged when tb3 is not implemented, but the battery information may only valid when tb3 driver is up and gather information through USB interface. The latter part is a guess based on a recent kp after unplug the charger. So maybe I have to get a stable tb3 (at least USB part) first?

There are a couple of threads regarding TB SSDT patching (very much a work-in-progress). You should check into them.
Off-topic here.
 

RehabMan

Moderator
Joined
May 2, 2012
Messages
183,805
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
How do you go about finding the right information for your laptop? As mine is a Lenovo V110-15ISK 80TL model.
I have MaciASL, added your http://raw.github.com/RehabMan/Laptop-DSDT-Patch/master to sources but I'm unable to determine if any Lenovo laptop there is similar.
No "Problem Reporting" files attached.
Read FAQ, "Problem Reporting" again. Carefully. Attach all requested files/output.
https://www.tonymacx86.com/threads/faq-read-first-laptop-frequent-questions.164990/
Use the gen_debug.sh tool mentioned in the FAQ, that way it is less likely you'll omit something.
 
Joined
Jul 28, 2017
Messages
122
Motherboard
ASUS-Prime Z-390-P
CPU
i5-9400
Graphics
iGPU
Mac
  1. MacBook Air
Mobile Phone
  1. Android

Attachments

  • debug_8998.zip
    2.3 MB · Views: 48

RehabMan

Moderator
Joined
May 2, 2012
Messages
183,805
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
Here you go.

If you had followed the guide, you would have discovered your DSDT has no multibyte EC fields, therefore no need to patch any.
You just need to install ACPIBatteryManager.kext.
 
Top