Linux configuration guide for Thinkpad x1 Carbon 6th Gen (2018)
This guide workable for Lenovo ThinkPad Ultrabook X1 Carbon Gen6 (20KH006HRT) After these steps, laptop works around 8-10 hourse on medium load.
Install Ubuntu 18.04
If touchpad andr/or trackpoint don't work on Ubuntu installer, add 'psmouse.synaptics_intertouch=1' to loader.
Install latest version of Linux Kernel
Firstly, after instalation, update Linux Kernel (because in kernels 4.17.x power management has improved) using UKUU:
$ sudo add-apt-repository ppa:teejee2008/ppa
$ sudo apt-get update
$ sudo apt-get install ukuu
$ sudo ukuu --check
$ sudo ukuu --install-latest
Touchpad & Trackpoint
- Edit the /etc/modprobe.d/blacklist.conf file and comment out following line:
# blacklist i2c_i801
- Edit the /etc/default/grub file and change line:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
to
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash psmouse.synaptics_intertouch=1"
- update grub:
$ sudo update-grub
- install xserver-synaptics:
$ sudo apt-get install xserver-xorg-input-synaptics
- Copy wakeup-control script from this repo to /lib/systemd/system-sleep/ for wakeup touchpad/trackpoint after sleep.
Deep sleep
Reboot, enter your BIOS/UEFI. Go to Config - Thunderbolt (TM) 3 - set Thunerbolt BIOS Assist Mode to Enabled. It has also been reported that Security - Secure Boot must be disabled.
Install iasl (Intel's compiler/decompiler for ACPI machine language) and cpio from your distribution.
Get a dump of your ACPI DSDT table.
$ cat /sys/firmware/acpi/tables/DSDT > dsdt.aml
- Decompile the dump, which will generate a .dsl source based on the .aml ACPI machine language dump.
$ iasl -d dsdt.aml
- Apply X1Y3_S3_DSDT.patch it against dsdt.dsl:
$ patch --verbose < X1C6_S3_DSDT.patch
Note: Hunk 6 may fail due to different specified memory regions. In this case, simply edit the (almost fully patched) dsdt.dsl file, search for and entirely delete the two lines reading solely the word "One". You can look at hunk 6 in the patch file to see how the lines above and below look like if you're unsure.
Plan B: If this does not work (patch is rejected): It has been the case, that certain UEFI settings may lead to different DSDT images. This means that it may be possible that the above patch doesn't work at all with your decompiled DSL. If that is the case, don't worry: Go through the .patch file in your editor, and change your dsdt.dsl by hand. This means locating the lines which are removed in the patch and removing them in your dsl. The patch contains only one section at the end which adds a few lines - these are important and make the sleep magic happen.
Make sure that the hex number at the end of the first non-commented line is incremented by one (reading DefinitionBlock, should be around line 21). E.g., if it was 0x00000000 change it to 0x00000001. Otherwise, the kernel won't inject the new DSDT table.
Recompile your patched version of the .dsl source.
$ iasl -ve -tc dsdt.dsl
- There shouldn't be any errors. When recompilation was successful, iasl will have built a new binary .aml file including the S3 patch. Now we have to create a CPIO archive with the correct structure, which GRUB can load on boot (much like initrd is loaded). We name the final image acpi_override and copy it into /boot/.
$ mkdir -p kernel/firmware/acpi
$ cp dsdt.aml kernel/firmware/acpi
$ find kernel | cpio -H newc --create > acpi_override
$ cp acpi_override /boot
- We yet have to tell GRUB to load our new DSDT table on boot in its configuration file. In Ubuntu, to allow this change to persist through kernel updates, you should add this to linux_entry() function initrd call in /etc/grub.d/10_linux:
--- 10_linux~ 2018-08-07 21:24:52.058669051 +0200
+++ 10_linux 2018-08-07 21:24:07.210436901 +0200
@@ -198,7 +198,7 @@
EOF
fi
sed "s/^/$submenu_indentation/" << EOF
- initrd ${rel_dirname}/${initrd}
+ initrd /boot/acpi_override ${rel_dirname}/${initrd}
EOF
fi
sed "s/^/$submenu_indentation/" << EOF
Note: GRUB updates might still overwrite this file (haven't had a GRUB update yet), but maybe it'll help to move this to eg. 11_linux to simply redefine linux_entry() function.
- Moreover, GRUB needs to boot the kernel with a parameter setting the deep sleep state as default. The best place to do this is /etc/default/grub, since that file is not going to be overwritten when the GRUB config becomes regenerated. Simply add mem_sleep_default=deep to the GRUB_CMDLINE_LINUX_DEFAULT configuration option. It should look somewhat like that:
GRUB_CMDLINE_LINUX_DEFAULT="quiet mem_sleep_default=deep"
- Reboot
If everything worked, you shouldn't see any boot errors and the kernel will confirm that S3 is working. The output of the following commands should look the same on your machine:
$ dmesg | grep ACPI | grep supports"
[ 0.213668] ACPI: (supports S0 S3 S4 S5)
$ cat /sys/power/mem_sleep
s2idle [deep]
In most setups, simply closing the lid will probably trigger deep sleep. If you're using a systemd-based distribution, you can also verify if it works on the command line:
$ systemctl suspend -i
low cTDP and trip temperature in Linux
This problem is related to thermal throttling on Linux, that is set much below the Windows values. This will cause your laptop to run much slower than it could under heavy stress.
Before you attempt to apply this solution, please make sure that the problem still exists when you read it. To do so, open a Linux terminal and run following commands:
$ sudo apt-get install msr-tools
$ sudo rdmsr -f 29:24 -d 0x1a2
If you see 3 as a result value (or 15 when running on battery), you don’t have to do anything. Otherwise:
Disable Secure Boot in the BIOS (won’t work otherwise)
Run this command:
sudo apt install git virtualenv build-essential python3-dev \
libdbus-glib-1-dev libgirepository1.0-dev libcairo2-dev
- Install lenovo-throttling-fix:
$ cd lenovo-throttling-fix/
$ sudo ./install.sh
Check again, that the result from running the rdmsr command is 3
If you want to change the default values, you need to edit the /etc/lenovo_fix file and set the Trip_Temp_C for both battery and AC the way you want:
[BATTERY]
# Other options here...
PL2_Tdp_W: 40
Trip_Temp_C: 75
[AC]
# Other options here...
PL1_Tdp_W: 34
PL2_Tdp_W: 40
Trip_Temp_C: 90
CPU undervolting
The amazing Lenovo Throttling fix script supports also the undervolting. To enable it, please edit the /etc/lenovo_fix.conf again and update the [UNDERVOLT] section. In my case, this settings proven to be stable:
[UNDERVOLT]
# CPU core voltage offset (mV)
CORE: -110
# Integrated GPU voltage offset (mV)
GPU: -90
# CPU cache voltage offset (mV)
CACHE: -110
# System Agent voltage offset (mV)
UNCORE: -90
# Analog I/O voltage offset (mV)
ANALOGIO: 0
Battery charging thresholds
$ sudo apt-get install tlp tlp-rdw acpi-call-dkms tp-smapi-dkms acpi-call-dkms
After that just edit the /etc/default/tlp file and edit following values:
# Uncomment both of them if commented out
START_CHARGE_THRESH_BAT0=45
STOP_CHARGE_THRESH_BAT0=95
Reboot, run:
sudo tlp-stat | grep tpacpi-bat
and check if the values are as you expect:
tpacpi-bat.BAT0.startThreshold = 45 [%]
tpacpi-bat.BAT0.stopThreshold = 95 [%]
You can change these thresholds anytime, and apply changes using command:
$ sudo tlp start
Note, that if you need to have your laptop fully charged, you can achieve that by running following command while connected to AC:
$ tlp fullcharge
Top comments (0)