Contribute
Register

Battery Manager with Fix for Boot without Batteries

RehabMan

Moderator
Joined
May 3, 2012
Messages
191,692
Motherboard
Intel DH67BL
CPU
Core i7-2600K
Graphics
Intel HD 3000
Mac
MacBook Air
Mobile Phone
iOS
I'd like to have some help with testing these. If you have been following along, you know that I've come up with a fix for AppleSmartBatteryManager.kext where it shows incorrectly 'Power Source: Battery' if you remove the batteries and boot exclusively on AC power adapter. The fix is a simple two line fix to the code as provided by zprood over on that 'other insane hackintosh forum'... As you may know, my first attempt at creating this fix was hampered by the fact that my build seemed to cause other problems with certain machines, in particular tegezee's and a few others, where the status would not correctly show 'Charging' when the AC adapter was plugged in and the battery was present. Even without my two line code change that was the case. It is a mystery.

The cause of that remains unknown, so I'm attempting to start over. I've downloaded the sources provided by zprood, and very carefully did a build under current xcode with current ML tools and I'd like to see what happens. Especially for those folks that had issues with the last one.

I'm attaching two separate kexts. The one labeled 'nofix' is just zprood source re-compiled on my machine. The other marked 'withfix' has my two line change. So, I'd like to know how both of these perform, and in particular whether you get the 'Not Charging' with battery present and AC adapter plugged in (with a depleted battery). After I figure out this mystery, I can go on to other things...

Use your favorite kext installer (I like Kext Wizard) and be sure to fix permissions & rebuild cache just to make sure... Please provide feedback by replying here. Thanks,

Edit 2012-08-27: Also please test out the "release" build I did at this post: http://www.tonymacx86.com/hp-probook/69472-battery-manager-fix-boot-without-batteries.html#post431221. Only difference is debug vs. release build (without compiler optimizations/with optimizations).

Edit 2012-08-31: Please note I've released another version. For details, see this post: http://www.tonymacx86.com/hp-probook/69472-battery-manager-fix-boot-without-batteries-6.html#post436372

Edit 2012-09-10: New release available from github. From now on I will be releasing binaries only on the github project, located at: https://github.com/RehabMan/OS-X-ACPI-Battery-Driver. Of course, you can also build from source if you like.

Edit 2012-09-19: New release available from github. This version has code to handle ACPI battery methods that return data in watts instead of amps. ProBook always returns in amps, but some other laptops return watts.

Edit 2012-09-21: New release available from github. I have merged the probook branch into the master branch. It was becoming a pain to maintain the two separate branches for only a two line difference in Info.plist. This version adds some additional code to check for methods _BIX/_BBIX before using them even if the Info.plist is configured to use them.

Edit 2012-09-22: New release available from github. There was an issue where 10.7.5 (maybe all Lion versions) could not include the kext in the kernel cache. It is caused by something new Xcode 4.5 is doing. I rebuilt it with Xcode 4.4.1 and now it can be included in kernel cache. Bumped version numbers -- no other code changes.

Edit 2013-08-05: New release available (1.33). Changed the code to use DesignVoltage when converting from watts to amps when interpreting data from _BST. Not a concern for ProBook users, as the ProBook reports in amps. But for other laptops (Sony is one) where the report is in watts, it can make a difference when the reported voltage is different in _BST vs. _BIF.

Edit 2013-09-13: New release available (1.40). This version changes the name from AppleSmartBatteryManager.kext to ACPIBatteryManager.kext. This allows the stock kext to remain and the ACPIBatteryManager.kext to live in /S/L/E simultaneous. That way it is not overwritten by system updates.

Edit 2013-12-05: New release available (1.50). This version includes a device for the AC adapter ("ACPI0003") that allows the battery status to be updated quicker when plugging or unplugging the AC adapter. It overrides the use of AppleACPIACAdapter. This also means that if before you needed DSDT patches to make AppleACPIACAdapter load, you no longer need them. However, you may need other DSDT patches to make the _PSR method in your AC adapter device work.


Note: To be sure you are using AppleSmartBatteryManager.kext, be sure to remove AppleACPIBatteryManager.kext from /System/Library/Extensions. It is not needed and you don't want it loading instead of the now updated AppleSmartBatteryManager.kext. And every time an OS X update changes AppleSmartBatteryManager.kext, you will need to re-install this one.
 
Joined
Feb 17, 2011
Messages
138
Motherboard
HP ProBook 4540s
CPU
Intel Core i5 3 i5-3210M / 2.5 GHz
Graphics
Intel HD 4000 Graphics | Native Mode: 1366 x 768(p) (59.989Hz
Mac
Classic Mac
Mobile Phone
Android, iOS
Interested ! Working on ivy ? and lill confution had to install 2 kext together or 1/1?

I'd like to have some help with testing these. If you have been following along, you know that I've come up with a fix for AppleSmartBatteryManager.kext where it shows incorrectly 'Power Source: Battery' if you remove the batteries and boot exclusively on AC power adapter. The fix is a simple two line fix to the code as provided by zprood over on that 'other insane hackintosh forum'... As you may know, my first attempt at creating this fix was hampered by the fact that my build seemed to cause other problems with certain machines, in particular tegezee's and a few others, where the status would not correctly show 'Charging' when the AC adapter was plugged in and the battery was present. Even without my two line code change that was the case. It is a mystery.

The cause of that remains unknown, so I'm attempting to start over. I've downloaded the sources provided by zprood, and very carefully did a build under current xcode with current ML tools and I'd like to see what happens. Especially for those folks that had issues with the last one.

I'm attaching two separate kexts. The one labeled 'nofix' is just zprood source re-compiled on my machine. The other marked 'withfix' has my two line change. So, I'd like to know how both of these perform, and in particular whether you get the 'Not Charging' with battery present and AC adapter plugged in (with a depleted battery). After I figure out this mystery, I can go on to other things...

Use your favorite kext installer (I like Kext Wizard) and be sure to fix permissions & rebuild cache just to make sure... Please provide feedback by replying here. Thanks,
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
191,692
Motherboard
Intel DH67BL
CPU
Core i7-2600K
Graphics
Intel HD 3000
Mac
MacBook Air
Mobile Phone
iOS
Interested ! Working on ivy ? and lill confution had to install 2 kext together or 1/1?
It should work on pretty much anything with an ACPI compliant battery _STA, _BIF, _BST in DSDT.
I think the issue for you is you have gen3 with Ivy ProBook and a proper DSDT has not been created yet.
I think the problem with that is, so far, no one with DSDT skills has purchased a 4x40 series ProBook and hacked it...

Need someone with DSDT editing skills to look at a DSDT dump from your laptop and create a version that Mac OS likes...
I've been looking into how the DSDT was created for the 4530s as I'd like to understand it by going through the process myself.
(partially because I'd like to create a DSDT for my Intel DH67GD/core i7-2600 desktop)

As far as your confusion. This battery manager comes from zprood over on "Insanley Mac". He modified Apple's ACPI open source version with a few tweaks (evidently Apple used to use standard ACPI for battery management at one time and used open source to create it, so then had to release the source code per open source license). There was a slight bug in his version that when no batteries were installed in the laptop that it incorrectly reported power source as battery (no batteries, power source must be AC cord, right?). So, I had attempted to fix that bug a couple weeks back. Problem was I successfully fixed that problem but my build caused other problems and I couldn't figure out why. Making the process difficult was the fact that these "other problems" could not be reproduced on my computer. Only others -- in particular, tegezee. If I can't reproduce a problem, then I can only guess as to the cause. As a result, I started over with zprood's original sources and very carefully made my fix, trying not to cause any other problems and trying to set up the build environment as close to possible when BigDonkey built the same kexts for the HP Installer.

So the first one, with nofix, is just that... Zprood's original sources built by me. No changes at all. And with the bug where if the laptop has no battery installed at boot, it will display the bug of thinking it is on battery source, even no batteries are installed. The second one, withfix, is the same code, but with my two line fix for the "no batteries" issue discussed above.

So far, this version is working for tegezee so that is good. Later today, I hope to release a 'release' build of this with version # bump and the source.
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
191,692
Motherboard
Intel DH67BL
CPU
Core i7-2600K
Graphics
Intel HD 3000
Mac
MacBook Air
Mobile Phone
iOS
Interested ! Working on ivy ? and lill confution had to install 2 kext together or 1/1?
BTW, if you want to post your /Extra/dsdt.aml, I'd be willing to look at specifically the battery device.
 
Joined
Feb 17, 2011
Messages
138
Motherboard
HP ProBook 4540s
CPU
Intel Core i5 3 i5-3210M / 2.5 GHz
Graphics
Intel HD 4000 Graphics | Native Mode: 1366 x 768(p) (59.989Hz
Mac
Classic Mac
Mobile Phone
Android, iOS
BTW, if you want to post your /Extra/dsdt.aml, I'd be willing to look at specifically the battery device.
If i put Got KP So removed ATM
 

Attachments

RehabMan

Moderator
Joined
May 3, 2012
Messages
191,692
Motherboard
Intel DH67BL
CPU
Core i7-2600K
Graphics
Intel HD 3000
Mac
MacBook Air
Mobile Phone
iOS
If i put Got KP So removed ATM
Well at least your DSDT has the BAT0 device and the battery methods. If you look in Console log and search for 'AppleSmartBattery' what kind of messages do you see from the battery manager?
 

RehabMan

Moderator
Joined
May 3, 2012
Messages
191,692
Motherboard
Intel DH67BL
CPU
Core i7-2600K
Graphics
Intel HD 3000
Mac
MacBook Air
Mobile Phone
iOS
Attached you will find what I believe to be the final release of the battery manager kexts. In theory, this is applicable to ML and Lion, although I've only tested it on ML. I don't currently have a Lion partition to test with. It is built with Xcode Version 4.4.1 (4F1003), host OS is ML 10.8.1.

This is the same as zprood's version from this link: http://www.insanlynac.com/forum/index.php?showtopic=272459 (note you will have to fix that URL because of disagreements between tonymac & Insanely Mac), except for a fix for the case where the computer is started without any batteries installed. With my fix here it will correctly show running "Source: Power Adapter" and will of course use the "Power Adapter" power profile in energy preferences. It was simple two line change and is documented in the source code, attached. As per APLS open source license, I include the source and documented my changes along with date of modification.

I have built a 'Release' version and bumped the Version to "1.1" to make it easier to identify. Both AppleACPIBatteryManager.kext and AppleSmartBatteryManager.kext are included and both contain the fix. Please note that generally AppleSmartBatteryManager.kext is the kext that loads, and I believe that AppleACPIBatteryManager.kext is not needed (I usually remove it after the HP ProBook Installer installs it). I include it here just because zprood included it in his version.

Tegezee has tried it and he was one of the folks that had trouble with my version a couple of weeks ago... this time it is good. Several others have downloaded my test version above and I've heard nothing. I'm assuming no news is good news.

Please test and report any issues here.

Tegezee -- Assuming it is good, this is ready to be integrated in the Installer.
 
Joined
Feb 18, 2011
Messages
78
Motherboard
ProBook 4340s B6L98EA
CPU
i5 2450m
Graphics
Intel HD 3000
Mobile Phone
Android
Can you please verify my DSDT battery section to be compatible with your kexts?
 

Attachments

Joined
Apr 3, 2012
Messages
452
Motherboard
HP ProBook 4530s
CPU
i7 2670QM
Graphics
HD 7470M / HD 3000, 1920x1080
Mac
MacBook Pro
Mobile Phone
Android, iOS
How to fix this,my AC Charger is ON
Okay people before you install RehabMan's battery kext and expect it to work, there is some things you need to do. You can just install it and if it works great but instead of draining the battery to 4-5% just do this:

Reseting the smc (sort of speak)
*Turn off the laptop
*Take out your battery & ac adapter
*Hold down the power button for 30-60 seconds (just hold it for 60)
*Put the battery back in without the ac adapter
*Turn on the laptop
*(OPTIONAL)boot into bios & reset the defaults
*Now just boot up without ac adapter

Trust me this works, when you get to your desktop plugin your ac adapter.
 
Top