Linux on Lenovo TP-T420i

Thinkpad-T420i

Hardware Specs

  Processor        Intel Core i3-2350M 2.30GHz (3MB L2 cache)
  Video            Intel Sandybridge GT2 (GMA HD-3000) with external VGA and DP
  Memory           4096MB DDR3 RAM 1333MHz(Hynix)
  HDD              WesternDigital WD5000LPVT 500GB (SATA, 5400rpm)
  Optical          HL-DT-ST DVDRAM GSA-T50N (DVDRW, DL 24x)
  Sound            Intel HD Audio (Conexant CX20590) with int. microphone
  Display          14.0 inch Active Matrix TFT 1600x900 max
  Networking       Intel 82579LM Gigabit ethernet and Intel Centrino 6205AGN wireless
  Broadband        Ericsson mobile broadband (0bdb:1911)
  Bluetooth        Broadcom (0a5c:217f)
  Touchpad         UltraNav, Synaptics PS/2 and a TPPS/2 TrackPoint
  USB              4 x 2.0 USB ports
  PC Express       1 x PC-Express port /34
  CardReader       Ricoh 4-in-1 (SD/SDHC/SDXC/MMC)
  WebCam           Chicony, UVC webcam (1199:9013)

Recent Changes

  * Dec 12 power button acpid event trigger
  * Dec 10 new and complete acpid event handler script
  * Dec 09 extra pageup/pagedown key mappings
  * Dec 05 cpufreq updates, BIOS frequency overrides
  * Nov 11 tp_smapi tested, fancontrol tested
  * Oct 28 initial version of the article

System Installation


If you're wondering; this laptop works fine with GNU/Linux and you should have no doubts about buying it or switching to GNU/Linux. In fact, this is the best laptop I've ever owned or used, so I bought two, one for the office and one for personal use.

Just make sure to choose a distribution that had a release recently.

lspci

00:00.0 Host bridge: Intel Corporation 2nd Generation Core Processor Family DRAM Controller (rev 09)
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)
00:16.0 Communication controller: Intel Corporation 6 Series/C200 Series Chipset Family MEI Controller #1 (rev 04)
00:19.0 Ethernet controller: Intel Corporation 82579LM Gigabit Network Connection (rev 04)
00:1a.0 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #2 (rev 04)
00:1b.0 Audio device: Intel Corporation 6 Series/C200 Series Chipset Family High Definition Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 1 (rev b4)
00:1c.1 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 2 (rev b4)
00:1c.3 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 4 (rev b4)
00:1c.4 PCI bridge: Intel Corporation 6 Series/C200 Series Chipset Family PCI Express Root Port 5 (rev b4)
00:1d.0 USB controller: Intel Corporation 6 Series/C200 Series Chipset Family USB Enhanced Host Controller #1 (rev 04)
00:1f.0 ISA bridge: Intel Corporation QM67 Express Chipset Family LPC Controller (rev 04)
00:1f.2 SATA controller: Intel Corporation 6 Series/C200 Series Chipset Family 6 port SATA AHCI Controller (rev 04)
00:1f.3 SMBus: Intel Corporation 6 Series/C200 Series Chipset Family SMBus Controller (rev 04)
03:00.0 Network controller: Intel Corporation Centrino Advanced-N 6205 [Taylor Peak] (rev 34)
0d:00.0 System peripheral: Ricoh Co Ltd PCIe SDXC/MMC Host Controller (rev 08)

Kernel

At the moment I'm running a 3.6.9 kernel provided by Arch. It's a very well configured kernel, very modular, and everything works OK with it. I have no intention of compiling my own for now, so I don't provide a kernel config file like some articles do.

Installation

I partitioned the hard drive during installation:
  Disk:
      /dev/sda
  Partitions:
      /dev/sda1 - 200MB - ext2 - /boot  (* flagged bootable)
      /dev/sda2 -  50GB - ext3 - /
      /dev/sda3 -   2GB - swap - swap space
      /dev/sda4                - extended
      /dev/sda5 - 200GB - ext3 - /home
      /dev/sda6 - 210GB - ext3 - /mnt/storage
I booted the core CD and walked trough the setup. With Arch Linux you partition your drive(s), edit crucial config files like /etc/{rc,resolv,lilo}.conf ..., and install core packages. Once the system was running I updated the pacman (Arch package manager) database and installed everything else; X.org, graphic and audio drivers, libraries, window manager... everything you need on a workstation.

System Configuration


X11

For the initial setup I run xorgconfig, then edited xorg.conf to fine tune it. Graphics runs fine with the vesa driver, however I did install the opensource intel driver (xf86-video-intel) and that's what I'm using now.

Optimus graphics

I detected no Nvidia Optimus graphics on this specific model. There was no mention of it anywhere in the system BIOS. If that is true I feel relieved, this is my workstation and I don't need Nvidia draining my battery, or having to deal with Bumblebee. There were also some indications that conncting external monitors through the DP would only work with the Nvidia card, I certainly didn't want that happening.

DP / External VGA

Both cloned and extended displays are possible with this chip/driver. For a static configuration you can take a look at my xorg.conf, but xrandr is widely used today for dynamic, on the fly setup and (re)configuration.

Backlight

The backlight controls (and buttons) do work trough the ACPI video module, but I noticed brightness level is reset on next boot. This is what I added to my ~/.xinitrc to fix it in X11:
  # Brightness level
  # - xbacklight doesn't work with legacy, set level first
  xbacklight -set 16

  # Legacy control could solve resetting brightness levels
  #xrandr --output LVDS1 --set BACKLIGHT_CONTROL legacy

Framebuffer

Since Linux 2.6.32 the KMS (Kernel Mode Setting) support for Intel graphics is finally reliable. When using KMS no vga lines are required in your bootloader configuration, correct resolution is auto-detected.

Synaptics

The driver is now a part of X.org (xf86-input-synaptics), old project page can be found here, as for setting it up feel free to copy the config from my xorg.conf.d file. All the touchpad buttons work, including those below the trackpoint (and the trackpoint it self). Once you setup synaptics you also get tapping and scrolling functionality on the touchpad it self.

Extra keys

Most of the keys work out of the box, except the "document navigation" buttons which are recognized but just aren't properly mapped. Since the laptop is brand new I didn't have time yet to submit a fix to the udev keymaps project. Note that the mute button and brightness control buttons work in hardware, no userspace mappings are necessary.

The two fw/bck "document navigation" keys are easily mapped with xmodmap, I chose to use them as an extra pair of PgUP/DN keys much easier to press than the pair in the top right corner of the keyboard. Added to ~/.Xmodmap:
!
! Fix ergonomic problems
! 
! Use Menu as a slash
keycode 135 = slash
!
! Alternative PgUP/DN on ThinkPad
keycode 112 = Page_Up
keycode 117 = Page_Down

ACPI

All ACPI modules work fine (battery, button, processor, thermal, video), including the extra thinkpad_acpi module/driver which provides some good features from RF-KILL and fan control, to LED support.

In userspace you can install acpitool or ACPI Client which replicate behavior of the old "apm" command, thus giving you temperature, battery... and all kind of other information.

Processor frequency scaling is possible with this CPU (see the cpufreq section). Also note that newer Linux kernels no longer have a fixed 1000Hz timer tick. The result (in theory) is huge power savings because the CPU stays in low power mode for longer periods during system idle. For other ways of saving power read sections below this one, and visit the LessWats project.

Suspend

You can choose between uswsusp, tuxonice and direct kernel suspend/hibernate. Uswsusp is completely software based, doesn't require any kernel modifications and gives you the possibility to use quirks and compress (+ encrypt) images during hibernation. I use it in combination with pm-utils, which is now the standard power management framework on every distribution and supports all three mentioned suspend methods.

acpid

To setup acpid take a look in /etc/acpi, I mapped the power key to do a clean shutdown, Fn+Sleep to suspend, Lid closing to lock the desktop and AC events start laptop-mode-tools. My complete handler file is here.

Note that the power button does not emit an acpid even on a short key-press. It will emit a PBTN power button event only if pressed for >1 second. I'm not overly fond of this because a lot of machines will simply stop power if the power button is held for too long.

laptop-mode

Laptop-mode-tools is a laptop power saving package for Linux systems (a shell script and a bunch of config files really). I configured acpid to call it when I switch to/from battery power (see my handler script above). It can enable the Laptop Mode feature of the kernel, control CPU throttling, HDD power management, remount your partitions and setup the system do to less frequent writes, enable power saving for Intel HDA sound cards and Intel's SATA controllers, stop/start services and programs, remove modules... and a whole lot more (+ restoring the system to original state when AC is plugged in).

cpufreq

Install cpufrequtils first, then load the acpi-cpufreq module. Run cpufreq-info next to see what are your options. I chose not to use the cpufreq daemon or any utility other than laptop-mode-tools. I configured its cpufreq module to use the conservative governor (load cpufreq_conservative module) while on battery, with max and min frequencies identical to what cpufreq-info reported as max/min. Otherwise when on AC I decided to always use the performance governor (default, no modules to load).

Note that the BIOS can force the system to remain at a lower frequency even while using the "performance" governor, making for some jerky video watching. I configured the SpeedStep mode for battery to "maximum performance", and did the same for Adaptive Thermal Management scheme for battery. I appreciate it but I prefer to control my own power savings using cpufreq and laptop-mode-tools.

fancontrol

This could be in the lm_sensors section below, but it's more relevant in the ACPI and vendor drivers section. The lm_sensors package provides a simple daemon for controlling fan(s) and it works perfectly fine with this model. My own configuration file is available here. In recent time a project called thinkfan gained some popularity. But I found it overly complicated (compared to fancontrol), and powerful enough to destroy hardware by simple missconfiguration.

APS

The hdaps module refuses to load with an "No such device " message. To get proper HDAPS support you need the tp_smapi driver which also includes an alternative hdaps module/driver. After verifying it works I stopped there as I have no interest in running complicated userspace components to detect movements on my stationary workstation. So unfortunately there's nothing else I can contribute.

SMAPI

I have the tp_smapi driver installed but I didn't get to experiment with battery charging levels yet. Apparently it's best to maintain a battery charge that is between 40% and 80%, and this driver should make it possible to stop charging when 80% is reached (or stop discharging when 40% is reached). Here's a configuration tutorial until I have something to add based on my own experience.

Multimedia

This particular Intel HDA is supported by alsa, fortunately udev will load the modules (snd_hda_intel...) for you. First you must run alsamixer to unmute the channels, then store your config with alsactl store, that's it. Built in microphone also works, you should max out your Capture channels in alsamixer and then try to record something with a utility like arecord:
  $ arecord -f cd -d 3 -t wav -N test.wav
If you have problems with autodetection of the model, or the results are not as good as you hoped for (small number of channels, low sound...) try to specify the model in /etc/modprobe.conf:
  options snd-hda-intel model=basic
I found that auto(detection) gives best results in terms of mixers, support and capture. The speakers are properly auto-muted when headphones are connected.

I noticed that applications which rely on OSS always see PCM channel as muted and they can't control it. Another issue was with games that use OSS, like enemy-territory, they had no sound. This was added to the system init (rc.local):
  # OSS emulation mixer fix
  #   PCM alsa control isn't auto. mapped to OSS equivalent
  echo 'PCM "PCM" 0' > /proc/asound/card0/oss_mixer
  # Enemy Territory sound fix
  echo "et.x86 0 0 direct" > /proc/asound/card0/pcm0p/oss

Webcam

This webcam is supported trough the UVC driver, once installed I tested it with ffmpeg and kopete it was also reported to work with Skype... you can also check luvcview which I guess gives some more control over the picture. Since Linux 2.6.26 UVC is part of the kernel, module is uvcvideo. Also above the webcam there's a ThinkLight device, a keyboard light toggled by Fn+PgUp.

Card Reader

The hardware is recognized and supported, but I only had an SD card for testing. Be sure that the correct modules are loaded depending on the card you're inserting (tifm_core, tifm_sd, tifm_7xx1, mmc_core, sdhci, sdhci_pci...).

Networking

Provided ethernet card works OK with the e1000e module. I also have an external USB card that works fine with the pegasus module.

Wireless

This card is covered with a driver from the iwlagn/iwlwifi project, complete with injection support. Depending on the kernel you're using read their instructions carefully about which driver to use and which firmware to cut. I also own an Atheros PCMCIA card, those chips always had great support. People at the MadWifi project are doing a great job. If you're buying wifi hardware consider something with an Atheros chip.

My kismet.conf looks like this:
  ...
  ncsource=wlan0:type=mac80211,name=intel
  ncsource=wlan1,type=mac80211,name=atheros
  #ncsource=ath0,type=madwifi_g,name=madwifi
  ...
  # I switch these depending on cards running at the moment
  enablesources=intel
  #enablesources=atheros
  #enablesources=madwifi
  #enablesources=atheros,intel
  #enablesources=madwifi,intel
  ...

Bluetooth

I didn't personally verify this chipset works, others claim it does. But from previous experience I can tell you that once bluetooth, btusb and the rest of the modules are loaded; You need to install bluez-libs, bluez-utils and optional some GUI utility, like kdebluetooth set of tools. There are many guides available, one that set me going in no time was Gentoo's Bluetooth Guide. For more specific usage like using your mobile phone as a modem or remote control you can check the docs on BlueZ.

i2c / lm_sensors / hddtemp

The lm_sensors picked up the CPU sensor (coretemp module) and the thinkpad-isa fan device. You can also get thermal readings from ACPI. If you install hddtemp you can also get thermal readings from SMART for your hard drives, it works OK with this HDD model. You can get those with smartctl as well.

sysctl

For the record my sysctl.conf looks like this:
  #
  # Kernel sysctl configuration
  #
  
  # Magic-sysrq key
  kernel.sysrq=1
  
  # Custom memory settings
  vm.swappiness=1
  #vm.overcommit_memory=2
  vm.vfs_cache_pressure=50

Screenshot

screenshot1

Final Note

I would suggest to use some of these stickers instead of that ugly sticker that comes shipped with the laptop: http://www.openstickers.com/

You can find my contact info on my home page http://sysphere.org/~anrxc/, I would be glad to hear from you with some suggestions or solutions, or possibly be of some help to you (but please note that I have no time for users too lazy to read any kind of documentation). Thank you, anrxc.