BeardOverflow / msi-ec

GNU General Public License v2.0
134 stars 41 forks source link

Support for MSI Alpha 17 B5EEK #45

Closed mutchiko closed 1 day ago

mutchiko commented 1 year ago

hello, after installing the msi-ec package from the AUR, i'm not able to find the msi-ec folder at : /sys/devices/platform/

i also noticed a error massage when i boot that goes along the lines: "failed to start kernel modules", which only happens when install msi-ec

important info: system: garuda linux kernel version: 6.1.30-1-lts

BIOS:E17LLAMS.108 EC:17LLEMS1.106 I tried to do this : https://github.com/BeardOverflow/msi-ec/issues/18#issuecomment-1435733090

but i failed to get the dump file this way, however, after going with the first 3 steps, i was able to find the msi-ec folder in: /sys/devices/platform/ (it disappears after rebooting) and from there i manually copied the contents of ec_dump dump.txt

when i opened ec_dump using kate and spammed f5 i saw some values change in real time, i remember one of entries had 3 values for each time that i press fn+f8 to change the keyboard lights (they don't work)

other things to note with this laptop:

1- i had very poor performance when using any external monitor, so i had to disable resize-BAR from the bios.

2-the dGPU:RX6600M is having performance issues too, low wattage, high usage when playing games.

so im hoping to solve this issue IF i can get msi-ec to work

thanks.

teackot commented 1 year ago

Hi!

Here's what I've found so far:

mutchiko commented 1 year ago

super battery is supported, i remember having a mode like that in the msi app on windows, the charger was disconnected when i copied the dump file and i have tlp installed

cooler boost was not enabled

leds? i don't know what is that

keyboard is RGB, [0xf3] contains a value between 80 to 83 for every time i press fn+f8, and the lights are totally under control using open RGB, which shows that the device is: MSI MysticLight MS-1563 v0001

teackot commented 1 year ago

super battery is supported, i remember having a mode like that in the msi app on windows, the charger was disconnected when i copied the dump file and i have tlp installed

Okay! Though will be quiet difficult to figure out the exact address. So far we've found three different possible addresses.

cooler boost was not enabled

Yep, I can see that in the dump

leds? i don't know what is that

The LEDs on the sound mute and mic mute buttons. I suppose they don't light up when you press them

keyboard is RGB, [0xf3] contains a value between 80 to 83 for every time i press fn+f8, and the lights are totally under control using open RGB, which shows that the device is: MSI MysticLight MS-1563 v0001

We'll need to test that, because for some models it isn't enough to change the value in the EC to change the backlight

mutchiko commented 1 year ago

Okay! Though will be quiet difficult to figure out the exact address. So far we've found three different possible addresses.

ill figure which one is the real one, where can i find a list of all the addresses?

The LEDs on the sound mute and mic mute buttons. I suppose they don't light up when you press them

i didn't know that they even existed before, and you are right, they don't light up

i just figured something new, though i don't know what it is or what it does: [0x32] changes between 00 and 01 whenever i activate or disactivate cooler boost but of course it's not cooler boost

im still looking for any new entries so stay tuned,

teackot commented 1 year ago

ill figure which one is the real one, where can i find a list of all the addresses?

@glpnk has added a memory map, you can find it here

If you have Windows installed, I suggest you to use it to discover the addresses used by the MSI Center. There is a Windows app for it, you can find it here. It may or may not work for you.

mutchiko commented 1 year ago

I tried MsiEcRamEditor and it didn't work, so I'm using this and it seems to be working fine, however, i don't know what i should do exactly to figure out the values responsible for each option in the msi center app, so can you explain the steps that i should follow? Thanks

teackot commented 1 year ago

Switch the parameters in MSI Center and watch what changes in the RWEverything app when you do that. Some values in the EC are constantly changing (like CPU frequency, temperature, fan speed, etc), you can ignore them.

For example, if you switch between different battery thresholds, you'll see [0xEF] changing

glpnk commented 1 year ago

In RWEverything you can save current values and load it for comparison, changed values will be highlighted, but you need to press some key (i don't remember which) to show current values instead saved

mutchiko commented 1 year ago

Thanks for the help, here is a list of the things i confirmed MSI Alpha 17 B5EEK_230531_204144.txt

I'm open to any suggestions before i go any further

teackot commented 1 year ago

Thank you!

Your EC configuration is somewhat similar to MSI Alpha 15, but the set of available fan and shift modes is different.

• Display overdrive : ??? • Crosshair display (i dont care anymore)

These are interesting, but we have 0 info about these params and I'm not even sure they are related to the EC. Let's ignore them for now.

Explanation: i am very confused with shift mode in 0xF2, both of them seem to change when changing the scenario. i chose this to be super battery after looking at the memory map but i am totally lost here

I admit, our naming is pretty confusing =] The modes in the official MSI Center app actually change both parameters. We actually have no idea what exactly those params do. I think that the param we call 'super battery' is actually some sort of a GPU mode parameter, and the param we call 'shift mode' is a CPU mode parameter.

• Mic mute: stuck! can't turn it off to check! God knows who is listening on the other side

Haha, well knowing the speaker mute address, we can figure out the mic mute address because 2b and 2c are the only available options for these LEDs

So, this is the memory map of your EC:

parameter address comment
charge control 0xef -
webcam 0x2e ? -
fn/win swap 0xbf -
cooler boost 0x98 -
shift mode 0xf2 options: C0, C1, C2, C4
super battery 0xd5 options: A0, A1, A4, A5; AMD related?
fan mode 0xf4 curious, seems like only the higher 4 bits matter?; options: auto, silent?, advanced
speaker mute 0x2c -
mic mute 0x2b -
keyboard backlight - RGB with 4 different styles, out of scope of this driver :(
teackot commented 1 year ago

Now, can you please switch the webcam LED on and off and see how the [0x2E] changes (i.e. the values for on and off)? Same for the speaker mute LED at [0x2C]

Edit: oh, and also fn/win swap

mutchiko commented 1 year ago

So i think that i have figured out a good chunk of values now, i also think that i have figured out the 'super battery' and 'shift mode' confusion, however, i won't confirm/change anything until tomorrow.

I will be taking into account your previous 2 comments to update the list with more entries and better naming to fit the actual project too.

What i need now is to know why does 'super battery' accepts only one value in the memory map? It must be CPU governors that get applied when changing modes (i don't know if the windows kernel works like that too)

But for me personally, i think 'super battery' is not the right thing to call it (at least in my case)

teackot commented 1 year ago

I will be taking into account your previous 2 comments to update the list with more entries and better naming to fit the actual project too.

Okay, thanks!

What i need now is to know why does 'super battery' accepts only one value in the memory map

That's because we didn't have much information about it until some recent laptop support requests. It should use a list of modes, like shift_mode and fan_mode params do.

i think 'super battery' is not the right thing to call it

I agree

mutchiko commented 1 year ago

As promised, here is the updated list: MSI Alpha 17 B5EEK_230602_134249.txt

And here is what i managed squeeze out of the MSI app, very interesting stuff, and in the same .zip file you'll find a few screenshots for the EC dump, i couldn't save it normally so i had to adapt: MSI Alpha 17 B5EEK.zip

You'll find some even more interesting changes between the linux dump and the dump on windows (which explains the tons of problems i have with this laptop on linux).

glpnk commented 1 year ago

MSI naming is really strange, now i`m writing comparison table for supported firmwares and i really surprised that we already supporting Alpha 15 B5EE / B5EEK [158LEMS1] #16, but you model is Alpha 17 and can be not compatible

teackot commented 1 year ago

I think the addresses are (mostly?) compatible, not sure about allowed values at them yet. Alpha 15 even has the 'super battery' parameter at [0xD5], just like Alpha 17, we just didn't add it yet.

teackot commented 1 year ago

Note: [0xED] is VERY WIERD! It changes the value to [0xC0] for unknown reasons, for example, when i press the webcam block button it changes whatever value to [0xC0].

About [0xED], this address is related to ACPI events, it will also change its value when you press the brightness keys or plug/unplug the type-c charger

mutchiko commented 1 year ago

@glpnk Well you can't blame anyone but MSI, it's not just the naming we're talking about here.

There was 6 months gap between the release of the Alpha 15 and the Alpha 17 ,in which MSI received alot of complaints that the Alpha 15 overheats itself and shuts down when charging after gaming for a bit.

It seems to me that they did some modifications to the EC to avoid such problems in later releases.

What is most important here is to look for the buid date for each firmware release (i can't find much info about the Alpha 15) but it seems that there is only one month between the first (and only) firmware release for the Alpha 17 and the latest update for the Alpha 15

glpnk commented 1 year ago

I'm not blame anyone and I'm just found that devices from the same generation had different EC name, but could be compatible, check Katana GF66

UPD: also they use different names for EC and like EMS, IMS, AMS.

mutchiko commented 1 year ago

I want to clear some confusion about fan_mode in [0xF4]:

Changing the scenario (shift mode) is one of 2 ways to have some sort of "control" over the fans, which gives the control to whatever is responsible for fan speed ( MSI app or something else)

The other way is to set the scenario to USER, in which i can control the performance and fan speed, under fan speed there is only 3 options:

Auto = [0x20]

Advanced = [0xA0] (No matter how you change the dan speed)

Cooler boost (doesn't change anything)

To even add more information: When editing the value in [0xF2] (shift mode) From [0xC2] (eco mode that turns off the fans) to [0xC1] (sport mode that turns on the fans) The fans will kick in as if i changed the scenario in the MSI app. And the actual fan_mode value doesn't even change!

So to my understanding there is no way to control the fans directly from the EC, but since it does already control the fans by itself then there isn't much pressure to get fan_mode support in the driver

mutchiko commented 1 year ago

i'm back at it again and here is what i found:

real time CPU fan speed at [0x71] those are the fan speed steps that can be controlled in advanced mode:

fan speed: 0% = 00 / 100% = 64

in [0x78] there should be another step but it is not controllable by the MSI app and is stuck to 55

real time GPU fan speed at [0x89]

fan speed: 0% = 00/ 100% = 64

just like before, the last step at [0x90] is stuck at 55

glpnk commented 1 year ago

your fan curve address seems default, check https://github.com/dmitry-s93/MControlCenter/blob/53a8df677bc5df30813f935f3e79a7faf12708a6/src/operate.cpp#L64

mutchiko commented 1 year ago

i just tried it and it is very weird: CPU fan can't be controlled but the GPU fan seems to be fine it can mess up the charging LED even if the laptop is not plugged to the power, though it only happens when i click on the FN/super switch

shift mode and backlight are not supported it can report the right temperatures for both the CPU and the GPU it also reports fan speed for both fans but sometimes it gives me 2 million rpm so yeah

glpnk commented 1 year ago

i experimented with charging registers (addresses) on my laptop and found

name address, bit, value description
FN-lock get 0x2b bit 3 read only
cooling profile 0x72-77, 0-150% in hex advanced fan mode, but works in other modes
charging state 0x30-31, DANGEROUS!!! something related to charging, setting 0x30 bit 0 to HIGH with unplugged charger triggers charging state with powering on charging led and charging mark on windows
realtime fan RPM 0xcd, around 4e-d2, inverted value proportional to EC cooler RPM in HWINFO64 (max 6128 = 0x4e, min around 2k = 0xd2)
fan enabled 0x33 bit 3
battery level 0x42 value in %

also RPM in MControlCenter is calculated like [CONST / rpm register value]

look like EC reports cooler RPM in time per rotation

mutchiko commented 1 year ago

real time CPU temperature at [0x68]

real time GPU fan speed at [0x80]

i'm not sure about any of these since i can't find a way to test them out

mutchiko commented 1 year ago

@glpnk what's your laptop?

glpnk commented 1 year ago
Model Class EC name Link
Modern 14 C5M Business 14JKEMS1 MSI support

also I have problems with suspend (S3 and s2idle state), SSD dont power on after boot on arch and ubuntu like OS

but if laptop is booted from external ssd, internal ssd powering on after second and next sleep-resume cycles

mutchiko commented 1 year ago

i find it weird that your laptop doesn't support super battery, what values do you see in [0xD5]?

glpnk commented 1 year ago

Yeah, its weird but in super battery mode in MSI app EC values not changed

Settings are the same as in silent (or eco, dont remember) mode but without silent cooler profile

Also how super battery setting look like in app? Mine look like one of power profiles like [turbo, silent, SB, eco]

mutchiko commented 1 year ago

how super battery setting look like in app?

Well, it's kind of complicated, i still don't know what is 'super battery' or what it does in this driver, however in the MSI app it's a "usage scenario" which means it's a part of shift_mode (eco)

But if i look at [0xD5] i see 4 values: A0, A1, A4, A5. @teackot says that it might be related to GPU mode or something, but changing it while stress testing both the CPU/GPU doesn't change anything.

mutchiko commented 1 year ago

@teackot you were right about super battery mode, it is indeed related to the GPU, i messed up and wrote somthing instead of A4 and my laptop screen turned off, but the external monitor kept working just fine, windows recognised the changes and moved all open windows to the other screen, so after trying things in the BIOS i found out that under AMD -> CBS -> GFX configuration there is an option about how the iGPU should work globally, and changing it from auto to anything else (ex: UWM_iGPU gaming mode) will make the super battery value stick to A4 even after changing shift mode in the MSI app

mutchiko commented 1 year ago

Now im in a trouble, i chose iGPU_disable in the bios and my laptop screen doesn't trun on at all! Even when booting and going to the bios, nothing shows up on both screens, so i need a way to reset my bios but there isn't any CMOS battery, i searched all over the Internet and can't find a solution, what should i do?

glpnk commented 1 year ago

Try to remove battery for long time like 5 minutes, or search for bios reset hole on the bottom of laptop if you had one, or press power button for 30+ seconds

UPD: or read instruction for your laptop, may be it contain something about bios reset

mutchiko commented 1 year ago

@glpnk i tried t all of them, the power button solution is the only one that worked for me, thanks.

glpnk commented 1 year ago

Great. I think I`m read about it in manual

mutchiko commented 1 year ago

So i installed the driver on linux-zen 6.3.8 but i don't know how to use it, i can find the files at sys/devices/platform/msi-ec but when i try to edit something like shift_mode i can't save the file (even with permissions), is that how you actually do it?

Update: it is causing the laptop to hang at random times which is weird, because i verified all the addresses i found in https://github.com/BeardOverflow/msi-ec/pull/47/files/5cdea3f7fcab09d19715455af1f5684df5a74a8c..1e8c9efc1d094ace27e539d023bc8f7b5a1c319a and they are correct.

Any idea what's the reason for that? Thanks

mutchiko commented 1 year ago

Today i checked the official MSI website to see if there is any updates and i saw a BIOS update version E17LLAMS.10B has been released 5 days ago. Changelog says: Fix the issue of the USB-A/USB-C port not connecting to the phone.

Should i update?

teackot commented 10 months ago

Okay, I finished the PR adding a config for your laptop. I didn't add "super battery" because the driver still doesn't support it.

when i try to edit something like shift_mode i can't save the file

I usually write into the files like this: echo on | sudo tee /sys/devices/platform/msi-ec/cooler_boost

No idea about your laptop hanging though

i saw a BIOS update (...) Should i update?

Yeah, why not, it won't harm

mutchiko commented 10 months ago

@teackot woah I didn't expect you to return to this issue, but i already updated the bios and it seems that it changed a lot of things, for example: shift mode values for comfort and sport are the same now! And shift mode value will change the super battery value automatically (but not vice versa).

I've lost some addresses for fan mode and gpu/cpu fan speed, so i highly suggest that the pull request stays as a draft for now

teackot commented 10 months ago

I just had some stuff to deal with this summer, I hope I'm back =)

Okay then, I'll leave it as a draft until we fully figure it out

mutchiko commented 10 months ago

I'm still trying to figure out the rest, but it seems that im getting nowhere with all these blue screens of death on windows. I wont be able to fully test everything before the first release candidate for 6.6 kernel becomes available, though i wouldn't mind it if the driver is ready in linux 6.5

mutchiko commented 10 months ago

I hope you enjoyed your vacation, while you were away, i was learning C and made many attempts to make super_battery use 5 modes instead of a single mask.

Now that you're back im going to learn a lot of stuff from your commits!

teackot commented 10 months ago

Thanks! Good luck learning C!

mutchiko commented 10 months ago

Im back again, it seems that not a lot of things have changed, just shift mode and fan mode, i want to test my changes so i tried to install the driver on linux zen 6.4.11 but it gives me an error at install: modeprobe: could not insert msi-ec: operation not supported

How do i fix this?

Update: I managed to load the driver with "sudo make load" but this is not an actual install

mutchiko commented 10 months ago

@teackot Alright, i tested the driver with your last commits, here is what needs to be changed:

shift_mode:

fan_mode: to be completely removed (the older address shows weird numbers when changing fan profiles in the MSI app).

Other than that everything seems to be correct i tested/verified everything i could, and just to keep it clear for any future reader: this is bios E17LLAMS.108 and every bios update changes some of these values on this laptop.

mutchiko commented 10 months ago

By the way this helped me a lot : msi ec.pdf

teackot commented 10 months ago

Im back again, it seems that not a lot of things have changed, just shift mode and fan mode, i want to test my changes so i tried to install the driver on linux zen 6.4.11 but it gives me an error at install: modeprobe: could not insert msi-ec: operation not supported

That's because the in-tree kernel version of the driver doesn't have a config for your laptop. I still haven't figured out how to permanently enable the github version of the driver on kernels >= 6.4

SM_COMFORT_NAME: to be removed. technically, this mode still exist, but it needs super battery value to be set to [0xa4]

I want to completely redesign this Shift Mode / Super Battery thing. We need both parameters to be changed together, like you described.

msi ec.pdf

That's cool! I'll use it when we will be implementing the fan curve. And we also need to fix the rt_fan_speed, because it doesn't work on all models

mutchiko commented 10 months ago

That's because the in-tree kernel version of the driver doesn't have a config for your laptop.

too late! i already messed up the kernel and re-installed the system.

I want to completely redesign this Shift Mode / Super Battery thing.

first we need to know what they are before we give them new names. my best guess is that one of them tells the bios what fan curve to use, and the other should have something to do with intel p-state and AMD p-state because they both have 4 states in most processors (it tells the firmware what the power/performance ratio should be). and since amd support for linux is very late, i can't properly test the driver before linux 6.6 is available.

That's cool! I'll use it when we will be implementing the fan curve.

i really want to credit who made it, but i don't know where i found it.

And we also need to fix the rt_fan_speed, because it doesn't work on all models.

that's because it does not update the values in real time. sometimes it gets stuck to a value even when the fan is off (usually it gets stuck to the first step in the fan curve)

teackot commented 10 months ago

From what we know:

Fan mode, in your case, is controlled by the [0xf4] address. Switching the fan mode to silent indeed makes the fan work noticeably quieter.

The one we call 'Shift Mode' is at [0xf2], this is the one that may be related to the CPU's p-states

And the one we call 'Super Battery' is related to the GPU

We still don't know what exactly the last two do, right?

mutchiko commented 10 months ago

Fan mode, in your case, is controlled by the [0xf4] address.

it WAS there, now it is not anymore, sure the value changes when i change fan_mode, but it just gives me garbage numbers, now lets say that it was working fine, there is no silent mode; only auto and advanced (not counting cooler boost) , on top of that, once we change shift_mode the value in fan_mode returns to auto and STAYS THE SAME NO MATTER WHAT shift_mode YOU USE.

The one we call 'Shift Mode' is at [0xf2], this is the one that may be related to the CPU's p-states

that is my point, and i can't disapprove it at the moment, so i will stick with it for now.

the one we call 'Super Battery' is related to the GPU.

now that i remember, writing directly into its address won't have any effect on shift mode,and no matter the value i choose, it wont affect the fans too, unlike shift_mode which affects the the fan curve when changed directly (and with that i just disapproved my last point).

but i don't think that the GPU is related to super_battery, and if you get this idea from my previous comments, i was simply confused by the unholy amounts of bugs i encountered with this laptop. now it makes more sense that super_battery is the one that is responsible for the performance and shift_mode is responsible for changing the fan curve.

can it get more confusing than this?