BeardOverflow / msi-ec

GNU General Public License v2.0
145 stars 45 forks source link

Support for MSI Alpha 15 B5EEK #16

Closed VesperLlama closed 5 months ago

VesperLlama commented 1 year ago

I tried installing this driver on my MSI Alpha 15 B5EEK but it gives an error "Your firmware version is not supported!" How can I help in adding support for my device?

Device: MSI Alpha 15 B5EEK Distro: Arch Linux Kernel: 6.1.12-zen BIOS Version: E158LAMS.108 EC Version: 158LEMS1.103

dmidecode ouput - dmidecode.txt

Zalaxx commented 1 year ago

Hi, I have the exact same laptop, let me know if I can be of any use!

I tried too to install the driver by following the instructions in the readme, but got the error modprobe: ERROR: could not insert 'msi_ec': Operation not supported when running the sudo make install. When checking dmesg, I also got the error Your firmware version is not supported!.

Distro: Pop!_Os 22.04 Kernel: 6.0.12 BIOS Version: E158LAMS.107 EC Version: 158LEMS1.106

Here is the output of dmidecode on my computer: dmidecode.txt

teackot commented 1 year ago

Hi!

I am working on a debug mode which will allow you to load the driver with unsupported firmware and let you collect some information (primarily an EC memory dump).

As for the information you provided here, I can see that you have a different minor EC version. I wonder if the EC memory configuration is the same.

VesperLlama commented 1 year ago

I can see that you have a different minor EC version

Do you mean different version between mine and @Zalaxx? .106 was released after I bought my laptop, so my laptop has older version. The changelog of the EC only says "system stability improvements". Should I also update to that version?

teackot commented 1 year ago

Do you mean different version between mine and @Zalaxx

Yes

The changelog of the EC only says "system stability improvements"

Where can I see these changelogs? Seems very useful for this project

Should I also update to that version

No, I would actually like to see if there are any differences between minor versions' EC dumps. We need to get as much info as possible

VesperLlama commented 1 year ago

You can get the EC file from here. The changelog is in a txt file in the zip.

You can also get the older version by changing the zip name to ...105.zip in the download url.

teackot commented 1 year ago

I'm back!

I have already implemented EC dump for debug mode, so if you don't want to wait until it gets merged you can get it from my repo.

Please, follow the steps described in this comment to get an EC dump and attach it here

VesperLlama commented 1 year ago

ec_dump.txt

Here's the dump. I turned off the keyboard backlight at around 5 sec. Thanks!

teackot commented 1 year ago

I turned off the keyboard backlight at around 5 sec

I see, the backlight address is 0xd3

Does your backlight have 3 modes or is it on/off?

teackot commented 1 year ago

I see, the backlight address is 0xd3

Can you please use watch -d -c -n1 'cat /sys/devices/platform/msi-ec/debug/ec_dump' and confirm if it is true? This command updates the dump on your screen every second and highlights the changes

VesperLlama commented 1 year ago

Does your backlight have 3 modes or is it on/off?

It is RGB with 4 modes - Steady, Breathing, Breathing Cycle and Colour Shift. I use a self made python script to control it on Linux but I've only added the Steady mode for it.

VesperLlama commented 1 year ago

Can you please use watch -d -c -n1 'cat /sys/devices/platform/msi-ec/debug/ec_dump' and confirm if it is true?

I don't see any value which changes consistently as I toggle the lights on/off. Many other random values change every second even when idle.

I see, the backlight address is 0xd3

If I am looking at the right value (14th row, 4th column) then it changes to 01 when I press Ctrl and 02 when pressing Alt. When I press both at the same time it changes to 03. I use Ctrl+Alt+Up/Down combination to toggle the lights. So, I guess it changed when I pressed the combination and not because of the light changing.

teackot commented 1 year ago

So, I guess it changed when I pressed the combination and not because of the light changing.

Oh, good thing we double checked

It is RGB with 4 modes

I'm starting to think that some backlit keyboards aren't controlled by EC

Many other random values change every second even when idle.

Those are fan speeds, temperatures and some other paraneters we don't know

teackot commented 1 year ago

I use a self made python script to control it on Linux but I've only added the Steady mode for it.

What interface do you use to communicate with the keyboard? I know some MSI kbd backlights use USB (MSIKLM project uses libusb)

teackot commented 1 year ago

Is your charge threshold set to 60% ? I can see the 60% value in [0xef]

VesperLlama commented 1 year ago

What interface do you use to communicate with the keyboard?

I send USB packets to the keyboard, so I guess it's not controlled by the EC.

Is your charge threshold set to 60%?

Yes.

teackot commented 1 year ago
teackot commented 1 year ago

I send USB packets to the keyboard, so I guess it's not controlled by the EC.

Okay, then backlight isn't in the scope of this project

VesperLlama commented 1 year ago

Is your camera disabled?

Yes.

Did you set your shift mode to comfort in the official app?

I don't remember what I set before, but it was on Extreme performance mode when I booted into it right now. The modes are named differently, I think. They are Extreme Performance, Balanced, Silent and Super Battery.

I will try this app tomorrow and report what I see.

teackot commented 1 year ago

I will try this app tomorrow and report what I see.

Thanks! Also toggle the mute and micmute LEDs and see what changes. I'm pretty sure it's two of these: [0x2b], [0x2c], [0x2d]

VesperLlama commented 1 year ago

I will try this app tomorrow and report what I see.

It's not working on my laptop. It only shows 0s ☹️ Is there any other way to see the memory changes?

teackot commented 1 year ago

I found this reddit post suggesting RWEverything, maybe it will work

VesperLlama commented 1 year ago

I found this reddit post suggesting RWEverything

This is working. Thanks!

Here's what I found.

fan mode is [0xf4]

This changes when changing the scenario.

Do you know what 0xF3 does? It changes when changing the scenario but also when I press the Keyboard light button to change the light mode. It goes from 80-83 in different modes. But it doesn't change when I use MSI Center's Mystic Light setting to change the mode and also does nothing when I change it manually.

basic fan speed may be [0x89]

This value always stays 0, even with cooler boost on and the fans at max, is this normal?

Anything else that I should look at?

teackot commented 1 year ago

Thanks! This covers most of the config parameters.

0xF2 is currently called shift mode in this dirver (needs to be renamed to something more specific).

0xF4 is indeed the fan mode

Do you know what 0xF3 does?

Everything points to it being the backlight. My theory is, maybe this parameter controls the backlight of non-RGB laptops, and RGB laptops have it only for compability reasons. If it is true, then it is out of scope of this driver. If you want to control it on Linux, try OpenRGB, maybe it'll work for your laptop.

This value always stays 0, even with cooler boost on and the fans at max, is this normal?

Anything else that I should look at?

0x89 is a (write only?) parameter used to set fan speed when fan mode is set to basic. If your MSI Center doesn't have basic mode, try setting [0xF4] to 0x4D and writing something like 0x32 (50% speed) into [0x89]

The actual fan speed may be located at [0x71] or [0xC9]

VesperLlama commented 1 year ago

If your MSI Center doesn't have basic mode, try setting [0xF4] to 0x4D and writing something like 0x32 (50% speed) into [0x89]

This didn't do anything. Both values revert back to original when edited. Maybe it's not supported on this device.

VesperLlama commented 1 year ago

22

Thank you for adding support for my device!

But I notice these issues -

teackot commented 1 year ago

Thank you for adding support for my device!

Will be merged here soon too!

The values for Win/Fn key is reversed

I know, I need to make some changes in the program logic to support reversed Win/Fn placement.

The Speaker mute and Mic LEDs do not work

They won't toggle on key press ootb, if you mean that. See https://github.com/BeardOverflow/msi-ec/pull/13#issuecomment-1432513857

teackot commented 1 year ago

Merged!

(Fn/Win is still reversed, I'll address it later)

Freihut commented 1 year ago

I'm not sure, if I should open a new issue, but for some reason this seems to break the Alpha 17 B5EEK (I guess they're using the same board and just a bigger display + case): Booting stops with blinking capslock LED + damaged filesystem on the bootpartition after hardreset (REISUB not working). But as far as I can tell no hardware damage (phew!). It happened twice, so I guess it's not a one-time-thingy.

EC Version: 17LLEMS1.106 BIOS Version: E17LLAMS.108 Board: MS-17LL Distro: Arch on Kernel 6.1.29+30

VesperLlama commented 1 year ago

@teackot Hello. I saw that this driver was merged in Linux 6.4. I have now updated to it but there is no msi-ec folder in /sys/devices/platform so I can't change anything.

The charging limit works fine. I can also see the driver in lsmod

Do I have to change something to make it work?

teackot commented 1 year ago

Hello! The in-tree kernel driver only has charging limits. Other features will be gradually merged with the further patches. For now, if you want those features, you still have to use the driver from this repo

VesperLlama commented 1 year ago

@teackot I have installed the module from this repo using the makefile. But the kernel module is still being loaded instead of the repo one.

How do I use the repo one instead of the kernel one?

teackot commented 1 year ago

Hello! Really sorry for not answering, have you found the solution yet?

VesperLlama commented 1 year ago

No, I haven't found any solution to this :( It always loads the kernel module.

teackot commented 12 months ago

Hi again! I think @glpnk found a solution: install the module with DKMS and you will be able to load it instead of the in-tree module:

sudo make uninstall
sudo make dkms-install
sudo modprobe -v msi-ec
VesperLlama commented 12 months ago

Thanks for the help. I also found another solution few days ago. I renamed the msi-ec.c file and all instances of it in the makefile to msi-ec-git.c. Now I can blacklist the kernel one and load the renamed one without any issue.

glpnk commented 12 months ago

I renamed the msi-ec.c file and all instances of it in the makefile to msi-ec-git.c.

I did the same, but I think this is kinda gray hack. Because at least it changes path to sysfs (maybe I did it in wrong way).

Also another gray hack is just to copy with replace .ko file to /lib/modules/<kernel-version>/kernel/drivers/platform/x86/ manually

VesperLlama commented 12 months ago

it changes path to sysfs

The sysfs path is same for me. The folder name in sysfs hasn't changed for me. Did you change anything in the source code? I only changed it's filename and the Makefile.

glpnk commented 12 months ago

@VesperLlama

Did you change anything in the source code?

Maybe but it was a long time ago. I think I modified both source and makefile, but I thought that is wrong way. After this I just replaced in-kernel module with self-made because it's easier.

vadcx commented 9 months ago

What's there left to do to close this? Looking at https://github.com/BeardOverflow/msi-ec/blob/c39fe616c24e2ff12f086dfbc34358499c13f6bf/msi-ec.c#L452

VesperLlama's Feb 19 comment contains extensive list from testing; Feb 20 has follow up issues.

On 6.6.7 kernel the only LED that doesn't work out-of-the-box on key press is Fn+F1 for Mute button. ESC+Caps Lock are done in firmware and the Microphone LED (Fn+F5) works on its own.

@teackot I own this laptop, if I retested this with a PR, can it be checked off as done?

Edit: The mic button may be working as a result of the msi-ec driver, I see /sys/devices/platform/msi-ec/leds/ folders.

teackot commented 5 months ago

@vadcx Hi

fn_win_swap is reversed - this is long-term todo, out of scope

Right.

claims super-battery is unsupported (not true)

The address is marked as ADDR_UNKNOWN, I'll remove the "unsupported?" comment. Also super battery doesn't work as expected rn, so it's also out of scope until it is properly implemented.

fan address

I feel like we'll have to do a full review of the cpu and gpu sections' algorithms. Also there is no constant fan speed setting in the MSI app for this model (correct me if I'm wrong). So this doesn't block the issue.

kbd backlight: entire section "needs testing" // comments above: backlight apparently on USB

Kbd mode isn't implemented yet, backlight intensity is not controlled by the EC on RGB models

I think it can be closed now! I'll add a label so we don't lose this issue when we implement the currently unimplemented features