acidanthera / bugtracker

Acidanthera Bugtracker
385 stars 45 forks source link

SMCBatteryManager little bug #1841

Open rboldini opened 2 years ago

rboldini commented 2 years ago

Hi, after some research i found that if the battery serial number is "0123456789" battery condition is always reported as bad status and the Service Recommended notification persist.

Injecting a Dummy SN in the _BIF method solved the problem, a simple check and replace during information poll can solve the problem for everyone in the same situation.


Other things i found is that from 20% the percentage reported form system gain 1% more than the one reported in ioreg, ending with 100% reported from system and 94% reported from ioreg, so more the battery is charge more the gap increase. In addition the Fully charged notification string appear only when the ioreg value reach 0x64 (100%).

I don't know if this second issue is related to my settings, to macOS behaviour or to a SMCBAttery bug.

Can't upload .zip here is my repo, rboldini No DEBUG log unfortunately, i'll provide it later.

Edit: Everything updated to latest (OC 0.7.5 and kext latest)

andreszerocross commented 2 years ago

I can't see serial number of battery. But it's reported as "Service Recommended" Asus ROG GL503VD-FY285T 4th  KabyLake - Intel HD 630 + I2C  - OpenCore-6

andreszerocross commented 2 years ago

This too,, no serial number of battery. But service is recommended alarm Asus VivoBook Pro 15 N580VD-77A05DB1 2nd  KabyLake - Intel HD 630 + I2C  - OpenCore-7

vit9696 commented 2 years ago

cc @usr-sse2 @lvs1974

usr-sse2 commented 2 years ago

Please show AppleSmartBattery properties in the ioreg. Снимок экрана 2021-11-03 в 16 05 38

usr-sse2 commented 2 years ago

Where do you look the percentage in the IOReg?

rboldini commented 2 years ago

MacBook Pro.zip

This is my fixed ioreg, in AppleSmartBattery under Battery Data here is a field for StateOfCharge that report it.

I'm sure this is not a device issue 'cause, beside the AC Adapter Plug here is a LED mapped like this: OFF = Not charging RED = Charging BLUE = Fully Charged

And it become Blue only when ioreg status reach 0x64

This observation include a check to CurrentCharge and LastFullCharge, CurrentCharge is equal to LastFullCharge 10 minutes after the icon reported 100%.

Probably i need to explain that, previously my battery wasn't working, as you can see in SSDT-BAT, i've dumped with RWEverything the whole EC region and mapped values, I found that DesignCapacity and Voltage where reported wrongly, so i just coded it in the right way and in the right index of the _BIF PKG[] (that i assume is an array/Structure in C, or a container(?) C++), and found that ACPIBatteryManager didn't work without a design voltage, instead SMCBatteryManager didn't work without a Design Capacity value (it report 1% charge).

Both of them actually report "Service Recommended" without a SN, so i assume you're just reading it and placing it in the virtual battery memory without checking is validity, then AppleBattery report it as bad. Probably SN is a check for "Real Battery" and report it wrong if battery is replaced, like in iPhone and iPad behaviour.

Hope it can help, i'm also a junior dev, actually C is my first lang but i'm also able to code in C++, Python, Assembly and many others, so feel free to ask for debug or help if needed for lack of time.

Actually i'm looking at this:


        /**      /* 123 ACPIBattery.h */
     *  QuickPoll will be disable when average rate is available from EC
     */
    bool averageRateAvailable {false};

i think this broke my AC Adapter detection/status when charge reach 100%, i'm fixing it using ACPIPoller and a dummy device to trigger the adapter if the condition state != prevState is true. (SSDT-LID-AC)

usr-sse2 commented 2 years ago

I'll check the serial number issue. (I have the "Service Recommended" too, but not because of the SN but because the battery had about 65% of its design capacity at the time I bought my laptop, and it continues to decrease and is now 57%). Your battery is in good condition (93%).

About the percentage: please show the IOReg when the battery is charging, StateOfCharge is less than 0x64 and the menu bar item displays 100%. I'll also check how it works on a 2013 MacBook Air.

rboldini commented 2 years ago

100.zip Screen Shot 2021-11-04 at 00 12 11

As you can see also Average Time to Full say 0x5 and Current Capacity is different from Max Capacity

BrandTime commented 2 years ago

Me too. Service is recommended alarm.

ASUS K550J, OS Version: Monterey 12.0.1 (21A559), MacBookPro 11,4

Everything updated to the latest (OC 0.7.5 and kext latest)

MacBook Pro.ioreg.zip

rboldini commented 2 years ago

So for everyone:

Report for battery service notification only if :

If you are below 80% of battery life you can try this fix injecting a new battery serial from DSDT.

It probably won't work, cause service notification is normal with a low battery life value. In that case don't report, it's as expected.

BrandTime commented 2 years ago

thanks @rboldini , Injecting a Dummy SN in the _BIF method solved the problem.

batio

bat

rboldini commented 2 years ago

Glad I was helpful.

I've also a tricky workaround for who's below 80% of battery life and doesn't mind to keep cycle count reported.

OEMs actually (or in past) fake the battery health providing LastFullChargeCapacity as DesignCapacity, an example is HP at least before 2015 models likes my Pavillion 15 or Chuwi with Corebook X gen 2 (8th gen i5) more recent.

So modifying the _BIF method and storing 'PKG 0x02' value in 'PKG 0x01' instead of the default one, will make Service Notification disappear, or at least I suppose it can work.

! IDK if that can make issue or break yours devices. That's just an observation !

rboldini commented 2 years ago

Sorry for this OP message, i'm trying to build VirtualSMC but actually i cant find the Headers included in the project, i suppose they are part of the MacKernelSDK(?). Someone can give a hint on this, sorry if it seems a dumb question i looked inside MacKernelSDK and project directory but can't find them.

BrandTime commented 2 years ago

Sorry for this OP message, i'm trying to build VirtualSMC but actually i cant find the Headers included in the project, i suppose they are part of the MacKernelSDK(?). Someone can give a hint on this, sorry if it seems a dumb question i looked inside MacKernelSDK and project directory but can't find them.

Lilu

usr-sse2 commented 2 years ago

Seems like it's related to the manufacture date, it's reported as Jan 1, 1970 if the serial doesn't contain a valid date, although it's supposed to be hardcoded value Feb 29, 2016. I'm working on it.

vit9696 commented 2 years ago

@usr-sse2 did we make any progress on that after discovering that macOS can blacklist batteries by serial number?

luonghv-31 commented 2 years ago

@rboldini did you fix it? I have problem same you.

Other things i found is that from 20% the percentage reported form system gain 1% more than the one reported in ioreg, ending with 100% reported from system and 94% reported from ioreg, so more the battery is charge more the gap increase. In addition the Fully charged notification string appear only when the ioreg value reach 0x64 (100%).

Kwokping commented 9 months ago

Injecting a Dummy SN in the _BIF method

how to Injecti a Dummy SN in the _BIF method,I have the same problem。