Contribute
Register

[Guide] How to patch DSDT for working battery status

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.
 
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?
 
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.
 
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: 82
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.
 
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.
 

Attachments

  • debug_8998.zip
    2.3 MB · Views: 63
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.
 
HI Rehabman.
I can not start the battery. The patch does not help. Laptop Lenovo B5070. Please.
 

Attachments

  • DSDT_b5070.aml.zip
    20.5 KB · Views: 51
  • debug_5296.zip
    1.9 MB · Views: 73
Back
Top