Open cobaltbee opened 1 year ago
It failed because it expected the ID of the embedded controller to be 0x8227, but it read 0x5576. This model HACN BIOS firmware also does not seems to supported by the Windows tools LegionFanControl. It is one of the rare cases.
Maybe this model uses another chip. If you want to try to find the addresses in this chip, I could guide you through. It roughly works like that. Either, it can be easy, because you will find the embedded controller will use the same program/memory layout. Or, it is more complicated because it is completely different.
# Install requiered tools
sudo apt install acpica-tools
# Create folder for all the new files
mkdir acpi_re
cd acpi_re
# List ACPI tables and copy them
ls /sys/firmware/acpi/tables/
sudo cp --no-preserve=mode /sys/firmware/acpi/tables/*SDT* .
# Disassemble tables to output DSDT.dsl
iasl -e SSDT* -d DSDT
Then upload files.
Find the part for the embedded controller. It will contain something like this.
Device (EC0)
Name (_HID, EisaId ("PNP0C09") /* Embedded Controller Device */) // _HID: Hardware ID
Name (_UID, One) // _UID: Unique ID
Then find the regions used by the embedded controller. There are lots of other regions, but only these are interesting that are within the scope/braces of the embedded controller.
You will find something similar to this:
OperationRegion (ERAM, EmbeddedControl, Zero, 0xFF)
OperationRegion (ECMS, SystemIO, 0x72, 0x02)
OperationRegion (ERAX, SystemMemory, 0xFE00D400, 0xFF)
- mapped into memory at 0xFE00D400
- region with most of the fields defined
OperationRegion (ECB2, SystemMemory, 0xFF00D520, 0xFF)
- mapped into memory at 0xFF00D520
- region with most of the fields defined
This will show that registers/memory of the embedded controller is mapped to (CPU) memory address space. Note that these regions described in the ACPI tables above are only the registers/memory used directly in ACPI.
Often, much more registers/memory of the embedded controller are mapped to (CPU). Usually, these are before or after the regions mentioned in the ACPI tables.
Now we can read the memory mapped regions. Then we change something, e.g.
...
OK, thanks. Here you go, please see attached.
I see the first section you mention, but grep'ing for 'ERAM' and 'EmbeddedControl' shows nothing.
I had a lock at the files and found the string "embedded controller". It seems to be at the same memory address as others. I pushed a version (to main), that allows you just try it in readonly mode.
Try
# pull newest version
cd kernel_moodule
make
sudo make forcereloadmodulereadonly
cat /sys/kernel/debug/legion/fancurve
and check if this outputs a sensible fan curve. Otherwise, one would have to find different addresses in your different embedded controller.
Thanks a lot, I really appreciate it. The module now loads, although there are some errors...
[25137.962671] legion_laptop 0.1 starts loading
[25137.962677] Read identifying information: DMI_SYS_VENDOR: LENOVO; DMI_PRODUCT_NAME: 82K8; DMI_BIOS_VERSION:HACN39WW
[25137.962742] legion PNP0C09:00: legion_laptop platform driver 0.1 probing
[25137.962744] Read identifying information: DMI_SYS_VENDOR: LENOVO; DMI_PRODUCT_NAME: 82K8; DMI_BIOS_VERSION:HACN39WW
[25137.962747] legion PNP0C09:00: is_denied: 0; is_allowed: 1; do_load_by_list: 1; do_load: 1
[25137.962748] legion PNP0C09:00: legion_laptop is forced to load.
[25137.962749] legion PNP0C09:00: Using configuration for system: HACN
[25137.962764] Succeffuly mapped embedded controller: 0xfe00d400 to virtual 0x00000000e53d72d3
[25137.962767] Unexpected read at offset 8192 into EC RAM
[25137.962768] Error reading EC RAM at 0x2000
[25137.962769] Unexpected read at offset 8193 into EC RAM
[25137.962769] Error reading EC RAM at 0x2001
[25137.962770] legion PNP0C09:00: Read embedded controller ID 0x0
[25137.962771] legion PNP0C09:00: Skipped checking embedded controller id
[25137.962772] legion PNP0C09:00: Creating debugfs inteface
[25137.962778] Creating sysfs inteface
[25137.962780] Creating hwmon interface
[25137.962830] Creating platform profile support
[25137.962833] Init WMI driver support
[25137.962862] legion_wmi 887B54E3-DDDC-4B2C-8B88-68A26A8835D0: Register after probing for WMI.
[25137.962884] legion_wmi BFD42481-AEE3-4501-A107-AFB68425C5F8: Register after probing for WMI.
[25137.962892] legion_wmi BFD42481-AEE3-4502-A107-AFB68425C5F8: Register after probing for WMI.
[25137.962901] legion_wmi D062906B-12D4-4510-999D-4831EE80E985: Register after probing for WMI.
[25137.962909] legion_wmi BC72A435-E8C1-4275-B3E2-D8B8074ABA59: Register after probing for WMI.
[25137.962917] legion_wmi 10AFC6D9-EA8B-4590-A2E7-1CD3C84BB4B1: Register after probing for WMI.
[25137.962924] legion_wmi D320289E-8FEA-41E0-86F9-611D83151B5F: Register after probing for WMI.
[25137.962944] legion PNP0C09:00: legion_laptop loaded for this device
... but the fan curve isn't right, and using setmyfancurve.sh
doesn't seem to change anything.
LenovoLegionLinux on main
❯ sudo ./setmyfancurve.sh
MODEL
Legion S7 15ACH6
BIOS
HACN39WW
Using hwmon directory: /sys/module/legion_laptop/drivers/platform:legion/PNP0C09:00/hwmon/hwmon7
Writing fancurve succesful!
EC Chip ID: 0
EC Chip Version: 0
legion_laptop version: 0.1
legion_laptop features: fancurve powermode platformprofile platformprofilenotify minifancurve
legion_laptop ec_readonly: 0
minifancurve on cool: error
lock fan controller: false
enable maximumfanspeed: false
enable maximumfanspeed status: 0
fan curve current point id: 10
fan curve points size: 10
Current fan curve in hardware (embedded controller):
rpm1|rpm2|acceleration|deceleration|cpu_min_temp|cpu_max_temp|gpu_min_temp|gpu_max_temp|ic_min_temp|ic_max_temp
25500 25500 255 255 255 255 255 255 255 255
25500 25500 255 255 255 255 255 255 255 255
25500 25500 255 255 255 255 255 255 255 255
25500 25500 255 255 255 255 255 255 255 255
25500 25500 255 255 255 255 255 255 255 255
25500 25500 255 255 255 255 255 255 255 255
25500 25500 255 255 255 255 255 255 255 255
25500 25500 255 255 255 255 255 255 255 255
25500 25500 255 255 255 255 255 255 255 255
25500 25500 255 255 255 255 255 255 255 255
=====================
Writing fancurve succesful!
MODEL
Legion S7 15ACH6
BIOS
HACN39WW
It seems like your embedded controller uses different addresses or is a totally different chip. Try pulling, compiling, loading again (I fixed dumping the whole EC memory) and run
cat /sys/kernel/debug/legion/ecmemory | hexdump -C
before and after you change the power mode with Fn+Q. Try to find which values change and which could represent the fan curve.
Hi, are there any updates for this issue? If you'd like any more data from real hardware I have this laptop and am open for any help.
Hello, thanks for the great project, I couldn't believe my eyes when I saw the post on r/LenovoLegion, and I hope mods will sticky your thread soon for more visibilty.
I have a Legion S7-15ACH6 - Type 82K8 aka 2021 Slim 7 that unfortunately has problems loading the module. I have tried the 'forceloadmodule' option mentioned in another thread here, but no luck. Let me know if you need any further details from me, glad to provide whatever you need.
Info about the system:
Top of 'dmesg'