AppHouseKitchen / AlDente-Charge-Limiter

Menubar Tool to set Charge Limits and Prolong Battery Lifespan
https://apphousekitchen.com/
Other
7.97k stars 293 forks source link

Somone managed to run it on a M1 MBP with Big Sur? #52

Closed Peebuddy43 closed 3 years ago

Peebuddy43 commented 3 years ago

Somone managed to run it on a M1 MBP with Big Sur?

JiaaackY commented 3 years ago

I tried on my m1 air. It doesn't work. I installed the helper tool and reboot my air but it still keeps charging.

davidwernhart commented 3 years ago

@JiaaackY thank you for this information! I already suspected that it would not work on M1 macs since they have no SMC like the intel ones have. Maybe I will be able to find a similar solution for M1 macs in the future, but for now I don't have a device to test. Best regards, David

FreeWoRLD83 commented 3 years ago

@JiaaackY thank you for this information! I already suspected that it would not work on M1 macs since they have no SMC like the intel ones have. Maybe I will be able to find a similar solution for M1 macs in the future, but for now I don't have a device to test. Best regards, David

You can't imagine how many folks out there awaiting eagerly for the M1 version as this is the most amazing app you could ever install on your mac if you are careful about battery of your device. Love your work.

asd123cqp commented 3 years ago

I believe SMC should still exist on ARM Macs, it's just that the key BCLM has been renamed or removed.

I complied the smc tool from smcFanControl on an ARM Mac.

DevNulPavel commented 3 years ago

@asd123cqp Can you show your output of smc -l command?

asd123cqp commented 3 years ago

Sure, here's the smc -l output on a M1 Macbook Air: smc-l-arm-mba.txt.

davidwernhart commented 3 years ago

Thank you for dumping the smc keys @asd123cqp ! That is very interesting to me, I suspect Apple simply renamed some keys for the new M1 macbooks. From looking at your dump, I would guess that the key "BCMV" (maybe "battery charge max value"?) could be the right one. If you are brave enough, you could maybe try to write to it and see what happens. Although I must warn you that you can also brick your MacBook by writing to the wrong keys and I do not take responsibility if that would be the case. Anyways, thank you for sharing your findings! Best regards, David

DizzyFop commented 3 years ago

Thank you for dumping the smc keys @asd123cqp ! That is very interesting to me, I suspect Apple simply renamed some keys for the new M1 macbooks. From looking at your dump, I would guess that the key "BCMV" (maybe "battery charge max value"?) could be the right one. If you are brave enough, you could maybe try to write to it and see what happens. Although I must warn you that you can also brick your MacBook by writing to the wrong keys and I do not take responsibility if that would be the case. Anyways, thank you for sharing your findings! Best regards, David

How could you brick it? Would resetting the SMC not fix an issue caused by this?

davidwernhart commented 3 years ago

@Superjack78 because we don't know what those keys do for now. Maybe BCMV actually stands for "battery charge max voltage" and modifying it actually messes with the charging circuit, having the potential to do some permanent damage to the battery even if you reset the SMC afterwards. The point is that we just don't know yet and there is always some risk attached to messing with the SMC. I got lucky with finding the original BCLM key, but I cannot guarantee that this is the case for everyone.

asd123cqp commented 3 years ago

From looking at your dump, I would guess that the key "BCMV" (maybe "battery charge max value"?) could be the right one.

@davidwernhart I doubt BCMV is the renamed BCLM. Its current value is BCMV [ui16] 23312 (bytes 5b 10) and I am not sure how to make sense of this number. Maybe this is the new charge limit and it is now an absolute value instead of a percentage. Maybe it's totally unrelated. I don't know.

There are two values that stand out to me though. I searched the dump for keys that start with an "B" and have the value "100" and found these two: BMSC [ui16] 100 (bytes 64) and BTRS [ui8 ] 100 (bytes 64). Again, not sure what they stand for and might be totally unrelated. I don't know.


Update:

smoothdvd commented 3 years ago

BTRS is for Bluetooth?

2018-08-07 09:16:29.919311+0100 0x7b Default 0x0 0 0 kernel: (IOBluetoothFamily) [IOBluetoothACPIMethods][SetBTRS] -- mACPIDevice->evaluateObject ('BTRS') successful -- took 23211 microseconds

https://github.com/khronokernel/DarwinDumped/blob/b6d91cf4a5bdf1d4860add87cf6464839b92d5bb/MacBook/MacBook9%2C1/BootLog_Kernel/Kernel_Messsages_BootLog.txt

thloh85-intel commented 3 years ago

@asd123cqp Wonder if you have managed to try out writing to BMSC? Note: I can't test it yet as the M1 Macbook isn't available in my home country yet. Just checking if I'm still able to limit the charge when I buy the new M1 MacBook since my Macbook sits on my charger all day

timension commented 3 years ago

I find it very strange that so many people (including me) want this feature (which is very sound, considering the sustainability etc.) but Apple cannot provide it natively. :-/

lasharor commented 3 years ago

I find it very strange that so many people (including me) want this feature (which is very sound, considering the sustainability etc.) but Apple cannot provide it natively. :-/

I believe it to be even more relevant now as with the increased battery life it becomes somewhat difficult to get this laptop to "healthy" battery levels in regular office use.

tairasu commented 3 years ago

I find it very strange that so many people (including me) want this feature (which is very sound, considering the sustainability etc.) but Apple cannot provide it natively. :-/

I believe apple doesn't want to spread the fact that keeping your battery at 60% is keeping it healthy. if too many people know it, the "user experience" might suffer, because then people are afraid of charging it up to 100%. they rather hide it as a "battery optimization" feature, that is out of control of the user

thloh85 commented 3 years ago

Did anyone tried out changing BMSC? I want to buy the new M1 MacBook, been using AlDente for a while, and wish to know if I can still use it for M1 MacBook.

stefandesu commented 3 years ago

I'm slightly worried that this feature was removed from the M1 MacBooks. The support article "About battery health management in Mac notebooks" has two versions:

The latter doesn't talk about the "battery health management feature" at all. 🤔

lasharor commented 3 years ago

I'm slightly worried that this feature was removed from the M1 MacBooks. The support article "About battery health management in Mac notebooks" has two versions:

The latter doesn't talk about the "battery health management feature" at all. 🤔

Screenshot 2020-12-08 at 21 48 09

M1 Macbook Air

stefandesu commented 3 years ago
Screenshot 2020-12-08 at 21 48 09

M1 Macbook Air

What I meant is the option "Manage battery longevity" under Battery Health (see screenshot in the Intel article). That feature is missing on M1 Macs (at least on my MBA).

thloh85-intel commented 3 years ago

Well as long as the hook to enable "Optimised battery charging" is there, there should be a way to limit the charge. However, if the hook is now placed in the firmware (ie. ARM's SMC, secure monitor call, not system management controller, callback handles Y/N to optmize battery charging instead of the percentage), then we're out of luck. If the Secure Monitor Call still accepts battery percentage value instead of a typical Y/N, then we're still able to do this, with proper privilege.
I hope they didn't kill this.

@stefandesu Are you planning to try out changing BMSC's value?

stefandesu commented 3 years ago

@stefandesu Are you planning to try out changing BMSC's value?

I'm not willing to take the risk, sorry. 🙈

mattiasottosson commented 3 years ago

I don't really get how the optimised battery charging works. Had that checked since day one on both my iPhone and M1 mac, but haven't seen it stay at 80% once.

I use my macbook at work plugged in to a screen, so it stays at a 100% at all times now unfortunately.

Maybe start a BMSC insurance campaign at gofundme? 🤓

celsoazevedo commented 3 years ago

I tried on my m1 air. It doesn't work. I installed the helper tool and reboot my air but it still keeps charging.

With Big Sur, I had to set the % max and reboot my Intel MBP 16" twice for the limit to be applied.

Not saying that AlDente works on the M1, but I would try set the limit and reboot more than one time. Also, if we set it to stop at 80%, sometimes it goes over that (usually 1 or 2% above the value we set).

Evertt commented 3 years ago

No it just doesn't work on M1 MacBooks.

thloh85-intel commented 3 years ago

No it just doesn't work on M1 MacBooks. …

It won't work without proper changes definitely. As per @asd123cqp's check, the BMCV SMC value is no longer there, thus we need to look for the proper value to change (if it exists)

Evertt commented 3 years ago

Yes I'm aware, I read all of that. I hope the value still exists under a different name, because this tool is super useful.

davidwernhart commented 3 years ago

I don't really get how the optimised battery charging works. Had that checked since day one on both my iPhone and M1 mac, but haven't seen it stay at 80% once.

I use my macbook at work plugged in to a screen, so it stays at a 100% at all times now unfortunately.

Maybe start a BMSC insurance campaign at gofundme? 🤓

This sounds like a good idea, but I honestly doubt to get enough backers to afford a ~1100€ M1 MacBook Air to experiment with. I guess it's much more likely that someone who already owns one finds the right key in the meantime.

Best Regards, David

thloh85 commented 3 years ago

Honestly, I suspect they moved it to firmware level callback (ie. the ARM SMC callback) instead of the SMC value. I've been working on ARM bootloader and are familiar with SMC callback's functionality, and this is one of the implementation that I personally would put in as an SMC call. As for how it is called, what value, it really is up to the kernel level driver. In Linux, it is open source, thus is pretty open and accesible how one can set it, but in MacOS, not so much. However, Darwin kernel is open source, so, in that department, we might find something :)

Ryanfsdf commented 3 years ago

I've figured out some more clues in case anyone is willing to risk their their laptop.

When I first got my M1 MBA, there were 4 values in the SMC which had a value of 100. These were BMSC, BNSC, BTRS, and BUIC.

Upon checking now, I see that BMSC and BNSC are both at 99 instead of 100. They seem to be related in some way, and the fact that they dropped to 99 seems to suggest that they are percentages.

However, even though both of these values are 99, my laptop still charges all the way up to 100%. This may not mean much though, because I've noticed on all my MacBooks that even if my laptop battery is ~97% full based on actual current battery capacity divided by the maximum capacity, the laptop doesn't charge beyond that and the battery percentage reported is still 100%.

thloh85 commented 3 years ago

This could also mean that the BMSC is the max battery percentage (ie. your battery health).

On Sun, 13 Dec 2020 at 6:20 PM Ryan Kim notifications@github.com wrote:

I've figured out some more clues in case anyone is willing to risk their their laptop.

When I first got my M1 MBA, there were 4 values in the SMC which had a value of 100. These were BMSC, BNSC, BTRS, and BUIC.

Upon checking now, I see that BMSC and BNSC are both at 99 instead of 100. They seem to be related in some way, and the fact that they dropped to 99 seems to suggest that they are percentages.

However, even though both of these values are 99, my laptop still charges all the way up to 100%. This may not mean much though, because I've noticed on all my MacBooks that even if my laptop battery is ~97% full based on actual current battery capacity divided by the maximum capacity, the laptop doesn't charge beyond that and the battery percentage reported is still 100%.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/davidwernhart/AlDente/issues/52#issuecomment-743983966, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACNGGKFZEV5ZW252Z47D77LSUSIO3ANCNFSM4T4TEQ5A .

Ryanfsdf commented 3 years ago

This could also mean that the BMSC is the max battery percentage (ie. your battery health).

I don't think it is, because my max battery capacity is at 4420mAh and the design capacity is 4382mAh.

DevNulPavel commented 3 years ago

Maybe BMSC stands for "Battery Max Supported Charge"?

thloh85 commented 3 years ago

This could also mean that the BMSC is the max battery percentage (ie. your battery health).

I don't think it is, because my max battery capacity is at 4420mAh and the design capacity is 4382mAh.

Yeah, but from @asd123cqp's log, the value is pretty different (BMSC == 100, BNSC == 92). I couldn't make out what's the actual value :(

smoothdvd commented 3 years ago

@thloh85 my smc data: capture 1 (stop charging at 70%):

BMSC  [ui16]  70 (bytes 46) 
BNSC  [ui16]  37 (bytes 25) 

capture 2(stop charging at 66):

BMSC  [ui16]  70 (bytes 46), 
BNSC  [ui16]  37 (bytes 25)

capture 3(stop charging at 74%)

BMSC  [ui16]  74 (bytes 4a)
BNSC  [ui16]  37 (bytes 25)
Screen Shot 2020-12-14 at 11 36 52 AM

suppose it is the BMSC means MAX value in some period when charging is stopped (Battery Max Stopped Charge) and BNSC means MIN value in some period when charging is started(Battery Min Started Charge).

thloh85 commented 3 years ago

@thloh85 my smc data: capture 1 (stop charging at 70%):

BMSC  [ui16]  70 (bytes 46) 
BNSC  [ui16]  37 (bytes 25) 

capture 2(stop charging at 66):

BMSC  [ui16]  70 (bytes 46), 
BNSC  [ui16]  37 (bytes 25)

capture 3(stop charging at 74%)

BMSC  [ui16]  74 (bytes 4a)
BNSC  [ui16]  37 (bytes 25)
Screen Shot 2020-12-14 at 11 36 52 AM

suppose it is the BMSC means MAX value in some period when charging is stopped (Battery Max Stopped Charge) and BNSC means MIN value in some period when charging is started(Battery Min Started Charge).

Yeah, this makes a lot of sense! Thanks for trying out, this makes me instantly buys the Macbook Air! I guess what we'll need to do is to integrate the changes back into AlDente.

Thanks a lot @smoothdvd for trying this out and reporting back, I guess this is where open source benefits most!

thloh85 commented 3 years ago

@thloh85 my smc data: capture 1 (stop charging at 70%):

BMSC  [ui16]  70 (bytes 46) 
BNSC  [ui16]  37 (bytes 25) 

capture 2(stop charging at 66):

BMSC  [ui16]  70 (bytes 46), 
BNSC  [ui16]  37 (bytes 25)

capture 3(stop charging at 74%)

BMSC  [ui16]  74 (bytes 4a)
BNSC  [ui16]  37 (bytes 25)
Screen Shot 2020-12-14 at 11 36 52 AM

suppose it is the BMSC means MAX value in some period when charging is stopped (Battery Max Stopped Charge) and BNSC means MIN value in some period when charging is started(Battery Min Started Charge).

Yeah, this makes a lot of sense! Thanks for trying out, this makes me instantly buys the Macbook Air! I guess what we'll need to do is to integrate the changes back into AlDente.

Thanks a lot @smoothdvd for trying this out and reporting back, I guess this is where open source benefits most!

I'll read up AlDente's code to see if I know how to change it. I'm not very familiar with app development as I'm a low level bootloader engineer.

But I guess I can navigate it around if @davidwernhart doesn't have the time to do so.

Evertt commented 3 years ago

Hmm, I don't see yet how this helps. The way I understand it, the values you found function like some kind of log of what the last max value was at which you stopped charging? Isn't it? But we don't need a log-value, we need a value that dictates when the system will choose to stop charging. Don't you think?

Or did I misunderstand something? Did you in fact first change those values to some specific values and then see what would happen when you let your macbook charge?

thloh85 commented 3 years ago

Ahh I must have misunderstood then. I guess you interpret this correctly and I misinterpreted it.

Ryanfsdf commented 3 years ago

I guess we can rule out BMSC and BNSC then. That leaves BTRS and BUIC. I think it was mentioned before that BTRS is a new value. Does anyone know if BUIC is present on an Intel MacBook? Also, is there anyone with a BTRS or BUIC value that isn't 100?

smoothdvd commented 3 years ago

@Ryanfsdf BUIC means current battery percent. And on my M1 MacBook Air, only BTRS value is 100 now.

FreeWoRLD83 commented 3 years ago

@Ryanfsdf BUIC means current battery percent. And on my M1 MacBook Air, only BTRS value is 100 now.

Would you mind sharing how I can extract SMC data?

smoothdvd commented 3 years ago

@freestylemaster https://github.com/davidwernhart/AlDente/issues/52#issuecomment-734028300

Frederik441 commented 3 years ago

Can read value 100 on M1 Mac with key BTRS. I would like to try change it but can't. if I do "smc -k BTRS -w 65" the command is accepted but when reading it again it show still 100. Also tried to change it from recovery - terminal, but got wrong architecture failure from the smc command. Any clues?

smoothdvd commented 3 years ago

Finally, I saw this battery optimization status.

Screen Shot 2020-12-25 at 8 55 09 PM

BUIC value is 80.

Frederik441 commented 3 years ago

wow, please tell me how do you set the value 80 in BUIC?

Frederik441 commented 3 years ago

No, BUIC shows the actual battery charge procent. But how did you set the battery charging on hold?

davidwernhart commented 3 years ago

Oh, okay. I also got a little too excited about this for a moment. Anyway, as soon as someone manages to find the right key, I will make sure to have an update ready to go. Happy Holidays, David

Evertt commented 3 years ago

@smoothdvd just to check, did you just get this because you checked the checkbox in system preferences? Or did you get this because you experimented with setting SMC values?

smoothdvd commented 3 years ago

@davidwernhart @Evertt Yes, I checked the checkbox in system preferences.

I just checked the BUIC at that moment and found it's value is 80.

I tried to write BUIC but faild.

sudo ../smc -k BUIC -w 70
./smc -k BUIC -r
BUIC  [ui8 ]  80 (bytes 50)

Look it's a readonly key or "fake src".

FreeWoRLD83 commented 3 years ago

BUIC is the current battery percentage as commented before.

Screen Shot 2020-12-25 at 10 26 25 PM