BeardOverflow / msi-ec

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

Add support for MSI Modern 15 B7M #89

Closed CosmicRaptor closed 1 month ago

CosmicRaptor commented 8 months ago

Laptop model

Modern 15 B7M

EC firmware version

15HKEMS1.104

EC memory dump

No response

GPU

iGPU only (AMD)

Is your keyboard RGB?

No (single color)

Additional context

I'm on windows and willing to do an EC dump if someone can guide me, I never did this before.

CosmicRaptor commented 8 months ago

EC Dump as below


 | _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _a _b _c _d _e _f
-----+------------------------------------------------
0x0_ | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x1_ | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x2_ | 00 00 00 00 00 00 00 00 00 00 00 80 e0 06 09 0b
0x3_ | 03 03 00 0d 51 0a 05 00 f4 0c 88 2c 4b 01 80 00
0x4_ | 16 0d 38 00 49 0c 9b 08 ca 06 e5 2f 1e 0c fa 32
0x5_ | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x6_ | 00 00 00 00 00 00 00 00 5f 00 36 3a 3e 42 4d 5d
0x7_ | 78 64 00 32 3c 41 4b 4b 64 64 03 02 02 02 03 05
0x8_ | 00 00 32 3c 46 52 5a 5d 64 00 2d 32 41 48 50 55
0x9_ | 64 00 03 05 05 06 03 03 06 19 73 02 00 66 00 00
0xa_ | 31 35 48 4b 45 4d 53 31 2e 31 30 34 31 30 32 34
0xb_ | 32 30 32 32 31 30 3a 35 38 3a 31 39 49 0c 00 08
0xc_ | 00 07 30 0f 00 9e 40 00 00 df 00 00 00 73 14 00
0xd_ | 00 00 00 00 70 a0 00 00 3b a0 5f 80 00 17 0a 1f
0xe_ | e2 02 00 00 10 00 00 00 00 00 38 30 00 b8 00 bc
0xf_ | 00 00 c1 81 0d 00 05 11 15 19 00 00 00 00 00 00
CosmicRaptor commented 7 months ago

Okay, here's what I tested so far.

Backlight off: image

Backlight max: image

Backlight medium: image

Backlight low: image

Based on this, this bit seems to be the one handling backlight. (F003? Am I saying it right?) image

Moving on, here's more findings

"AI" mode: image

Performance mode: (fan speed auto, cooler boost off) image

Balanced mode: image

Silent mode: image

Super battery: image

CosmicRaptor commented 7 months ago

Best for battery(60% limit) mode: image

Balanced battery mode(80% limit): image

Best for mobility(100% charge limit): image

Above tests were conducted while plugged in.

CosmicRaptor commented 7 months ago

Also, a few of the EC addresses keep changing on every refresh even if I am not doing any changes. Is that because of the RTC or something like that?

CosmicRaptor commented 7 months ago

This byte handles mute/unmute image

This one is for toggling the mic image

This one toggles the webcam image

This one toggles the Fn+Esc LED image

glpnk commented 7 months ago

@CosmicRaptor thanks for your report and analysis

F003? Am I saying it right?

It actually F3, because row value is F_, and column is _3

Also, a few of the EC addresses keep changing on every refresh even if I am not doing any changes. Is that because of the RTC or something like that?

Yeah you kinda right, but someone is temperature, cooler RPM, other, I think, may be related to some voltage, power or other internal logic, something may be related to RTC. Earlier in dmesg I have some messages related to EC with RTC phrase like 'method not found'

CosmicRaptor commented 7 months ago

@CosmicRaptor

Also, a few of the EC addresses keep changing on every refresh even if I am not doing any changes. Is that because of the RTC or something like that?

Yeah you kinda right, but someone is temperature, cooler RPM, other, I think, may be related to some voltage, power or other internal logic, something may be related to RTC. Earlier in dmesg I have some messages related to EC with RTC phrase like 'method not found'

Oh yeah a few of those absolutely are the cpu frequency, temperature and fan speed. I'm just not sure which. I'm also not sure if the RTC is in the EC or not.

glpnk commented 7 months ago

About RTC - it does not matter, read wiki to see which values are required and supported. https://github.com/BeardOverflow/msi-ec/wiki/List-of-parameters (partially ended)

Try to find similar config, and check if values the same

CosmicRaptor commented 7 months ago

How would I figure out the addresses for the battery modes? Lots of addresses change on switching the modes and I am not sure which one does what.

This is basically everything that I found out so far.


mic LED: 0x2b
speaker mute LED: 0x2c
Fn + Esc LED: 0x2b (not sure!)

keyboard backlight: 0x3f (80=off, 81= min brightness, 82= mid brightness, 83= max brightness)
glpnk commented 7 months ago

B7M is 17 inch or amd 7 gen laptop? I think you can check values from B5M (unfinished) or A5M pr#66 or C5M.

You can document unnecessary values if you want or just check all addresses from diff's above or wiki.

CosmicRaptor commented 7 months ago

B7M is 17 inch or amd 7 gen laptop? I think you can check values from B5M (unfinished) or A5M pr#66 or C5M.

You can document unnecessary values if you want or just check all addresses from diff's above or wiki.

It is 15 inch ryzen 7000 laptop. Mine has a ryzen 5 7530U I will check those PRs and compare, thank you.

CosmicRaptor commented 7 months ago

image I think only these parameters change on changing the shift modes. This seems to match with the C5M so far from what I can tell. Even the fan mode bit appears to be the same.

glpnk commented 7 months ago

f2 - shift (like C5M) f4 - fan mode - check is extended/manual fan curve is available (value may be 8d or any 8_)

f6-f9 - I think are unnecessary

DONT Change unknown values because sometimes your laptop may die

CosmicRaptor commented 7 months ago

f2 - shift (like C5M) f4 - fan mode - check is extended/manual fan curve is available (value may be 8d or any 8_)

f6-f9 - I think are unnecessary

DONT Change unknown values because sometimes your laptop may die

There is a 6 point manual fan curve supported under the performance mode. I however do not use it, the stock feels good enough. Is it necessary to test that?

CosmicRaptor commented 7 months ago

In charge control, there are a couple of offsets mentioned. What do those do? I have not found those for mine yet. image

I have also not found the addresses for the range_min and range_max

glpnk commented 7 months ago

There is a 6 point manual fan curve supported under the performance mode

Only f4 value, curve addresses seem the same in all models

In charge control, there are a couple of offsets mentioned. What do those do? I have not found those for mine yet.

offset seems default too, I think it was there since first releases, if values in range 0-100 in decimal, you not need to change nothing

check that 0xEF address set to next values through battery safe modes (ignore AI mode if present): 0x3C (60%), 0x50 (80%), 0x64 (100%)

CosmicRaptor commented 7 months ago

check that 0xEF address set to next values through battery safe modes (ignore AI mode if present): 0x3C (60%), 0x50 (80%), 0x64 (100%)

the values do not match. image

glpnk commented 7 months ago

100% limit = E4

0xE4=228, 100=0x64, 0xE4-0x64= 0x80 or 128 in decimal

So value has offset, for my model (C5M) value for 100% charge is also E4.

If you copied this section from my config - they match

CosmicRaptor commented 7 months ago

100% limit = E4

0xE4=228, 100=0x64, 0xE4-0x64= 0x80 or 128 in decimal

So value has offset, for my model (C5M) value for 100% charge is also E4.

If you copied this section from my config - they match

Sorry I'm new to this, are you saying that this is an exact match with the C5M?

glpnk commented 7 months ago

Battery offsets and range values are the same for all currently supported models.

Address 0xEF is similar for some models. And it similar to the B5M and C5M that I referenced before

I think (but not prove) that addresses is nearly identical for all models in each device class (like "business" or "gaming") within the some production date range, so you can use similar models for reference and prove it similarity after research.

CosmicRaptor commented 7 months ago

Battery offsets and range values are the same for all currently supported models.

Address 0xEF is similar for some models. And it similar to the B5M and C5M that I referenced before

I think (but not prove) that addresses is nearly identical for all models in each device class (like "business" or "gaming") within the some production date range, so you can use similar models for reference and prove it similarity after research.

You are correct. Most of the values are matching, as I've found here. I think my work is done then. What else am I supposed to do? I'm not a C programmer so I cannot file a PR.

glpnk commented 7 months ago

I think my work is done then.

Thank you. Please share which config to use as reference and which addresses are different, unknown and untested (if they exists). You can share your notes as is or as edited config.

Do you want to test this config on linux?

CosmicRaptor commented 7 months ago

I think my work is done then.

Thank you. Please share which config to use as reference and which addresses are different, unknown and untested (if they exists). You can share your notes as is or as edited config.

Do you want to test this config on linux?

Okay, I'm using the C5M as reference. Here's my entire findings msi-ec-b7m.txt

I would like to try this on linux, to make sure everything works.

glpnk commented 7 months ago

@CosmicRaptor, sorry for late reply, but I've seen your previous reply, before you wrote about checking

Link to fork

Download with

git clone -b 15HKEMS1 https://github.com/glpnk/msi-ec.git

Make and load

make
sudo make load

If you got error after sudo make load run (your kernel can contain older release of this module)

sudo make reload

Or install with DKMS

sudo make dkms-install
CosmicRaptor commented 7 months ago

Thank you for creating the PR! I just tested it out on fedora. All fan modes work. The speaker mute LED is not working. Need to investigate that. Battery charge thresholds are working. Cooler boost works too.

Also, my brightness keeps changing randomly as soon as i use a function key. Any fix to this?

glpnk commented 7 months ago

About mute LEDs - it can be broken triggers t volume levels, on POP OS only mic mute works, but I can lit audio mute LED manually.

Copy each command separately.

# off audio mute LED
echo 0 | sudo tee /sys/class/leds/platform::mute/brightness

# on audio mute LED
echo 1 | sudo tee /sys/class/leds/platform::mute/brightness

# off mic mute LED
echo 0 | sudo tee /sys/class/leds/platform::micmute/brightness

# on mic mute LED
echo 1 | sudo tee /sys/class/leds/platform::micmute/brightness

About brightness changing - it's a bug in graphics card or other driver - you need to blacklist some driver. For now - don't use keyboard for brightness control

I think this helped me with brightness issue https://discussion.fedoraproject.org/t/79613/8 But I think that I changed some other file, because this is overwritten after updates

CosmicRaptor commented 7 months ago

Yes, those LED commands work. So this is a weird bug I guess.

The fix you gave me is for xorg, I am unsure if that will work on GNOME Wayland. Will have to try. I think I'm done then, I'll finally install linux on this laptop. Thank you for your time!

glpnk commented 7 months ago

If you find fix for Wayland please share it.

Checklist:

Config Status
Charge control
Webcam block
FN-Win swap
Cooler boost
Shifts ❓✅
Super battery
Fan mode
CPU temp/speed
GPU
mute LEDs
Keyboard backlight

Please check question marked modes from checklist (I'll reply how to test this later)

CosmicRaptor commented 7 months ago

Checklist: Config Status Charge control ✅ Webcam block ✅ FN-Win swap ✅ Cooler boost ✅ Shifts ✅ Super battery ✅ Fan mode ✅ CPU temp/speed ✅ GPU ❌ this laptop has iGPU so this is irrelevant mute LEDs ✅ Keyboard backlight ✅

glpnk commented 7 months ago

Awesome

CosmicRaptor commented 7 months ago

I have a really weird issue, not sure if this is related to my hardware or the driver.

Whenever my fans spin up from 0%, there's a click sound. It's almost like the sound of a CD drive getting ejected. It's not very loud but noticeable. Do you or anyone else have this issue as well?

I do not recall having this issue on windows or on live boot. Will test it on live boot later to confirm it's not hardware related.

glpnk commented 7 months ago

I think I have same sound, but it quite silent and at the same time annoying. Some people change idle fan curve value to lowest RPM possible, but I think is too fast. But it "fixes" continuous start-stopping.

On Linux CPU on idle could be colder, so it runs on passive cooling.

CosmicRaptor commented 6 months ago

Tiny issue ive been having, on every boot the shift mode is reset to "comfort" is this a known issue or I have the incorrect EC values?

glpnk commented 6 months ago

@CosmicRaptor No, it's normal behavior. Some explanation.

In my experience, battery charge threshold not resetting or restored by some system component.

glpnk commented 4 months ago

@CosmicRaptor: Also, my brightness keeps changing randomly as soon as i use a function key. Any fix to this? @glpnk: I think this helped me with brightness issue https://discussion.fedoraproject.org/t/79613/8 @CosmicRaptor: The fix you gave me is for xorg, I am unsure if that will work on GNOME Wayland. Will have to try. I think I'm done then, I'll finally install linux on this laptop. Thank you for your time!

Hi, @CosmicRaptor, do you found how to fix brightness issue on Wayland? I think the simplest way is somehow disable event source. Maybe you know fix?

UPD: https://askubuntu.com/a/1487963 but on different Wayland version this prop could have different name

[Video Bus Spooky Ghost]
MatchName=*Video Bus*
AttrEventCodeDisable=EV_KEY:0xE0;EV_KEY:0xE1;
CosmicRaptor commented 3 months ago

@CosmicRaptor: Also, my brightness keeps changing randomly as soon as i use a function key. Any fix to this? @glpnk: I think this helped me with brightness issue https://discussion.fedoraproject.org/t/79613/8 @CosmicRaptor: The fix you gave me is for xorg, I am unsure if that will work on GNOME Wayland. Will have to try. I think I'm done then, I'll finally install linux on this laptop. Thank you for your time!

Hi, @CosmicRaptor, do you found how to fix brightness issue on Wayland? I think the simplest way is somehow disable event source. Maybe you know fix?

UPD: https://askubuntu.com/a/1487963 but on different Wayland version this prop could have different name

[Video Bus Spooky Ghost]
MatchName=*Video Bus*
AttrEventCodeDisable=EV_KEY:0xE0;EV_KEY:0xE1;

You are correct, the same fix works.

teackot commented 1 month ago

Closing, since #91 was merged

@CosmicRaptor thank you for providing the info! You can now switch to the main repo, feel free to open a new issue if you find any problems or have any suggestions

CosmicRaptor commented 1 month ago

Sure thing! Thanks for merging