BeardOverflow / msi-ec

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

MSI Modern 15 A5M support from 6.4 kernel #57

Closed benitozh closed 1 month ago

benitozh commented 11 months ago

Greetings everyone,

I've been using my own laptop daily for personal use, an MSI Modern 15 A5M, since last year, with YoyPa's ISW-Modern installed in order to have basic automated fan control on my laptop. I'm running on Endeavour OS.

Recently, I tried to install the AUR package msi-ec-git, in order to benefit from a more advanced version of the ISW-Modern package, which is rather limited in terms of functionality. Unfortunately, this never worked on my laptop, so I decided to wait for msi-ec to be merged with the linux 6.4 kernel.

Now that version 6.4 of the linux kernel has been released, I tried to see if it now worked on my laptop. Unfortunately, when I go to /sys/devices/platform/, there is no "msi-ec" folder. I tried to install the package from the tutorial explained on the main page of the project, but still no correspondant folder seems to exists (even in hidden folders).

I'm wondering if anyone involved in this project could gently help me in order to get this module working on my laptop. Right now, ISW-Modern doens't seems to function at all with kernel 6.4.

Any tips would be greatly appreciated, i'm still new to Linux even though i've been making a distro tour since two years now that made me learn a few things

rottenpants466 commented 11 months ago

Same problem here, kernel 6.4.

benitozh commented 11 months ago

Thanks for the reply, I've tried since my last text both Fedora and NixOS in addition to my daily endeavourOS install, I can't even see anything in the designated folders after msi-ec install.... It's a shame that the MSI Modern series doesn't seem to be supported by the project yet. I'm always up for a little help, if anyone is interested in porting msi-ec to the Modern A5M model.

ushinnary commented 10 months ago

Same problem, still kernel 6.4. E155LAMS.114. Sadly, i have no idea how can we try to put our model somewhere by patching or something... OS: Fedora Silverblue

glpnk commented 10 months ago

DISCLAIMER: I'm not responsible for any broken hardware and other damage! Reading EC is safe

Do you have Windows installed? You can use RWEverything to get EC values in real time. Also check config for C5M (14JKEMS1) model and use it as reference (at least its the same generation and family ~but AMD~). Make EC dump with debug mode and reply here, addresses can be the same. Compare with this.

If you sure enough that configs are same, add your EC version to list *ALLOWED_FW_9 for test. I don't know right way to commit this changes - as new model with own config or just adding new EC version to list.

teackot commented 10 months ago

Hi!

The reason why not all laptops are supported yet is that they all have different EC configurations, not documented anywhere. In order to support a laptop we need some feedback from its users.

Get the latest version of the driver from this repo, build it (make) and load it in the debug mode (sudo make load-debug)

Run cat /sys/devices/platform/msi-ec/debug/fw_version to get your EC FW version Run cat /sys/devices/platform/msi-ec/debug/ec_dump to get an EC dump And attach them here

Like @glpnk said, if you have windows you can use RWEverything to see what EC addresses are modified when you toggle different settings in the MSI Centre

It won't damage your hardware, it only reads from the EC. Just don't write random stuff into random addresses using msi-ec/debug/ec_set

rottenpants466 commented 10 months ago

Hi!

The reason why not all laptops are supported yet is that they all have different EC configurations, not documented anywhere. In order to support a laptop we need some feedback from its users.

Get the latest version of the driver from this repo, build it (make) and load it in the debug mode (sudo make load-debug)

Run cat /sys/devices/platform/msi-ec/debug/fw_version to get your EC FW version Run cat /sys/devices/platform/msi-ec/debug/ec_dump to get an EC dump And attach them here

Like @glpnk said, if you have windows you can use RWEverything to see what EC addresses are modified when you toggle different settings in the MSI Centre

It won't damage your hardware, it only reads from the EC. Just don't write random stuff into random addresses using msi-ec/debug/ec_set

I think the issue is that there is no msi-ec folder in the platform folder after using kernel 6.4 and up:

Screenshot_20230821_103115

I tested again with kernel 6.5 on Fedora 38 and it's the same thing.

(Secure boot is disabled btw)

teackot commented 10 months ago

/sys/devices/platform/msi-ec is created at runtime: if the laptop isn't supported, the driver won't load, and if the driver won't load the folder won't be created

I found issue #4, this laptop isn't supported yet. @catemiko attached a file with some tested addresses, I'm going to add them in my branch so you can test them

An EC dump and EC FW version would still be appreciated (see my first comment)

rottenpants466 commented 10 months ago

In my case my laptop is supported and the folder is still not created

teackot commented 10 months ago

I created a PR adding support for Modern 15 A5M 155LEMS1.106. Clone my branch to test it: git clone -b modern-15-a5m https://github.com/teackot/msi-ec.git

teackot commented 10 months ago

In my case my laptop is supported and the folder is still not created

Okay, let me check the comment you left in that discussion

rottenpants466 commented 10 months ago

In my case my laptop is supported and the folder is still not created

Okay, let me check the comment you left in that discussion

Ok, left a comment there.

teackot commented 10 months ago

In my case my laptop is supported and the folder is still not created

Just a little update here: the issue was that the kernel version of the driver doesn't create an msi-ec sysfs directory because it only supports charge thresholds yet, so it has nothing to put in that folder

catemiko commented 10 months ago

I created a PR adding support for Modern 15 A5M 155LEMS1.106. Clone my branch to test it: git clone -b modern-15-a5m https://github.com/teackot/msi-ec.git

Tried sudo modprobe -v msi-ec:

insmod /lib/modules/6.4.11-zen2-1-zen/kernel/drivers/platform/x86/msi-ec.ko.zst 
modprobe: ERROR: could not insert 'msi_ec': Operation not supported
teackot commented 10 months ago

@catemiko try building it and then loading it in the debug mode, then run /sys/devices/platform/msi-ec/debug/fw_version

teackot commented 10 months ago

Oh, I know why it didn't work. It loads the in-tree kernel module, you should load the github version by running sudo make load

ushinnary commented 10 months ago

Ok, now I have a possibility to run windows + RWeverything + MSI Center PRO, i've already pressed on EC button (in RWE...) and on every change in center app i pressed f2 to export config. What should i look at? With diffuse (flatpak app) i have at least 7 lines changed, so i don't know what i can check to be 100% sure. Comparing some values with PR #66 not giving me the same results (or at least I'm watching wrong). I'll be appreciated to have a guide (discord server with screen share is welcome)

glpnk commented 10 months ago

In RWE you need to Save (button 1) current dump and load (with load or Compare (2) button) it for comparison, than press Compare button (2) second time and changed values will be highlighted red:

RWE Screenshot from Asus laptop, don't get confused

If values are red but static you forgot to click Compare button second time

UPD: add this guide to wiki

ushinnary commented 10 months ago

Upd: if you confirm that these values are good, i'll be able to install ubuntu on external drive for testing purposes (on silverblue not so easy to test msi-ec)

glpnk commented 10 months ago

What exactly I need to find? Battery and Shift? #66 isn't resolving

PR #66 patch ```c static const char *ALLOWED_FW_12[] __initconst = { "155LEMS1.106", // MSI Modern 15 A5M NULL }; static struct msi_ec_conf CONF12 __initdata = { .allowed_fw = ALLOWED_FW_12, .charge_control = { .address = 0xef, .offset_start = 0x8a, .offset_end = 0x80, .range_min = 0x8a, .range_max = 0xe4, }, .webcam = { .address = 0x2e, .block_address = 0x2f, .bit = 1, }, .fn_win_swap = { .address = MSI_EC_ADDR_UNKNOWN, .bit = 4, }, .cooler_boost = { .address = 0x98, .bit = 7, }, .shift_mode = { .address = 0xf2, .modes = { { SM_ECO_NAME, 0xc2 }, { SM_COMFORT_NAME, 0xc1 }, { SM_SPORT_NAME, 0xc0 }, MSI_EC_MODE_NULL }, }, .super_battery = { .address = MSI_EC_ADDR_UNKNOWN, // may be supported .mask = 0x0f, }, .fan_mode = { .address = 0xf4, .modes = { { FM_AUTO_NAME, 0x0c }, { FM_BASIC_NAME, 0x4c }, { FM_ADVANCED_NAME, 0x8c }, MSI_EC_MODE_NULL }, }, .cpu = { .rt_temp_address = 0x68, .rt_fan_speed_address = 0x71, .rt_fan_speed_base_min = 0x19, .rt_fan_speed_base_max = 0x37, .bs_fan_speed_address = MSI_EC_ADDR_UNKNOWN, .bs_fan_speed_base_min = 0x00, .bs_fan_speed_base_max = 0x0f, }, .gpu = { .rt_temp_address = MSI_EC_ADDR_UNKNOWN, .rt_fan_speed_address = MSI_EC_ADDR_UNKNOWN, }, .leds = { .micmute_led_address = 0x2b, .mute_led_address = 0x2c, .bit = 2, }, .kbd_bl = { .bl_mode_address = MSI_EC_ADDR_UNKNOWN, .bl_modes = { 0x00, 0x08 }, .max_mode = 1, .bl_state_address = 0xf3, .state_base_value = 0x80, .max_state = 3, }, }; ```

From your screenshot and patch:

Value Address Value Match
Charge limit EF
"Battery super_save mode" SM_ECO_NAME F2 C2
"Battery silent mode" SM_COMFORT_NAME F2 C1
"Battery balance mode" SM_COMFORT_NAME F2 C1
"Battery performance mode" SM_SPORT_NAME F2 C0
"Battery silent mode" FM_SILENT_NAME F4 1D need to add to PR
FM_AUTO_NAME F4 0D
KB BL F3 80,83
teackot commented 10 months ago

Battery thresholds: right. You can see 0xEF changing

"Shift Mode": got it right

"Super Battery":

Fan mode:

teackot commented 10 months ago

catemiko's fan modes end with the C digit, and ushinnary's end with a D. I think only the higher 4 bits matter

glpnk commented 10 months ago

@teackot

I think only the higher 4 bits matter

Yeah I've tested, both working and not conflicting

Super battery is weird with 3 possible values.

From some MSI app research - you can programmatically disable battery charge. Also from my experiments - you also can trigger charge when power supply is unplugged

glpnk commented 10 months ago

@ushinnary does FN swap exists in MSI app? Also do you have ability to fine tune cooler speed in app? Led addresses right? Because from values it seems to be enabled (0x2B=8C bit 2 is set, do you have micmute led lit?)

Also F3 address is keyboard light about which I forgot

ushinnary commented 10 months ago

FN swap exists in MSI app?

Yes, it does. Should i make a screenshot with it changing too? I can do this in 5 hours from now😅 Not sure about cooler speed option, think it controlled by performance preset. Didn't see an led option in the app, i might need to install more drivers to check that, but i will :)

ushinnary commented 10 months ago

I have also a win key disable option

glpnk commented 10 months ago
catemiko's constants from #4 ```c #ifndef __MSI_EC_CONSTANTS__ #define __MSI_EC_CONSTANTS__ #define MSI_DRIVER_NAME "msi-ec" + #define MSI_EC_WEBCAM_ADDRESS 0x2e - #define MSI_EC_WEBCAM_ON 0x4a - #define MSI_EC_WEBCAM_OFF 0x48 (Not tested) #define MSI_EC_FN_WIN_ADDRESS 0xbf (Not tested) #define MSI_EC_FN_KEY_LEFT 0x40 (Not tested) #define MSI_EC_FN_KEY_RIGHT 0x50 (Not tested) #define MSI_EC_WIN_KEY_LEFT 0x50 (Not tested) #define MSI_EC_WIN_KEY_RIGHT 0x40 + #define MSI_EC_BATTERY_MODE_ADDRESS 0xef + #define MSI_EC_BATTERY_MODE_MAX_CHARGE 0xe4 + #define MSI_EC_BATTERY_MODE_MEDIUM_CHARGE 0xd0 + #define MSI_EC_BATTERY_MODE_MIN_CHARGE 0xbc + #define MSI_EC_COOLER_BOOST_ADDRESS 0x98 + #define MSI_EC_COOLER_BOOST_ON 0x82 + #define MSI_EC_COOLER_BOOST_OFF 0x02 (Not tested) #define MSI_EC_SHIFT_MODE_ADDRESS 0xf2 (Not tested, not present in MSI Center Pro) #define MSI_EC_SHIFT_MODE_TURBO 0xc4 + (High Performance) #define MSI_EC_SHIFT_MODE_SPORT 0xc0 + (Balanced) #define MSI_EC_SHIFT_MODE_COMFORT 0xc1 + (Super Battery) #define MSI_EC_SHIFT_MODE_ECO 0xc2 (Not tested) #define MSI_EC_SHIFT_MODE_OFF 0x80 + #define MSI_EC_FW_VERSION_ADDRESS 0xa0 + #define MSI_EC_FW_VERSION_LENGTH 12 + #define MSI_EC_FW_DATE_ADDRESS 0xac + #define MSI_EC_FW_DATE_LENGTH 8 + #define MSI_EC_FW_TIME_ADDRESS 0xb4 + #define MSI_EC_FW_TIME_LENGTH 8 (Has zeroes, not tested) #define MSI_EC_CHARGE_CONTROL_ADDRESS 0xef (Has zeroes, not tested) #define MSI_EC_CHARGE_CONTROL_OFFSET_START 0x8a (Has zeroes, not tested) #define MSI_EC_CHARGE_CONTROL_OFFSET_END 0x80 (Has zeroes, not tested) #define MSI_EC_CHARGE_CONTROL_RANGE_MIN 0x8a (Has zeroes, not tested) #define MSI_EC_CHARGE_CONTROL_RANGE_MAX 0xe4 + #define MSI_EC_CPU_REALTIME_TEMPERATURE_ADDRESS 0x68 + (2 bytes?) #define MSI_EC_CPU_REALTIME_FAN_SPEED_ADDRESS 0x71 (Not tested) #define MSI_EC_CPU_REALTIME_FAN_SPEED_BASE_MIN 0x19 (Not tested) #define MSI_EC_CPU_REALTIME_FAN_SPEED_BASE_MAX 0x37 (Not tested) #define MSI_EC_CPU_BASIC_FAN_SPEED_ADDRESS 0x89 (Not tested) #define MSI_EC_CPU_BASIC_FAN_SPEED_BASE_MIN 0x00 (Not tested) #define MSI_EC_CPU_BASIC_FAN_SPEED_BASE_MAX 0x0f (Not tested) #define MSI_EC_GPU_REALTIME_TEMPERATURE_ADDRESS 0x80 (Not tested) #define MSI_EC_GPU_REALTIME_FAN_SPEED_ADDRESS 0x89 + #define MSI_EC_FAN_MODE_ADDRESS 0xf4 (Has address 0x0c) #define MSI_EC_FAN_MODE_AUTO 0x0d (Has address 0x4c) #define MSI_EC_FAN_MODE_BASIC 0x4d (Has address 0x8c) #define MSI_EC_FAN_MODE_ADVANCED 0x8d + #define MSI_EC_LED_MICMUTE_ADDRESS 0x2b + #define MSI_EC_LED_MUTE_ADDRESS 0x2c + #define MSI_EC_LED_STATE_MASK 0x4 + #define MSI_EC_LED_STATE_OFF 0x80 + #define MSI_EC_LED_STATE_ON 0x84 + #define MSI_EC_KBD_BL_ADDRESS 0xf3 + #define MSI_EC_KBD_BL_STATE_MASK 0x3 + #define MSI_EC_KBD_BL_STATE_OFF 0x80 + #define MSI_EC_KBD_BL_STATE_ON 0x81 + #define MSI_EC_KBD_BL_STATE_HALF 0x82 + #define MSI_EC_KBD_BL_STATE_FULL 0x83 static int MSI_EC_KBD_BL_STATE[4] = { MSI_EC_KBD_BL_STATE_OFF, MSI_EC_KBD_BL_STATE_ON, MSI_EC_KBD_BL_STATE_HALF, MSI_EC_KBD_BL_STATE_FULL}; + #define MSI_EC_CAMERA_ADDRESS 0x2e + #define MSI_EC_CAMERA_HARD_ADDRESS 0x2f /* hotkey has no effect if this address disables the cam*/ + #define MSI_EC_CAMERA_STATE_MASK 0x2 (Has value 0x09) #define MSI_EC_CAMERA_STATE_OFF 0x80 (Has value 0x0b) #define MSI_EC_CAMERA_STATE_ON 0x84 #endif // __MSI_EC_CONSTANTS__ ```

Needs testing:

teackot commented 10 months ago

Didn't see an led option in the app

@glpnk means the LEDs on the mute and mic mute keyboard keys. You need to toggle them and see what happens in the EC ([0x2b] [0x2c] and [0x2d] addresses specifically)

glpnk commented 10 months ago

Leds require proper soundcard driver installation which successful not every time

ushinnary commented 10 months ago

LEDs on the mute and mic mute keyboard keys.

Oh i see, i have to press fn + F* to see the red light and make screenshots of rwe with changes, got it :)

benitozh commented 10 months ago

Hi everyone !

I've been away from my computer recently, and I've just noticed that some progress has been made on our device in order to get the msi-ec working.

I'm not sure how can I help from here, but i'm willing to help things going forward ! Feel free to guide me.

ushinnary commented 10 months ago

ok, here the those screenshots that have changes, idk why rwe shows me same values on some lines but others on reboot...

Later I will post others (want to be sure in them) For mic, i have an LED always enabled even after installing different drivers and impossible to switch it (idk why, every click shows it enabled without toggle it...). Other LED is on ESC key, do we need it too? (Because fn key swap is swap between win and fn) Keyboard has 4 states (off, 1, 2, 3 - max)

glpnk commented 10 months ago

For mic, i have an LED always enabled

So I was right with "0x2B=8C bit 2 is set, do you have micmute led lit?"

Checklist:

UPD: ESC (FN lock) is unnecessary

Keyboard has 4 states (off, 1, 2, 3 - max)

Yeah it's known

ushinnary commented 10 months ago
teackot commented 10 months ago

fan high perf cooler boost

[0x98] is highlighted red but has the same value as before, does it actually change when you switch cooler boost?

Also you left out the last row where the fan mode parameter is located

ushinnary commented 10 months ago

[0x98] is highlighted red

9F you mean? can't see 98 red value for fan high perf cooler boost

benitozh commented 10 months ago

I'd like to know what's the status of the msi-ec driver compatibility project on our Modern 15 A5M laptop? Thank you for the work already done,

ushinnary commented 10 months ago

@benitozh We should get a value for microphone button LED, that might be the last missing one, but i can't manage audio driver to work on win10 on my pc, and win11 won't let me install RWE :( I might check again fan high perf cooler boost values if they are correct, i guess. And then it might be ready for testing on teackot's branch, mentioned above.

ushinnary commented 10 months ago

@teackot

Hope everything is correct

ushinnary commented 9 months ago

Just updated my screenshots, didn't notice that previous was quite the same. Should be good now

teackot commented 5 months ago

66 has been merged!

benitozh commented 5 months ago

Thanks for your work and dedication @teackot !

EDIT : It might be useful to mention A5M variant in the tested laptops list. Anyway, that's not urgent.

teackot commented 1 month ago

Closing for now since no more info is needed yet