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?

FreeWoRLD83 commented 3 years ago

Captured smc while battery was on hold by Apple's own Battery Health Management system.

This might be what we are looking for. Anyone knows if we had these 2 keys on Intel's?


Well, I spoke too soon. Looks like "B0RM" is "Remaining Capacity of Battery 0" and I believe Intel's already have it in SMC. However no idea what SBAR is. I cannot find it in any Intel SMC logs online

Full smc capture below if anyone would like to take a look. Again, this is when battery was on hold by Apple's BHM

output.log

Screen Shot 2020-12-27 at 6 33 26 AM

Frederik441 commented 3 years ago

-> freestylemaster, would you like to send us a smc dump after the charge on hold stops? So vi can do a diff.

FreeWoRLD83 commented 3 years ago

-> freestylemaster, would you like to send us a smc dump after the charge on hold stops? So vi can do a diff.

Here's the smc log with no hold - at 100%. Both B0RM and SBAR is at 4310

output_nohold.log

Screen Shot 2020-12-27 at 2 22 52 PM

smoothdvd commented 3 years ago

Maybe all SMC in Apple Silicon Mac is "virtual" and "readonly".

thloh85-intel commented 3 years ago

I guess we'll just have to wait for Apple to release the XNU kernel source, then we'll be able to take a look if they do expose it via ARM SMC callback

thloh85 commented 3 years ago

Speaking of which, did anyone tried writing to SBAR?

Frederik441 commented 3 years ago

Tried now, it looks like a down counting counter when on battery and up counting on power. Can't change the value with write another value to it.

Harry1993 commented 3 years ago

Could it be BLTA? When I run ./smc -l | grep "20 (", it gives me

BLTA  [si8 ]  -20 (bytes ec)
...and some other results...

However, when I turn off Optimized battery charging, BLTA is still -20 (maybe because there is another boolean SMC value for whether or not the option is turned on?).

user858753257 commented 3 years ago

When I understand the thread until now right , it doesent run on M1 chips ?

jiehaopenpen commented 3 years ago

Today I finally go charging on hold. I assume it will stop charging from now on if I always connect to power adapter?

Screenshot 2021-01-08 at 12 25 27
NoelOfficial commented 3 years ago

Today I finally go charging on hold. I assume it will stop charging from now on if I always connect to power adapter?

Screenshot 2021-01-08 at 12 25 27

How did you do that?

jiehaopenpen commented 3 years ago

Today I finally go charging on hold. I assume it will stop charging from now on if I always connect to power adapter?

Screenshot 2021-01-08 at 12 25 27

How did you do that?

I just almost always plugged it in. ;-)

timension commented 3 years ago

I have a different issue. My new MBA M1 shows that it uses power adapter and remaning time for full charge but the battery doesn't charge. Quite the opposite, the charge goes down as if the laptop was not connected to the adapter at all. This behavior happens from time to time and I'm not sure how I can provoke it. It doesn't help to pulls the cable out and put it back. Sometimes I have to restart the computer.

NoelOfficial commented 3 years ago

Today I finally go charging on hold. I assume it will stop charging from now on if I always connect to power adapter?

Screenshot 2021-01-08 at 12 25 27

How did you do that?

I just almost always plugged it in. ;-)

Ok great, I only have mine plugged in constantly for a few days so hopefully it will learn soon.

jiehaopenpen commented 3 years ago

I have a different issue. My new MBA M1 shows that it uses power adapter and remaning time for full charge but the battery doesn't charge. Quite the opposite, the charge goes down as if the laptop was not connected to the adapter at all. This behavior happens from time to time and I'm not sure how I can provoke it. It doesn't help to pulls the cable out and put it back. Sometimes I have to restart the computer.

That is truly weird, never happened to me yet

jiehaopenpen commented 3 years ago

Today I finally go charging on hold. I assume it will stop charging from now on if I always connect to power adapter?

Screenshot 2021-01-08 at 12 25 27

UPDATE: After I used my MacBook battery to 81%, it starts charging again.... So sad....

cordelac commented 3 years ago

I have a different issue. My new MBA M1 shows that it uses power adapter and remaning time for full charge but the battery doesn't charge. Quite the opposite, the charge goes down as if the laptop was not connected to the adapter at all. This behavior happens from time to time and I'm not sure how I can provoke it. It doesn't help to pulls the cable out and put it back. Sometimes I have to restart the computer.

I've had this issue once before - unplugging and putting it in the other USB-C slot worked for me.

Frederik441 commented 3 years ago

So summering up, all this reports shows two techniques from Apple that set the battery charging on hold: 1) timer based; it looks on the usage behaviour when plugged in and when run on battery 2) is triggered when MBA is always on power. Ad 1) somewhere must be information (time) stored when charging should start again. Always stops hold when battery goes below 80%. The external 30W power is more than enough for powering the MBA without touching (charging) the battery.

Vincent6182 commented 3 years ago

When I understand the thread until now right , it doesent run on M1 chips ?

Yes. There are different tools but none of them work on M1 at the moment:

smoothdvd commented 3 years ago

As I used the M1 more and more, the optimized battery charging got smarter and smarter.

timension commented 3 years ago

As I used the M1 more and more, the optimized battery charging got smarter and smarter.

What do you do for it? I have not be able to activate charging on hold yet. I have used the MBA for two months soon.

mattiasottosson commented 3 years ago

As I used the M1 more and more, the optimized battery charging got smarter and smarter.

What do you do for it? I have not be able to activate charging on hold yet. I have used the MBA for two months soon.

Same here. It's been a month since my last comment in the thread, an since then my MBP has been in clamshell mode hooked up to a external display 95% of the time. Since the corona outbreak, I mostly stay at home , so it's been off external power for maybe two / three times during this period. Optimized battery charging never kicked in. 🀷🏼

Can't understand why apple wouldn't give us an advanced mode with a slider similar to what electric cars have, or just a manual trigger for the 80% limit.

user858753257 commented 3 years ago

The tool running on the M1 MacBook but without the original function

smoothdvd commented 3 years ago

https://eclecticlight.co/2021/01/21/system-management-and-nvram-on-m1-macs/

hgo11 commented 3 years ago

https://eclecticlight.co/2021/01/21/system-management-and-nvram-on-m1-macs/

Thanks for sharing, do you also have details, how this could be used?

I only see the following capabilities:

pmset -g cap Capabilities for AC Power: displaysleep disksleep sleep womp standby powernap ttyskeepawake tcpkeepalive

Frederik441 commented 3 years ago

Still no idea how to set "charging on hold" manually, but on my M1 pmset shows this when it is on hold:

pmset -g batt Now drawing from 'AC Power' -InternalBattery-0 (id=5308515) 80%; AC attached; not charging present: true

and

pmset -g systemstate Current System Capabilities are: CPU Graphics Audio Network Current Power State: 4

So we have to find out how to set/force "not charging present" to true or "Current Power State" to 4.

hgo11 commented 3 years ago

I don't think "Current Power State: 4" is charging on hold - I have this state when the MBP is running on battery & also when on weak charger.

on the other hand I found this ancient article about pmset, seems there used to be a 'ChargeInhibit' mode. https://apple.stackexchange.com/questions/87924/how-to-disable-battery-charging

Frederik441 commented 3 years ago

You are right that PS 4 is normal (with or without charger connected) and has nothing to do with charging on hold. The 'ChargeInhibit' flag is gone in newer versions of OSX. I found at in 10.7 but not in 10.11, so it is ancient.

Robiemaan commented 3 years ago

Still no idea how to set "charging on hold" manually, but on my M1 pmset shows this when it is on hold:

pmset -g batt Now drawing from 'AC Power' -InternalBattery-0 (id=5308515) 80%; AC attached; not charging present: true

and

pmset -g systemstate Current System Capabilities are: CPU Graphics Audio Network Current Power State: 4

So we have to find out how to set/force "not charging present" to true or "Current Power State" to 4.

Please run smc -l and drop output here when its charging is on hold and another smc -l when it's not? This way we can compare against eachother?

FreeWoRLD83 commented 3 years ago

Still no idea how to set "charging on hold" manually, but on my M1 pmset shows this when it is on hold: pmset -g batt Now drawing from 'AC Power' -InternalBattery-0 (id=5308515) 80%; AC attached; not charging present: true and pmset -g systemstate Current System Capabilities are: CPU Graphics Audio Network Current Power State: 4 So we have to find out how to set/force "not charging present" to true or "Current Power State" to 4.

Please run smc -l and drop output here when its charging is on hold and another smc -l when it's not? This way we can compare against eachother?

smc output not on hold https://github.com/davidwernhart/AlDente/files/5745060/output_nohold.log

smc output when on hold https://github.com/davidwernhart/AlDente/files/5744496/output.log

Robiemaan commented 3 years ago

Still no idea how to set "charging on hold" manually, but on my M1 pmset shows this when it is on hold: pmset -g batt Now drawing from 'AC Power' -InternalBattery-0 (id=5308515) 80%; AC attached; not charging present: true and pmset -g systemstate Current System Capabilities are: CPU Graphics Audio Network Current Power State: 4 So we have to find out how to set/force "not charging present" to true or "Current Power State" to 4.

Please run smc -l and drop output here when its charging is on hold and another smc -l when it's not? This way we can compare against eachother?

smc output not on hold https://github.com/davidwernhart/AlDente/files/5745060/output_nohold.log

smc output when on hold https://github.com/davidwernhart/AlDente/files/5744496/output.log

Some differences I spotted: Acronym - nohold value - hold value

BMSC - 98 - 82
BNSC - 98 - 62
BTRT - 0 - 40
BUIC - 100 - 82
B0RI - 0 - 32782
BCMW - 41232 - 16
BCMV - 41744 - 528
BFCT - 0 - 1
BFLO - 0 - 17
SBAS - 98 - 81
SBAV - 13 - 12

(BTRS, an earlier candidate, value is 100 in both)

I don't have an intel based Mac. Can anyone cross out the acronyms that exist on an intel as well (those would likely not be our target)?

Frederik441 commented 3 years ago

My M1 values: BMSC, BUIC shows the actually charge value BNSC shows 78 on pwr and hold BTRT shows 40 on pwr and 15 on hold B0RI shows 32782 on pwr and hold BCMW, BCMV is counting up BFCT shows 1 on pwr and hold BFLO shows 17 on pwr and hold SBAS [flt ] (bytes 00 00 a6 42) both pwr and hold SBAV change value all the time

So still no clue!

tkreindler commented 3 years ago

I'd greatly appreciate this feature, if there's anything I can do to help as an M1 MBP user just let me know.

jenexgaming commented 3 years ago

In the meantime, I will use a 'hardware' work around involving a Gosund branded smart plug accessed/controlled via Amazon Alexa skill and I will simply set a recurring timer and/or activated the plug via voice command. It isn't going to automatically cut off the smart plug when the laptop charge gets to a specific percentage, but I can make sure it only begins charging an hour before I wake up (or earlier if I know the laptop battery was at a very low percentage.

I currently use the same setup for my wireless charging dock where I place my phone, ear buds, & watch each night before bed, because Apple's optimized charging never kicks in for me. My devices only charge when I want them to, and only for the length of time I want them too. Can also turn the smart plug off via the internet when I'm away from home if I forgot to do so before I left.

It's not perfect, but Apple has given us lemons without a recipe for lemonade so I'm making orange juice instead.

mwc-max commented 3 years ago

Actually I can confirm the workaround with the low wattage charger is working fine. I use my MacBook Pro M1 mostly plugged in. With a 12 watt charger the system runs just fine and the battery is not charging. Using this solution the computer is sitting at 53 percent for some days already. However it would be great when aldente is working for m1 πŸ˜ƒ

timension commented 3 years ago

Actually I can confirm the workaround with the low wattage charger is working fine. I use my MacBook Pro M1 mostly plugged in. With a 12 watt charger the system runs just fine and the battery is not charging. Using this solution the computer is sitting at 53 percent for some days already. However it would be great when aldente is working for m1 πŸ˜ƒ

I cannot so much about the electricity. But does it matter what charger is used? I mean the other two parameters: voltage and current? Is it sufficient requirement to find a 12W adapter or there is a risk to damage the computer if wrong voltage/amperage used?

I know there is a relation W = A*V, so the question is actually what voltage has to be used and if the wrong voltage can damage the computer.

hgo11 commented 3 years ago

Actually I can confirm the workaround with the low wattage charger is working fine. I use my MacBook Pro M1 mostly plugged in. With a 12 watt charger the system runs just fine and the battery is not charging. Using this solution the computer is sitting at 53 percent for some days already. However it would be great when aldente is working for m1 πŸ˜ƒ

I cannot so much about the electricity. But does it matter what charger is used? I mean the other two parameters: voltage and current? Is it sufficient requirement to find a 12W adapter or there is a risk to damage the computer if wrong voltage/amperage used?

I know there is a relation W = A*V, so the question is actually what voltage has to be used and if the wrong voltage can damage the computer.

I suggest you to use a 5V supply (2A). This is what is working fine for me.

mwc-max commented 3 years ago

Same here. 5V and 2A is working just fine

timension commented 3 years ago

I've just tried 5V, 2A charger from Huawei phone and it doesn't work. It says the computer is running on battery and the charge reduces as I use the computer.

mattiasottosson commented 3 years ago

Actually I can confirm the workaround with the low wattage charger is working fine. I use my MacBook Pro M1 mostly plugged in. With a 12 watt charger the system runs just fine and the battery is not charging. Using this solution the computer is sitting at 53 percent for some days already. However it would be great when aldente is working for m1 πŸ˜ƒ

I cannot so much about the electricity. But does it matter what charger is used? I mean the other two parameters: voltage and current? Is it sufficient requirement to find a 12W adapter or there is a risk to damage the computer if wrong voltage/amperage used?

I know there is a relation W = A*V, so the question is actually what voltage has to be used and if the wrong voltage can damage the computer.

If you use a regular USB-C / USB-C PD or USB-A charger, there's no need to worry about voltage. USB-PD enabled devices negotiate a power contract, or a handshake, when they’re plugged into each other. They discuss how much power the source can support, as well as how much power the device being charged can handle. The standard for USB-C devices without PD is 5V/3A, but for PD voltage is configurable (5/9/15/20 V) depending on the device and can go as high as 20V/5A. Then they settle on a compatible rate which both the supply and device support before the charging (or discharging) begins.

USB-A charges are always 5V.

jiehaopenpen commented 3 years ago

Actually I can confirm the workaround with the low wattage charger is working fine. I use my MacBook Pro M1 mostly plugged in. With a 12 watt charger the system runs just fine and the battery is not charging. Using this solution the computer is sitting at 53 percent for some days already. However it would be great when aldente is working for m1 πŸ˜ƒ

I cannot so much about the electricity. But does it matter what charger is used? I mean the other two parameters: voltage and current? Is it sufficient requirement to find a 12W adapter or there is a risk to damage the computer if wrong voltage/amperage used? I know there is a relation W = A*V, so the question is actually what voltage has to be used and if the wrong voltage can damage the computer.

If you use a regular USB-C / USB-C PD or USB-A charger, there's no need to worry about voltage. USB-PD enabled devices negotiate a power contract, or a handshake, when they’re plugged into each other. They discuss how much power the source can support, as well as how much power the device being charged can handle. The standard for USB-C devices without PD is 5V/3A, but for PD voltage is configurable (5/9/15/20 V) depending on the device and can go as high as 20V/5A. Then they settle on a compatible rate which both the supply and device support before the charging (or discharging) begins.

USB-A charges are always 5V.

Agree with the first part, but I believe USB A with PD can go up to 20v too πŸ˜„

timension commented 3 years ago

Those of you who made it work with 5V/2A chargers, do you use Apple charger? As I wrote above I use Huawei and it doesn't work, even if it has the same voltage. The computer behaves as it is not connected to anything.

Can it be that Apples products talk to each other better? Should I buy Apples charger? Actually it would solve the problem of full charged battery altogether.

mattiasottosson commented 3 years ago

If you use a regular USB-C / USB-C PD or USB-A charger, there's no need to worry about voltage.> > USB-PD enabled devices negotiate a power contract, or a handshake, when they’re plugged into each other. They discuss how much power the source can support, as well as how much power the device being charged can handle. The standard for USB-C devices without PD is 5V/3A, but for PD voltage is configurable (5/9/15/20 V) depending on the device and can go as high as 20V/5A. Then they settle on a compatible rate which both the supply and device support before the charging (or discharging) begins. USB-A charges are always 5V.

Agree with the first part, but I believe USB A with PD can go up to 20v too πŸ˜„

Heh, thats true. Same goes for QC i suppose. "Regular old plain none pd/qc/dash" USB-A charger then. ;)

hgo11 commented 3 years ago

Those of you who made it work with 5V/2A chargers, do you use Apple charger? As I wrote above I use Huawei and it doesn't work, even if it has the same voltage. The computer behaves as it is not connected to anything.

Can it be that Apples products talk to each other better? Should I buy Apples charger? Actually it would solve the problem of full charged battery altogether.

No I tried one from Ikea 5V 2A works fine and one from Lidl 5V 1,7A. Both only power the device without charging.

Harry1993 commented 3 years ago

In my case, even though macOS tells me "the battery is not charging", it is instead charging, but very slowly (it took 30 mins from 50% to 51%).

Edit 1: We can use coconutbattery to check the charging power. If it is too high (a few watts), we can attach some USB device (in my case, a USB sound card) to the other USB C port, which further lowers down the charging power (to 0.1 watt, for example).

timension commented 3 years ago

No I tried one from Ikea 5V 2A works fine and one from Lidl 5V 1,7A. Both only power the device without charging. Hmm, that's weird. Probably I should try a different charger. What does the computer say? Charging? On battery? On hold?

While I was writing Harry has answered that. :-)

cordelac commented 3 years ago

It depends on your use-case (Apps, I/O, brightness, etc)... Typically when I use the MBA I use somewhere between 12-18W, so if I use a USB-A charger (5V, 2.4A) then it still slowly depletes the battery.

My Anker 18W charger slowly charges the battery. I'd guess a 15W charger might be closest to freezing the battery in place.

timension commented 3 years ago

It depends on your use-case (Apps, I/O, brightness, etc)... Typically when I use the MBA I use somewhere between 12-18W, so if I use a USB-A charger (5V, 2.4A) then it still slowly depletes the battery.

My Anker 18W charger slowly charges the battery. I'd guess a 15W charger might be closest to freezing the battery in place.

Well, I do nothing special, just writing in this forum. :-) And the brightness is about 40 %. The battery is still depleting. And it won't charge either with the closed lid. It looks like the computer simply doesn't recognise the charger.

Edit I've changed the cord and now it works! πŸ‘ It says the computer is plugged but the battery doesn't charge. Edit 2 Actually, with the new cord it even works with old iPhone charger (5V/1A).

Frederik441 commented 3 years ago

To show the chargers capability run from terminal: pmset -g ac and to see the actually current flow from the charger (positive number) or from the battery (neg. number) run: pmset -g rawlog

user858753257 commented 3 years ago

Actually I can confirm the workaround with the low wattage charger is working fine. I use my MacBook Pro M1 mostly plugged in. With a 12 watt charger the system runs just fine and the battery is not charging. Using this solution the computer is sitting at 53 percent for some days already. However it would be great when aldente is working for m1 πŸ˜ƒ

Whcich workaround do you mean ?