msi-ec icon indicating copy to clipboard operation
msi-ec copied to clipboard

MSI Summit E16 Flip (A12UCT model)

Open rottenpants466 opened this issue 3 years ago • 11 comments
trafficstars

Hi, i was tying to change the values off of the contants.h file with the correct ones for my laptop. I've been trying to use the following values from this file: https://github.com/dmitry-s93/MControlCenter/blob/main/src/operate.cpp since the developer has the same laptop as mine and everything works in the app.

The problem is that there are some lines in contants.h that differ from operate.cpp in MControlCenter. For example:

In contants.h these are some of the lines relating to the battery:

#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_CHARGE_CONTROL_ADDRESS 0xef
#define MSI_EC_CHARGE_CONTROL_OFFSET_START 0x8a
#define MSI_EC_CHARGE_CONTROL_OFFSET_END 0x80
#define MSI_EC_CHARGE_CONTROL_RANGE_MIN 0x8a
#define MSI_EC_CHARGE_CONTROL_RANGE_MAX 0xe4

In operate.cpp from MControlCenter these relate to the battery as well:

const int batteryChargeAddress = 0x42;
int batteryThresholdAddress;
const int batteryThresholdAddress_0xEF = 0xEF;
const int batteryThresholdAddress_0xD7 = 0xD7;

const int batteryChargingStatusAddress = 0x31;
const int batteryNotCharging = 0x01;
const int batteryCharging = 0x03;
const int batteryDischarging = 0x05;
const int batteryFullyCharged = 0x09;
const int batteryFullyCharged_noPower = 0x0D;

Since there are differences in the amount of lines and different names i don't know how to correctly add the proper values in the contants.h file.

Sorry if i didn't explained the problem correctly

Thank you


Also this is the output of each entry:

for f in /sys/devices/platform/msi-ec/*; do echo $f; cat $f; echo; done
/sys/devices/platform/msi-ec/battery_mode
unknown (0)

/sys/devices/platform/msi-ec/cooler_boost
off

/sys/devices/platform/msi-ec/cpu
cat: /sys/devices/platform/msi-ec/cpu: É pasta

/sys/devices/platform/msi-ec/driver
cat: /sys/devices/platform/msi-ec/driver: É pasta

/sys/devices/platform/msi-ec/driver_override
(null)

/sys/devices/platform/msi-ec/fan_mode
unknown (42)

/sys/devices/platform/msi-ec/fn_key
unknown (8)

/sys/devices/platform/msi-ec/fw_release_date
2022/06/29 09:52:28

/sys/devices/platform/msi-ec/fw_version
1592EMS1.111

/sys/devices/platform/msi-ec/gpu
cat: /sys/devices/platform/msi-ec/gpu: É pasta

/sys/devices/platform/msi-ec/leds
cat: /sys/devices/platform/msi-ec/leds: É pasta

/sys/devices/platform/msi-ec/modalias
platform:msi-ec

/sys/devices/platform/msi-ec/power
cat: /sys/devices/platform/msi-ec/power: É pasta

/sys/devices/platform/msi-ec/shift_mode
unknown (112)

/sys/devices/platform/msi-ec/subsystem
cat: /sys/devices/platform/msi-ec/subsystem: É pasta

/sys/devices/platform/msi-ec/uevent
DRIVER=msi-ec
MODALIAS=platform:msi-ec

/sys/devices/platform/msi-ec/webcam
unknown (9)

/sys/devices/platform/msi-ec/win_key
unknown (8)

rottenpants466 avatar Nov 16 '22 20:11 rottenpants466

Just going to attach dmidecode here as well. I have been fiddling around with the constants.h file but i'm afraid of messing up something and break my computer :|

dmidecode.txt

Edit: I extracted my dsdt.aml, is it useful?

DSDT.zip

rottenpants466 avatar Nov 24 '22 19:11 rottenpants466

Sorry for the late answer.

  • batteryChargeAddress / batteryChargingStatusAddress (and batteryNotCharging, batteryCharging and so) Not mapped. Looks interesting, so I might consider to map them

  • batteryThresholdAddress Operate::detectBatteryThresholdAddress() evals two different addresses, batteryThresholdAddress_0xEF and batteryThresholdAddress_0xD7. By default, it is defined by constants.h at MSI_EC_BATTERY_MODE_ADDRESS as 0xEF. Try to change MSI_EC_BATTERY_MODE_ADDRESS to 0xD7 and read the values before writing. For example:

    • cat /sys/devices/platform/msi-ec/battery_mode --> it should return max/medium/min values
    • cat /sys/class/power_supply/BAT-0/charge_control_start_threshold --> it should return 50/70/90

BeardOverflow avatar Nov 25 '22 08:11 BeardOverflow

So i found a fork of this repo: https://github.com/ThePBone/msi-ec-modern

His contants.h and msi-ec files are a bit different from yours. I tested with his fork and can confirm that almost everything works (some names differ from yours as well):

[andre@SummitE16Flip ~]$ cat /sys/devices/platform/msi-ec/preset
silent
[andre@SummitE16Flip ~]$ cat /sys/devices/platform/msi-ec/webcam
on
[andre@SummitE16Flip ~]$ cat /sys/devices/platform/msi-ec/fn_key
right
[andre@SummitE16Flip ~]$ cat /sys/devices/platform/msi-ec/win_key
left
[andre@SummitE16Flip ~]$ cat /sys/devices/platform/msi-ec/battery_charge_mode
min
[andre@SummitE16Flip ~]$ cat /sys/devices/platform/msi-ec/cooler_boost
off
[andre@SummitE16Flip ~]$ cat /sys/devices/platform/msi-ec/shift_mode
off
[andre@SummitE16Flip ~]$ cat /sys/devices/platform/msi-ec/fan_mode
silent
[andre@SummitE16Flip ~]$ cat /sys/devices/platform/msi-ec/fw_version
1592EMS1.111
[andre@SummitE16Flip ~]$ cat /sys/devices/platform/msi-ec/fw_release_date
2022/06/29 09:52:28
[andre@SummitE16Flip ~]$ cat /sys/devices/platform/msi-ec/ac_connected
1
[andre@SummitE16Flip ~]$ cat /sys/devices/platform/msi-ec/lid_open
1
[andre@SummitE16Flip ~]$ cat /sys/devices/platform/msi-ec/cpu/realtime_temperature
43
[andre@SummitE16Flip ~]$ cat /sys/devices/platform/msi-ec/cpu/realtime_fan_speed
66
[andre@SummitE16Flip ~]$ cat /sys/devices/platform/msi-ec/gpu/realtime_temperature
0
[andre@SummitE16Flip ~]$ cat /sys/devices/platform/msi-ec/gpu/realtime_fan_speed
45
[andre@SummitE16Flip ~]$ cat /sys/class/leds/platform::micmute/brightness
0
[andre@SummitE16Flip ~]$ cat /sys/class/leds/platform::mute/brightness
0
[andre@SummitE16Flip ~]$ cat /sys/class/leds/msiacpi::kbd_backlight/brightness
2
[andre@SummitE16Flip ~]$ 

The only 3 that are wrong are msi-ec/fan_mode (it doesn't change anything when using echo "medium" | sudo tee etc..), cpu/realtime_fan_speed and gpu/realtime_fan_speed: both display wrong values because the fans were off when i did the test.

The only problem using his fork is that it's not possible to change, for example, battery thresholds in gnome/kde in system settings because i think it doesn't registers itself in the power_supply subsystem. Is there a way to do that? or better, how can i adapt his code to your code?

Screenshot_20221125_150411

Maybe this will be useful to you to create a more robust and compatible driver and help other people too in the process.

Thank you for you time and patience!

rottenpants466 avatar Nov 25 '22 15:11 rottenpants466

@ThePBone Interesting fork! It's pretty complete. I see that some basic constants are placed at different memory addresses for the modern series. I would like a pull request with the changes that you made, but actually it is not possible. First I must change the codebase in order to support more than one embedded controller. When the codebase is ready, I will request you again.

@rottenpants466 It should be enough if you replace the existing constants in the ThePBone's fork. But you are right, the driver must go forward to be more robust and compatible as you said. I will keep open this issue until supporting the modern series model.

BeardOverflow avatar Nov 27 '22 20:11 BeardOverflow

Interesting fork! It's pretty complete. I see that some basic constants are placed at different memory addresses for the modern series. I would like a pull request with the changes that you made, but actually it is not possible. First I must change the codebase in order to support more than one embedded controller. When the codebase is ready, I will request you again.

Sure! Feel free to ping me once your codebase is ready.

timschneeb avatar Nov 27 '22 20:11 timschneeb

Maybe this would help too? https://github.com/MusiKid/acpi_ec

:+1:

rottenpants466 avatar Nov 28 '22 19:11 rottenpants466

So i found a fork of this repo: https://github.com/ThePBone/msi-ec-modern His contants.h and msi-ec files are a bit different from yours. I tested with his fork and can confirm that almost everything works

I can add a config for your laptop in my PR.

The only 3 that are wrong are msi-ec/fan_mode (it doesn't change anything when using echo "medium" | sudo tee etc..)

Did you find the right addresses?

teackot avatar Jan 07 '23 15:01 teackot

So i found a fork of this repo: https://github.com/ThePBone/msi-ec-modern His contants.h and msi-ec files are a bit different from yours. I tested with his fork and can confirm that almost everything works

I can add a config for your laptop in my PR.

The only 3 that are wrong are msi-ec/fan_mode (it doesn't change anything when using echo "medium" | sudo tee etc..)

Did you find the right addresses?

Hi!

I tried but i couldn't (i'm not a programmer) :|

In my case i know that ThePBone's msi-ec is more compatible with my laptop than BeardOverflow's msi-ec maybe because his laptop is similar to mine.

What i ended up doing was using MControlCenter: https://github.com/dmitry-s93/MControlCenter and since i'm using Fedora i had to install the following module in order to use the app: https://github.com/MusiKid/acpi_ec. (Fedora doesn't include the ec_sys module in the kernel, like Ubuntu, and MControlCenter requires this, in the meantime the author updated the app to support that acpi_ec module)

Using MControlCenter everything works since we have similar hardware so i guess the addresses are the same.

My laptop is almost the exact same model as the author of MControlCenter: MSI Summit E16 Flip Evo A12MT https://github.com/dmitry-s93/MControlCenter/blob/main/docs/tested_devices.md

The only difference (i think) is that my model MSI Summit E16 Flip A12UCT has a nvidia gpu.

Anyway i will be glad to help out and test things :) i saw that you are trying to help @jwrdegoede here: https://github.com/dmitry-s93/MControlCenter/issues/78

rottenpants466 avatar Jan 07 '23 17:01 rottenpants466

Did you find the right addresses?

I tried but i couldn't (i'm not a programmer) :|

@rottenpants466 If you happen to have Windows installed on a secondary partition, you could use this tool: https://github.com/ThePBone/MsiEcRamEditor to read & observe changes to the EC memory while using the official MSI software/driver to find out which addresses are used for what purpose. I created that to find the correct addresses for my msi-ec-modern fork more easily. Just change settings in the official MSI center (or press FN keys) and see how these changes reflect in EC memory.

timschneeb avatar Jan 08 '23 18:01 timschneeb

Did you find the right addresses?

I tried but i couldn't (i'm not a programmer) :|

@rottenpants466 If you happen to have Windows installed on a secondary partition, you could use this tool: https://github.com/ThePBone/MsiEcRamEditor to read & observe changes to the EC memory while using the official MSI software/driver to find out which addresses are used for what purpose. I created that to find the correct addresses for my msi-ec-modern fork more easily. Just change settings in the official MSI center (or press FN keys) and see how these changes reflect in EC memory.

Will try to do that :+1:

Thank you!

rottenpants466 avatar Jan 08 '23 22:01 rottenpants466

Hi @teackot

So i returned to this issue with the tablet mode not detected. Whe have tried to find a solution for this already in here: https://github.com/dmitry-s93/MControlCenter/issues/77

I remembered that you asked me too look for changes in Linux of the adresses ED an EE these are probably related to the tablet mode swith: 0x84 in [0xED] and 0x01/0x03 in [0xEE]. Today i had some time to see if i could find those adresses in Linux. Also used Windows to check those as well.

What i found out is that both EE and ED adresses appear on Windows while flipping the screen:

  • Flipping the screen ED 0xC0 and EE 0x03 (For some reason ED doesn't always appear)

  • Flipping back to normal mode ED 0x84 and EE 0x01 (Again, ED doesn't always appear)

On Linux i found out that ED doesn't appear when using the command sudo hexdump -C /dev/ec but EE appears:

  • Flipping the screen EE 0x03

  • Flipping back to normal mode EE 0x01

Screenshot_20231022_230157

Screenshot_20231022_230237

Thank you teackot!

rottenpants466 avatar Oct 13 '23 15:10 rottenpants466