Contribute
Register

[Guide] How to patch DSDT for working battery status

Last edited:
Thanks Rehabman,
I have read it several times but am unsure what else to do - I have increased the delay, I have disabled the TRIM patch and nothing seem to have an effect. I'm stumped :/

Alright, so I've figured something out - the battery icon and status appears immediately after I press a screen brightness up or down multimedia key. It's weird but it somehow forces macOS to read the status of the battery and realise that there is in fact a battery. However the status is still stuck and not updating. If I use a third-party battery status app, the percentage does change as the battery discharges.

EDIT: I have found even more - the AppleSmartBattery attachment to BAT0 in IOReg says false to the property 'Battery Installed' after boot when the battery icon in invisible. But then when I press either of the Brightness keys (up or down), the battery icon immediately appears with the correct status (however it is frozen - i.e. doesn't update). At this point, AppleSmartBattery displays the more properties with their fields now filled with battery status data as well as 'Battery Installed' returning true.

I don't understand why this happens and I hope that you have an idea. The above described behaviour happens regardless of the first poll delay flag being specified in config.plist or not. I have uploaded two IOReg files which are a before and after so you can see for yourself what is going on. If you need me to perform some kind of debugging steps, please let me know.

Thank you!
 

Attachments

  • Battery.zip
    1.1 MB · Views: 72
Last edited:
Alright, so I've figured something out - the battery icon and status appears immediately after I press a screen brightness up or down multimedia key. It's weird but it somehow forces macOS to read the status of the battery and realise that there is in fact a battery. However the status is still stuck and not updating. If I use a third-party battery status app, the percentage does change as the battery discharges.

EDIT: I have found even more - the AppleSmartBattery attachment to BAT0 in IOReg says false to the property 'Battery Installed' after boot when the battery icon in invisible. But then when I press either of the Brightness keys (up or down), the battery icon immediately appears with the correct status (however it is frozen - i.e. doesn't update). At this point, AppleSmartBattery displays the more properties with their fields now filled with battery status data as well as 'Battery Installed' returning true.

I don't understand why this happens and I hope that you have an idea. The above described behaviour happens regardless of the first poll delay flag being specified in config.plist or not. I have uploaded two IOReg files which are a before and after so you can see for yourself what is going on. If you need me to perform some kind of debugging steps, please let me know.

Thank you!

You will need to use ACPIDebug.kext to debug/troubleshoot your _BIF/_BST/_BST methods.
 

Attachments

  • Problem Report files.zip
    2.9 MB · Views: 50
"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.
Hi rehabman thanks for your reply!.
I've already downloaded the tools but when i run the sh file from terminal, it required internet connection, since my laptop wifi card isn't supported i can't connect to the internet. Is there any other way to do it? Or what files are missing?
 
You will need to use ACPIDebug.kext to debug/troubleshoot your _BIF/_BST/_BST methods.

Hi Rehabman,
So I managed to get some output from battery related methods _STA, _BST and others and I've attached a log (plus comments) of both ACPIDebug output as well as ACPISmartBattery. I have also attached a DSDT file so that you can see what lines are causing the output. Could you please have a look at them when you can because even after reading up on some of those methods in the ACPI spec, I'm still quite unsure :/

What I've learnt so far about this situation:
- macOS boots
- ACPISmartBattery tries to poll battery
- _STA in BAT0 reports that there is no battery (maybe due to MIS0 which is mentioned in a different place in DSDT that checks what power the laptop is getting).
- ACPISmartBattery continues to poll with the same result
- I press brightness up/down key on my laptop and - boom - ACPISmartBattery says that I've inserted a battery and immediately gets battery information.
- Battery icon shows the current status however the percentage does not update and AC plug status is stuck as well.
- Stats update in IOReg correctly in realtime

P.S.: Would changing the _STA method in BAT0 so it reports so that there is always a battery cause an issue in your opinion? Cause after 1 is returned (i.e. a battery is present) the laptop has no problems reading the battery status. It's kind of a janky fix though.

If you need more info, please let me know.
Sorry to bother you so much,

Thanks in advance!
 

Attachments

  • Battery-Debug.zip
    624.5 KB · Views: 81
Hi Rehabman,
So I managed to get some output from battery related methods _STA, _BST and others and I've attached a log (plus comments) of both ACPIDebug output as well as ACPISmartBattery. I have also attached a DSDT file so that you can see what lines are causing the output. Could you please have a look at them when you can because even after reading up on some of those methods in the ACPI spec, I'm still quite unsure :/

What I've learnt so far about this situation:
- macOS boots
- ACPISmartBattery tries to poll battery
- _STA in BAT0 reports that there is no battery (maybe due to MIS0 which is mentioned in a different place in DSDT that checks what power the laptop is getting).
- ACPISmartBattery continues to poll with the same result
- I press brightness up/down key on my laptop and - boom - ACPISmartBattery says that I've inserted a battery and immediately gets battery information.
- Battery icon shows the current status however the percentage does not update and AC plug status is stuck as well.
- Stats update in IOReg correctly in realtime

P.S.: Would changing the _STA method in BAT0 so it reports so that there is always a battery cause an issue in your opinion? Cause after 1 is returned (i.e. a battery is present) the laptop has no problems reading the battery status. It's kind of a janky fix though.

If you need more info, please let me know.
Sorry to bother you so much,

Thanks in advance!

MIS0 is updated in two places, SOST and PWSH.

I can see PWSH called from NEVT, which is called from the EC queries, so it makes sense that MIS0 gets updated when you do something that causes an EC query.

SOST is called from PCI0._INI, but maybe that is too early for the SMI reads (via SMI method you see SOST using). Maybe try calling SOST from BAT0._STA (to make sure MIS0 is updated each time) or you could hardcode BAT0._STA return at 0x1F (macOS does not support removable batteries anyway).
 
MIS0 is updated in two places, SOST and PWSH.

I can see PWSH called from NEVT, which is called from the EC queries, so it makes sense that MIS0 gets updated when you do something that causes an EC query.

SOST is called from PCI0._INI, but maybe that is too early for the SMI reads (via SMI method you see SOST using). Maybe try calling SOST from BAT0._STA (to make sure MIS0 is updated each time) or you could hardcode BAT0._STA return at 0x1F (macOS does not support removable batteries anyway).

Thanks a lot! I will try that soon.
 
Back
Top