BeardOverflow / msi-ec

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

Errors when "make older-kernel-patch" in MSI Modern 14 B5M-224xes with Xubuntu 22.04 LTS #123

Open ekoanimal opened 4 months ago

ekoanimal commented 4 months ago

Laptop model

MSI Modern 14 B5M-224xes

EC firmware version

14DLEMS1.105

Description

Hi all. This is my first post in GitHub so I hope this is the right place to ask something. If it's not the place, please let me know. I own an MSI Modern 14 B5M-224xes where I use Xubuntu 22.04 LTS. I noticed that the battery is being drained since some months ago maybe because there is no management software aside from the one in Xubuntu (quite poor). Now the battery charged at 100% fluctuates between 63-68% of it's original capacity. I assume that the battery has been permanently damaged and I must replace it. But before replacing it I'd like to solve the power management issue. That's how I found you :) I tried to install msi-ec even knowing that my device has not been tested. Well, maybe I'm the first.... I installed dependencies and so on, but when I get to the point of "make older-kernel-patch" I get the following errors:

git apply older-kernel.patch
error: patch failed: msi-ec.c:45
error: msi-ec.c: patch does not apply
make: *** [Makefile:12: older-kernel-patch] Error 1

The kernel I'm using is 5.15.0-107-generic and the EC firmware is 14DLEMS1.105. If you need any other info just let me know. I'm no linux expert at all so maybe I'm doing something wrong. Can you help me with this? Thank a lot!

MrThunder02 commented 4 months ago

Hi. Just install Liquorix kernel or Xanmod then install msi-ec. And seems your EC doesnt listed in msi-ec.c file

glpnk commented 4 months ago

I'm running Pop OS which is based on Ubuntu 22.04 and running Xanmod kernel. Don't try edge version, because seems like 6.9.1 version use different glibc and it fails to compile. Xanmod-Main should work for you. You can try to update Xubuntu to 24.04 if it exists, or try to use Ubuntu repos which definitely contains all required updates.

I need to try to apply patch myself now

Seems that some breaking changes happened from time of creation of this patch

Also, your model isn't supported yet, so feel free to send EC dump to #64 where it was discussed earlier

glpnk commented 4 months ago

Weird, JB Rider could apply this patch, git not

Ok, reference points changed a bit, so you can use the new patch below. You can check differences with old patch with meld or similar tool

glpnk commented 4 months ago
diff --git a/msi-ec.c b/msi-ec.c
--- a/msi-ec.c  (revision 8632888bec84724f3521261286ccf4a9f9f56f7d)
+++ b/msi-ec.c  (date 1716422285753)
@@ -46,6 +46,7 @@
 #include <linux/seq_file.h>
 #include <linux/string.h>
 #include <linux/slab.h>
+#include <linux/version.h>

 #define SM_ECO_NAME        "eco"
 #define SM_COMFORT_NAME        "comfort"
@@ -1903,14 +1904,22 @@

 ATTRIBUTE_GROUPS(msi_battery);

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,2,0)
 static int msi_battery_add(struct power_supply *battery,
               struct acpi_battery_hook *hook)
+#else
+static int msi_battery_add(struct power_supply *battery)
+#endif
 {
    return device_add_groups(&battery->dev, msi_battery_groups);
 }

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,2,0)
 static int msi_battery_remove(struct power_supply *battery,
                  struct acpi_battery_hook *hook)
+#else
+static int msi_battery_remove(struct power_supply *battery)
+#endif
 {
    device_remove_groups(&battery->dev, msi_battery_groups);
    return 0;
glpnk commented 4 months ago

@ekoanimal Before changing battery, try to calibrate on Windows with MSI app, or reduce charging maximum value. Assuming if you're running both Linux and Windows

ekoanimal commented 4 months ago
diff --git a/msi-ec.c b/msi-ec.c
--- a/msi-ec.c    (revision 8632888bec84724f3521261286ccf4a9f9f56f7d)
+++ b/msi-ec.c    (date 1716422285753)
@@ -46,6 +46,7 @@
 #include <linux/seq_file.h>
 #include <linux/string.h>
 #include <linux/slab.h>
+#include <linux/version.h>

 #define SM_ECO_NAME      "eco"
 #define SM_COMFORT_NAME      "comfort"
@@ -1903,14 +1904,22 @@

 ATTRIBUTE_GROUPS(msi_battery);

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,2,0)
 static int msi_battery_add(struct power_supply *battery,
             struct acpi_battery_hook *hook)
+#else
+static int msi_battery_add(struct power_supply *battery)
+#endif
 {
  return device_add_groups(&battery->dev, msi_battery_groups);
 }

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,2,0)
 static int msi_battery_remove(struct power_supply *battery,
                struct acpi_battery_hook *hook)
+#else
+static int msi_battery_remove(struct power_supply *battery)
+#endif
 {
  device_remove_groups(&battery->dev, msi_battery_groups);
  return 0;

Thanks Glpnk (and the rest) I applied the patch to "older-kernel.patch" but unfortunately I get the following error :S

git apply older-kernel.patch
error: corrupt patch at line 34
make: *** [Makefile:12: older-kernel-patch] Error 128

Regarding changing the kernel, I don't like the idea unless it is strictly necessary. And using windows is not an option for me in this laptop at this moment.

glpnk commented 4 months ago

@teackot Hi, can you fix patch?

@ekoanimal Hi, I applied it for you, download and install it

git clone -b old-kernel-patch https://github.com/glpnk/msi-ec.git
ekoanimal commented 4 months ago

@teackot Hi, can you fix patch?

@ekoanimal Hi, I applied it for you, download and install it

git clone -b old-kernel-patch https://github.com/glpnk/msi-ec.git

I downloaded and typed "make older-kernel-patch" in the terminal with the following result:

git apply older-kernel.patch
error: patch failed: msi-ec.c:45
error: msi-ec.c: patch does not apply
make: *** [Makefile:12: older-kernel-patch] Error 1

Maybe I'm doing something wrong?

glpnk commented 4 months ago

You don't need to apply this patch, because it applied in this branch. Just download it again in new folder and install with this commands

git clone -b old-kernel-patch https://github.com/glpnk/msi-ec.git
cd msi-ec
make
sudo make install
ekoanimal commented 4 months ago

Hi, I get the following after "make":

make[1]: Entering directory '/usr/src/linux-headers-5.15.0-107-generic'
  CC [M]  /home/eu/Escritorio/msi-ec/msi-ec.o
  MODPOST /home/eu/Escritorio/msi-ec/Module.symvers
  CC [M]  /home/eu/Escritorio/msi-ec/msi-ec.mod.o
  LD [M]  /home/eu/Escritorio/msi-ec/msi-ec.ko
  BTF [M] /home/eu/Escritorio/msi-ec/msi-ec.ko
Skipping BTF generation for /home/eu/Escritorio/msi-ec/msi-ec.ko due to unavailability of vmlinux
make[1]: Leaving directory '/usr/src/linux-headers-5.15.0-107-generic'

I proceeded with "sudo make install" and I get the following error:

mkdir -p /lib/modules/5.15.0-107-generic/extra
cp msi-ec.ko /lib/modules/5.15.0-107-generic/extra
depmod -a
echo msi-ec > /etc/modules-load.d/msi-ec.conf
modprobe -v msi-ec
libkmod: ERROR ../libkmod/libkmod-config.c:712 kmod_config_parse: /etc/modprobe.d/blacklist.conf line 55: ignoring bad line starting with 'dvb_usb_rtl28xxu'
libkmod: ERROR ../libkmod/libkmod-config.c:712 kmod_config_parse: /etc/modprobe.d/blacklist.conf line 56: ignoring bad line starting with 'rtl2832'
insmod /lib/modules/5.15.0-107-generic/extra/msi-ec.ko 
modprobe: ERROR: could not insert 'msi_ec': Operation not supported
make: *** [Makefile:38: install] Error 1
glpnk commented 4 months ago

Do you have secure boot enabled or module signing? Or try installing with dkms with

sudo make dkms-install
ekoanimal commented 4 months ago

Hi, Sorry for the delay. I tried with :

sudo make dkms-install

It shows no errors but I think it did not install correctly. I can't find the kernel module or maybe it is blocked somehow.

Anyway, I noticed that there is a new version of Xubuntu (24.04) released some days ago with Kernel 6.8. I will try a live version and see how it works :) If everything works fine I will go and update to 24.04 next month. Maybe it's the fastest and easiest solution.

I will let you know here if everything works fines :) In case it does not work, well.... we can continue fighting.

Thanks a lot! Really!

glpnk commented 4 months ago

Srems that it installed succesfully, but not started. You need to reboot after dkms installation or load it manually. But after manual loading, power service don't register new device.

BTW, your model is not supported, so you can open new issue about adding your model

ekoanimal commented 4 months ago

Hi Glpnk, I rebooted after installation, but as you say it is not loaded. I tried to manually access the folder "/sys/devices/platform/msi-ec/" but it does not exist. Unfortunately I don't know how to manually load it but don't worry I will try the option of installing Xubuntu 14.04 with kernel 6.8.

I have also opened a new issue asking for support for my model as you recommended:

https://github.com/BeardOverflow/msi-ec/issues/124

Thanks a lot you your support.

BTW, I am not a programmer but I speak several languages and can manage quite well with design, so if I can help with something here, just let me know.

glpnk commented 4 months ago

Ok, thanks, can you share output of this command in #124 please, it does similar thing as debug mode

sudo hexdump /sys/kernel/debug/ec/ec0/io -C