Contribute
Register

<< Solved >> OpenCore battery patch

Joined
Feb 9, 2017
Messages
89
Motherboard
HP Elitebook 8470p
CPU
Intel Core i7-3740QM
Graphics
AMD Radeon HD 7570m 1GB
Mobile Phone
  1. iOS
@DaveJ1

I think it would be helpful if you attach the Clover-Patch with working cycle-count, I can take a look at it and maybe help to transfer the responsible section. No idea about thermal stuff tho, never even seen it on any of my machines.
Under ACPI/Patched. Don't worry about thermal.
Thanks!
 
Last edited:
Joined
Mar 8, 2017
Messages
723
Motherboard
Lenovo ThinkPad T480s (OpenCore)
CPU
i7-8550U
Graphics
UHD 620, 2560x1440
Mobile Phone
  1. Android
@DaveJ1

Okay, I had a quick look at the source and can now share my opinion on it with you. When the patched and original DSDTs are diffed, I noticed an important addition the patch made:

Screen Shot 2021-08-05 at 18.04.57.png


BTIF gathers the needed battery information values and stores them at a known location (in this case package array NBTI, where [0] is the primary battery and [1] got called "travel"). The patched DSDT also writes BCC (possibly battery cycle-count) and TEMP to this package, which will then be read by macOS. Your native DSDT doesn't, other OS probably have another way of acquiring this data.

I'm not 100% sure on how to integrate this to your current setup, since I have *never* worked with ECEnabler. Had a gander at it's source, seems like it just reroutes AppleACPIEC's ecSpaceHandler to some custom implementations that are able to handle fields > 8b. So I *guess* that we no longer need to care about B1B2, B1B4, RECB, WECB, and so on, and just directly implement changes.

Would you be okay if I create a small SSDT for this fix, which may not work? You'd need to create a safe backup so you don't lock yourself out of your system. If it doesn't work, we need to fully convert this DSDT to a battery SSDT.
 
Joined
Feb 9, 2017
Messages
89
Motherboard
HP Elitebook 8470p
CPU
Intel Core i7-3740QM
Graphics
AMD Radeon HD 7570m 1GB
Mobile Phone
  1. iOS
@DaveJ1

Okay, I had a quick look at the source and can now share my opinion on it with you. When the patched and original DSDTs are diffed, I noticed an important addition the patch made:

View attachment 526323

BTIF gathers the needed battery information values and stores them at a known location (in this case package array NBTI, where [0] is the primary battery and [1] got called "travel"). The patched DSDT also writes BCC (possibly battery cycle-count) and TEMP to this package, which will then be read by macOS. Your native DSDT doesn't, other OS probably have another way of acquiring this data.

I'm not 100% sure on how to integrate this to your current setup, since I have *never* worked with ECEnabler. Had a gander at it's source, seems like it just reroutes AppleACPIEC's ecSpaceHandler to some custom implementations that are able to handle fields > 8b. So I *guess* that we no longer need to care about B1B2, B1B4, RECB, WECB, and so on, and just directly implement changes.

Would you be okay if I create a small SSDT for this fix, which may not work? You'd need to create a safe backup so you don't lock yourself out of your system. If it doesn't work, we need to fully convert this DSDT to a battery SSDT.
Sure, Let's do this.
 
Last edited:
Joined
Feb 23, 2020
Messages
131
Motherboard
Dell Precision M4700
CPU
i7-3740QM
Graphics
M4000
I'm not 100% sure on how to integrate this to your current setup, since I have *never* worked with ECEnabler. Had a gander at it's source, seems like it just reroutes AppleACPIEC's ecSpaceHandler to some custom implementations that are able to handle fields > 8b. So I *guess* that we no longer need to care about B1B2, B1B4, RECB, WECB, and so on, and just directly implement changes.
That's exactly what it does. If you have ECEnabler, you don't need to worry about B1B2, B1B4, RECB, WECB, etc

Btw, I'd check the ACPI spec. _BIF does not return cycle count, _BIX does. You probably need to write a custom _BIX method.
Section 10.2.2.1 for _BIF
Section 10.2.2.2 for _BIX

I think AcpiBatteryManager could read extra (nonstandard) fields from _BIF but SMCBatteryManager won't:

If you want battery temperature, SMCBatteryManager does have a custom method for that:
 
Joined
Mar 8, 2017
Messages
723
Motherboard
Lenovo ThinkPad T480s (OpenCore)
CPU
i7-8550U
Graphics
UHD 620, 2560x1440
Mobile Phone
  1. Android
@1Revenger1

I honestly never tried to work on anything related to cycle count or thermals, which is why this is more guesswork on my part than anything I'm sure about. RehabMan talked about _BIF, which is why I took a look at it (https://www.tonymacx86.com/threads/lenovo-x230-battery-cycle-count-last-problem-to-be-solved.257163/).

Just read the links you provided, and I now see what issue you're talking about. _BIF and NBTI work, but are not up to standard, and thus not read by the newer SMCBatteryManager, only legacy ACPIBatteryManager does. I could implement _BIX with NBIX, just not sure if it's worth the trouble, or if downgrading to the other kext would be fine as well.
 
Joined
Mar 8, 2017
Messages
723
Motherboard
Lenovo ThinkPad T480s (OpenCore)
CPU
i7-8550U
Graphics
UHD 620, 2560x1440
Mobile Phone
  1. Android
@DaveJ1

Please try this SSDT, just copy, add in config and reboot, no renames or anything else needed. This should change battery information, please capture a screenshot before *and* after. I commented out TEMP for now, since I'm not 100% sure on how it works yet.
 

Attachments

  • SSDT-BATT.aml
    1.2 KB · Views: 17
Joined
Feb 9, 2017
Messages
89
Motherboard
HP Elitebook 8470p
CPU
Intel Core i7-3740QM
Graphics
AMD Radeon HD 7570m 1GB
Mobile Phone
  1. iOS
@DaveJ1

Please try this SSDT, just copy, add in config and reboot, no renames or anything else needed. This should change battery information, please capture a screenshot before *and* after. I commented out TEMP for now, since I'm not 100% sure on how it works yet.
Showing up Battery power, and Serial number is gone.
Is this enough information?
 
Joined
Mar 8, 2017
Messages
723
Motherboard
Lenovo ThinkPad T480s (OpenCore)
CPU
i7-8550U
Graphics
UHD 620, 2560x1440
Mobile Phone
  1. Android
@DaveJ1

Thanks for the quick response, I need some more time to read up on this stuff, I think I messed up a little. Hold tight, be right back!
 
Joined
Mar 8, 2017
Messages
723
Motherboard
Lenovo ThinkPad T480s (OpenCore)
CPU
i7-8550U
Graphics
UHD 620, 2560x1440
Mobile Phone
  1. Android
@DaveJ1

Since I'm not really sure what's the issue and I can't live-debug this, it would be awesome if you could again boot with the attached SSDT and show me another screenshot, there should be some debugs there now.
 

Attachments

  • SSDT-BATT.aml
    1.2 KB · Views: 13
Joined
Feb 9, 2017
Messages
89
Motherboard
HP Elitebook 8470p
CPU
Intel Core i7-3740QM
Graphics
AMD Radeon HD 7570m 1GB
Mobile Phone
  1. iOS
@DaveJ1

Since I'm not really sure what's the issue and I can't live-debug this, it would be awesome if you could again boot with the attached SSDT and show me another screenshot, there should be some debugs there now.
When,
Plugged in:
- first reboot the Hardware/Power page the same
- CoconutBattery showing usual, except the temperature, cycle count.
- Discharging/Charging indicator is working, at least showing more or less the correct Wattage.
- macOS Battery Percentage and Coconut Charge Capacity is showing different value. ~5% different.

Unplugged:
- second reboot Hardware/Power showing Serial number, but Battery Power(3rd reboot yes) section not and Coconutbattery showing nothing.

Boot with plugged and then unplugged.
- Battery icon is changing to battery source and back to power source. Charge capacity is changing(decrease/increase).
- Coconutbattery showing, except thermal and cycle count.
When reconnecting, icon/percentage changing.

It was a moment at the second boot, when i closed CoconutBattery and opened, then showed nothing.

Boot with unplugged and then plugged.
- Battery icon is charging. - source and percentage
- CoconutBattery is fully empty, after plugged too.

I wanted a relatively detailed quick test.
How can i get more proper information to you?
 
Last edited:
Top