• Stars
    star
    143
  • Rank 255,521 (Top 6 %)
  • Language
    Shell
  • Created about 6 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Linux configuration guide for Thinkpad x1 Carbon 6th Gen (2018)

Linux configuration guide for Thinkpad x1 Carbon 6th Gen (2018)

This guide workable for Lenovo ThinkPad Ultrabook X1 Carbon Gen6 (20KH006HRT) and Ubuntu 18.04. After these steps, laptop works around 8-10 hourse on medium load.

If you follow this guide, no one is responsible for any damage to your hardware or any other kind of harming your machine.

Results

As a result of these actions I get power statistic like this: power_statistic

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

  1. Edit the /etc/modprobe.d/blacklist.conf file and comment out following line:
# blacklist i2c_i801
  1. 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"
  1. update grub:
$ sudo update-grub
  1. install xserver-synaptics:
$ sudo apt-get install xserver-xorg-input-synaptics
  1. Copy wakeup-control script from this repo to /lib/systemd/system-sleep/ for wakeup touchpad/trackpoint after sleep.

Deep sleep

  1. 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.

  2. Install iasl (Intel's compiler/decompiler for ACPI machine language) and cpio from your distribution.

  3. Get a dump of your ACPI DSDT table.

$ cat /sys/firmware/acpi/tables/DSDT > dsdt.aml
  1. Decompile the dump, which will generate a .dsl source based on the .aml ACPI machine language dump.
$ iasl -d dsdt.aml
  1. 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.

  1. 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.

  2. Recompile your patched version of the .dsl source.

$ iasl -ve -tc dsdt.dsl
  1. 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
  1. 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.

  1. 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"
  1. 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 (most of which are), you can also verify if it works on the command line:

$ systemctl suspend -i

Once again, many thanks to Ranguvar for the great collaboration on the Arch forums, and to fiji-flo for managing to hack the first fully working patch. Also, to whomever wrote the article on DSDT patching in the glorious Arch Wiki. And the entire Arch community in general, you're wonderful.

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:

  1. Disable Secure Boot in the BIOS (won’t work otherwise)
  2. Run this command:
sudo apt install git virtualenv build-essential python3-dev \
  libdbus-glib-1-dev libgirepository1.0-dev libcairo2-dev
  1. Install lenovo-throttling-fix:
$ cd lenovo-throttling-fix/
$ sudo ./install.sh

Check again, that the result from running the rdmsr command is 3

Personally, I use a bit lower temperature levels to preserve battery life in favor of performance. 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

There are a lot of theories and information about ThinkPad charging thresholds. Some theories say thresholds are needed to keep the battery healthy, some think they are useless and the battery will work the same just as it is. In this article I will try not to settle that argument. πŸ™‚ Instead I try to tell how and why I use them, and then proceed to show how they can be changed in different versions of Windows, should you still want to change these thresholds.

I always stick with following settings for my laptops (and somehow I feel that it works):

  • Start threshold: 45%
  • Stop threshold: 95%

This means that the charging will start only if the battery level goes down below 45% and will stop at 95%. This prevents battery from being charged too often and from being charged beyond a recommended level.

To achieve this for Linux based machines you need to install some packages by running:

$ 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

More Repositories

1

stable_diffusion.openvino

Python
1,533
star
2

MobileStyleGAN.pytorch

An official implementation of MobileStyleGAN in PyTorch
Python
662
star
3

crnn-pytorch

Pytorch implementation of OCR system using CRNN + CTCLoss
Python
216
star
4

mean_average_precision

Mean Average Precision for Object Detection
Python
192
star
5

random_face

A simple python library for fast image generation of people who do not exist.
Python
177
star
6

mpl.pytorch

Pytorch implementation of MaxPoolingLoss.
Python
175
star
7

pytorch_clip_guided_loss

A simple library that implements CLIP guided loss in PyTorch.
Python
77
star
8

VIBE

VIBE Background Subtractior
C++
67
star
9

pytorch_clip_bbox

Pytorch based library to rank predicted bounding boxes using text/image user's prompts.
Python
51
star
10

ESOINN

An enhanced self-organizing incremental neural network for online unsupervised learning
C++
28
star
11

vqvae_dwt_distiller.pytorch

Python
26
star
12

HandDetector

Hand and Fingertip Detecot with OpenCV
C++
25
star
13

SOINN

Self-Organizing and Incremental Neural Networks
C++
20
star
14

haar_pytorch

Pytorch implementation of forward and inverse Haar Wavelets 2D
Python
18
star
15

libGNG

Growing Neural Gas
C++
12
star
16

story-diffusion-runpod-serverless-worker

StoryDiffusion serverless worker
Python
9
star
17

stable_diffusion_quantizer.pytorch

Custom pipelines for stable diffusion model
Python
6
star
18

pytorch_clip_interrogator

Image-to-prompt reconstruction.
Python
4
star
19

smart_pdf

Summarize PDF by LLM
Python
4
star
20

SandboxCV

SandboxCV: sandbox for some computer vision algorithms
C++
2
star
21

pytorch_clip

Pytorch API to work with CLIP models.
Python
2
star
22

random_prompt

Random Prompt generator for ArtWork creation
Python
2
star
23

CloudsStitcher

Framework for stitching point clouds
C++
2
star
24

tts-runpod-serverless-worker

Serverless implementation of Text-To-Speech
Python
2
star
25

PTAM

Implementation of the PTAM as crossplatform library
C++
1
star
26

pybind11_template

Template of python wrapper for C++ class using pybind11+CMake
Python
1
star
27

image_to_sticker

Convert image to sticker
Python
1
star
28

text_to_speech_lab

Some experiments with TTS pipelines
Python
1
star