Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add guide for address discovery #152

Merged
merged 22 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ Also, and until future enhancements, no DMI data is used to identify your laptop

Check if your device is supported before attempting to install and use the driver. The list of supported devices can be found [here](docs/supported_devices.md).

Can't find your device in the list? Check the contribution guides and open a new issue.

## Contribute
Eager to support the project? Your help is always welcome to keep the project alive and going!
- Read how to get the necessary information about the device on Windows and Linux in [this guide](docs/device_support_guide.md)
- Check out the relevant [wiki article](https://github.com/BeardOverflow/msi-ec/wiki/Contributing).
- If you want to go deeper: [read into this discussion regarding EC firmware naming patterns](https://github.com/BeardOverflow/msi-ec/discussions/98).


## Installation

Expand Down Expand Up @@ -244,8 +252,3 @@ You can use `make load-debug` command to load the module in the debug mode after

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!
- Checkout the relevant [wiki article](https://github.com/BeardOverflow/msi-ec/wiki/Contributing).
- If you want to go deeper: [read into this discussion regarding ec firmware naming patterns](https://github.com/BeardOverflow/msi-ec/discussions/98).
203 changes: 203 additions & 0 deletions docs/device_support_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
# Intro
There are two main methods to get your MSI laptop supported: the recommended method requires Windows to be installed, and the other works directly on Linux.

> [!IMPORTANT]
> If there are any BIOS/firmware updates available for your laptop, follow this guide for your current firmware before installing any of them. Then repeat the process for each new firmware version you install from the official MSI website. This is required to obtain support for older firmware as the EC configuration may vary across the versions.

# Table of contents

+ [Windows](#windows-method-recommended)
+ [RWE guide](#windows-method-recommended)
+ [MsiEcRamEditor](https://github.com/timschneeb/MsiEcRamEditor) (WMI2 only)
+ [Linux](#linux-method)
+ [`msi-ec`](#msi-ec-debug-mode)
+ [`ec-sys`](#ec-sys-method)
+ [dd from `/dev/mem`](#reading-the-ec-ram-mapped-to-system-memory)
+ [Contribution](#contribution)
+ [Firmware naming and generations](#firmware-naming)
+ [Firmware generations](#firmware-generations)
+ [Common addresses](#common-addresses)

# Windows method (recommended):

1. Install Windows 10/11 normally, booting directly from a live usb or
any other trick won't work, however windows activation is not
needed.

2. After a successful installation, make sure to download/install all
Windows updates from the settings
(windows can't update bios/firmware automatically on MSI
laptops but that doesn't mean you have to update them yourself,
instead continue following the guide).

3. Install the MSI app designed for your laptop: MSI dragon center /
MSI creator center / MSI center / MSI center pro (the correct app
can be found on the support page for your laptop).

4. If you fail at step 3, then you most likely need another app. usually
its AMD Adrenalin software / GeForce Experience (nvidia)/ or intel
equivalent.

5. Once the MSI app is installed, you can test the functions it offers,
like user scenario and battery charge limit.

6. If everything works as expected, download RWEverything:
https://rweverything.com/download/ ![download RWEverything](pics/support_guide/dl_rwe.png)

7. Launch it as administrator:
![run as admin](pics/support_guide/run_as_admin.png)

8. Navigate to the EC tab (page):
![open ec tab](pics/support_guide/open_ec_tab.png)

9. Here you should see a table of all the values your Embedded Chip has in its memory.

> [!CAUTION]
> **Do not attempt to edit the memory manually. Writing the wrong values to the wrong addresses will DAMAGE YOUR HARDWARE or even BRICK YOUR DEVICE! This can't be reversed by resetting the EC or BIOS.**

![not apply changes](pics/support_guide/not_apply_changes.png)

10. Change the refresh rate to 500-600ms,
this makes it easier to see how the values react to the changes in the MSI app settings:

![refresh rate button](pics/support_guide/refresh_menu.png)

11. Reading the table:

Each address is a hexadecimal number.
Let's say you are looking for a specific address `0x54`.
The first number `5` can be found on the left side of the table and second number `4` can be found on the top side of the table:

![hex editor how to](pics/support_guide/hex_editor_how_to.png)

Each **Address** contains some **Value**. When you locate an **Address** inside the
table you can take a note of its content: 0x54 = 00 (**Address** = **Value**)
This **Value** will change depending on the parameters related to it.

Some parameters will be changing automatically without your intervention (e.g. the CPU temperature), others will change in response to different settings in the MSI app (e.g. battery charge limits)

Example: To figure out which **Addresses** are used by user scenarios (or shift
modes) go to the user scenario page in the MSI app and keep switching the scenarios
while looking at the EC table.

Eventually you'll notice one or more values that change each time you change the
setting, once you find them, you can start writing down the addresses and values
corresponding to *each* user scenario, so you can report them.

# Linux method

This method is very limited compared to the Windows method, because most
MSI laptop features are tied to software toggles that can only be found in the official Windows apps.

If you are lucky, your laptop model will have similar addresses to another laptop
that is already supported by the driver, but usually this only happens on some
features like cooler boost and battery charge limit.

On Linux, you can do the EC dump in several ways.
+ `msi-ec` built-in debug mode (git version only)
+ `ec-sys` kernel module
+ By reading the memory that is virtually mapped to EC

To request support for your device model, make the EC dump in text form
and open the [Issue on Github](https://github.com/BeardOverflow/msi-ec/issues/new?assignees=&labels=New+firmware&projects=&template=support_request.yml).

## `MSI-EC` debug mode

> [!NOTE]
> Make sure that you are running the git version of the module.
> If not, follow the installation guide in the [Readme](../README.md#Installation) file.
mutchiko marked this conversation as resolved.
Show resolved Hide resolved

Unload the module if it was previously loaded:

+ `sudo modprobe -r msi-ec`

Load the module with the debug mode enabled:

+ `sudo modprobe msi-ec debug=true`

Make a dump by reading the module's pseudo file:

+ `cat /sys/devices/platform/msi-ec/debug/ec_dump`

Or save it to a file:

+ `cat /sys/devices/platform/msi-ec/debug/ec_dump > ec_dump.txt`

> [!IMPORTANT]
> If you see the following error, then your module is not loaded in the debug mode:
>
> `cat: /sys/devices/platform/msi-ec/debug/ec_dump: No such file or directory`

## `EC-SYS` method

> [!NOTE]
> The `ec-sys` module may not be included in some distros, such as Fedora.

To start, You need to load a module called `ec_sys`:

* `sudo modprobe ec_sys`

After that you can extract the EC table and print it on the terminal in text form:

* `hexdump -C /sys/kernel/debug/ec/ec0/io`

Or save it to file:

+ `hexdump -C /sys/kernel/debug/ec/ec0/io > ec_dump.txt`

## Reading the EC RAM mapped to system memory

> [!CAUTION]
> NOT RECOMMENDED! Use only if other methods do not work! Never write to system memory.
>
> Reading random parts of the system memory can reveal your secrets, so check the dump before you post it to Github.
mutchiko marked this conversation as resolved.
Show resolved Hide resolved

> [!NOTE]
> `/dev/mem` may not be supported on some distros. For details, read the `man mem`.

Some devices have EC memory mapped to system memory address `0x0xFC000800`,
so you can read it from the `/dev/mem` pseudo file with `dd`.

To read EC memory in text form run:

+ `sudo dd if=/dev/mem bs=1 skip=4227860480 count=256 | hexdump -C`

To save EC memory in text form run:

+ `sudo dd if=/dev/mem bs=1 skip=4227860480 count=256 | hexdump -C > ec_dump.txt`

# Contribution

## Firmware naming
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a solid explanation , but it's better to put it in another documentation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably don't need more then 1 guide now

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should probably be in a separate guide.

Some people have been requesting a guide on adding a config to the code and I think it also doesn't belong in this file.

We can make a file with a "Contribution" guide that:

  1. refers people to this guide if they want to contribute by discovering their laptops' configs (this is a separate file because it is big)
  2. provides some specific info like FW naming and generations
  3. explains how to add a config to the code


| EC | BIOS | Series |
|:-------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------:|:-----------------------:|
| ${\color{red}xxxx}{\color{orange}b}{MS}{\color{yellow}n}{.}{\color{WildStrawberry}y}{\color{YellowOrange}zz}$ | ${E}{\color{red}xxxx}{\color{orange}b}{MS.}{\color{WildStrawberry}y}{\color{YellowOrange}zz}$ | Business/Creator/Gaming |
| ${\color{red}xxxx}{\color{orange}b}{WS}{\color{yellow}n}{.}{\color{WildStrawberry}y}{\color{YellowOrange}zz}$ | ${E}{\color{red}xxxx}{\color{orange}b}{WS.}{\color{WildStrawberry}y}{\color{YellowOrange}zz}$ | Workstation/CreatorPRO |

+ ${\color{red}xxxx}$ - model code
+ ${\color{orange}b}$ - CPU/EC vendor
+ For BIOS:
+ A - AMD CPU
+ I - Intel CPU
+ For EC:
+ E - ENE
+ I - ITE
+ ${\color{yellow}n}$ - EC / board(?) model
+ ${\color{WildStrawberry}y}{\color{YellowOrange}zz}$ - version
+ ${\color{WildStrawberry}y}$ - board generation; firmware is incompatible if different
+ ${\color{YellowOrange}zz}$ - firmware version

## Firmware generations
mutchiko marked this conversation as resolved.
Show resolved Hide resolved

Now we know about 2 firmware generations, which we call `WMI1` and `WMI2`. `WMI` is Windows component,
but MSI used `WMI2` name for the part that interacts with hardware via the Windows ACPI-WMI subsystem.

+ `WMI1`
+ Intel CPU Gen 10 based and older
+ All AMD based laptops, except Gaming series with 7 Gen CPU
+ `WMI2`
+ Intel CPU Gen 11 based and newer
+ Gaming series with AMD 7 Gen CPU and newer

## Common addresses
Binary file added docs/pics/support_guide/dl_rwe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pics/support_guide/hex_editor_how_to.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pics/support_guide/not_apply_changes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pics/support_guide/open_ec_tab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pics/support_guide/refresh_menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/pics/support_guide/run_as_admin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.