BeardOverflow / msi-ec

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

Embedded Controller for MSI laptops

Disclaimer

This driver might not work on other laptops produced by MSI. Use it at your own risk, we are not responsible for any damage suffered.

Also, and until future enhancements, no DMI data is used to identify your laptop model. In the meantime, check the msi-ec.c file before using.

Supported devices

Check if your device is supported before attempting to install and use the driver. The list of supported devices can be found here.

Installation

From GitHub

Prerequisities:

  1. Install the following packages using the terminal:
    • For Debian: sudo apt install build-essential linux-headers-amd64
    • For Ubuntu: sudo apt install build-essential linux-headers-generic
    • For Fedora: sudo dnf install kernel-devel
    • For Arch: sudo pacman -S --needed base-devel linux-headers
  2. Clone this repository and cd to it: git clone https://github.com/BeardOverflow/msi-ec && cd msi-ec
  3. (Linux < 6.2 only, verify with uname -r): make older-kernel-patch
  4. Choose one of the following installation methods

(Recommended) Installation using DKMS:

  1. Verify that dkms is available: which dkms
  2. Install the msi-ec kernel module: sudo make dkms-install
  3. (Optional) To uninstall: sudo make dkms-uninstall

(OR) Classic installation (without DKMS):

  1. Build the driver: make
  2. Install the msi-ec kernel module: sudo make install
  3. (Optional) To uninstall: sudo make uninstall

From AUR (Arch Linux)

  1. Install any AUR helper (yay for example)
  2. Run yay -S msi-ec-git

Current Support in the Kernel

Features already merged in kernel 6.4 and up:

Still not merged:

Usage

This driver exports a few files in its own platform device, msi-ec, and is available to userspace under:

In addition to these platform device attributes the driver registers itself in the Linux power_supply subsystem (Documentation/ABI/testing/sysfs-class-power) and is available to userspace under:

Led subsystem allows us to control the leds on the laptop including the keyboard backlight

Debug mode

You can use module parameters to get direct read-write access to the EC or force-load a configuration for a specific firmware.

Be very careful, since writing into the unknown addresses of the EC memory may be dangerous! If you did something wrong, please, reset the EC using the reset button on the bottom of your laptop.

debug, bool

Set this parameter to true to enable debug attributes, located at /sys/devices/platform/msi-ec/debug/, even if your EC is not supported yet. Normal attributes will still be accessible if your firmware is supported.

You can use make load-debug command to load the module in the debug mode after building it from source.

name permissions description
fw_version RO returns your EC firmware version
ec_dump RO returns an EC memory dump in the form of a table
ec_get RW receives an EC memory address in the hexadecimal format on write; returns a value stored in the EC memory at this address on read
ec_set WO receives an address-value pair in the following format: aa=vv, where aa and vv are address and value in the hexadecimal format; then writes the value into the EC memory

firmware, string

Set this parameter to a supported EC firmware version to use its configuration and test if it is compatible with your EC. Please verify that the attributes return the correct data before attempting to write into them!

Contribute

Eager to support the project? Your help is always welcome to keep the project alive and going!