FreeBSD on Lenovo ThinkPad X230

Last modified: 2019/12/30

back


Beastie

The ThinkPad X230 is well-supported by FreeBSD 11. You can find some hints on the system configuration here.

Table of Contents

  1. Overview
  2. Trackpoint
  3. Power Management
  4. Suspend/Resume
  5. Audio
  6. Volume Keys
  7. Screen
  8. Screen Brightness
  9. Wi-Fi
  10. Card Reader

Overview

NameCommentStatus
Audiosnd_hda(4) driver, set device hintsworks
Bluetoothworks
Camerauntested
DisplayPortuse xrandr(1)works
Docking stationworks
Ethernetem(4) driverworks
Finger print sensoruntested
Fn keyswith acpi_ibm(4)works
Hibernatefails
Suspend/resumeacpiconf(8)works
TrackPointworks
Touchpaduntested
USBworks
VGAuse xrandr(1)works
Wi-Fiiwn(4) driverworks

Trackpoint

You may want to disable the Touchpad in BIOS in order to use the Trackpoint of the X230. Then, edit /etc/rc.conf and add:

moused_enable="YES"
moused_flags="-V"

Power Management

For power management, you can either use powerd(8) or sysutils/powerdxx. To use powerd, edit /etc/rc.conf and add:

powerd_enable="YES"
powerd_flags="-a hiadaptive -b adaptive"
performance_cx_lowest="C2"

Or install powerd++ with:

# pkg install powerdxx
# sysrc powerdxx_enabled="YES"

Suspend/Resume

Suspend/resume on the X230 is supported by FreeBSD 11. You can test the power management with:

# acpiconf -s 3

This should perform a suspend to RAM. Press the power button to resume. You will need security/sudo to suspend with non-root privileges. Edit /usr/local/etc/sudoers (use visudo) and add:

%operator ALL=(root) NOPASSWD: /usr/sbin/zzz

Edit your .cshrc and set a new alias:

alias zzz /usr/local/bin/sudo /usr/sbin/zzz

You can now suspend as a user by running zzz. Execute zzz from your Window Manager by calling tcsh -c zzz. If you like to use the Fn key (Fn + F4) to suspend, load the acpi_ibm(4) kernel module. Add to /boot/loader.conf:

acpi_ibm_load="YES"

Audio

Audio output is provided by the snd_hda(4) driver. Load the kernel module at boot time by editing /boot/loader.conf:

snd_hda_load="YES"

To change between speaker and headphones you have to add the following lines to /boot/device.hints:

hint.hdaa.0.nid20.config="as=1 seq=0 device=Speaker"
hint.hdaa.0.nid21.config="as=1 seq=15 device=Headphones"

Volume Keys

Load the acpi_ibm(4) kernel module to use the volume keys above the keyboard. Edit /boot/loader.conf and add:

acpi_ibm_load="YES"

Raising and lowering the volume using the volume keys will work now in applications like VLC. You have to configure your Window Manager to map keypress events. For FVWM, add to ~/.fvwm/config:

Key XF86AudioRaiseVolume A A Exec exec mixer vol +10
Key XF86AudioLowerVolume A A Exec exec mixer vol -10

After restarting FVWM, the volume keys can be used to change the soundcard mixer values.

Screen

You can connect an external screen by VGA, Mini DisplayPort, or HDMI (docking station). Use x11/xrandr to enable video output and set display resolutions. Default output is LVDS1. List all outputs with:

$ xrandr

Set the resolution of the VGA output with:

$ xrandr --output VGA1 --mode 1024x768

Set the resolution of the DisplayPort output with:

$ xrandr --output DP1 --mode 1920x1200

Set the resolution of the internal screen with:

$ xrandr --output LVDS1 --mode 1366x768

Screen Brightness

Load the kernel modules acpi_ibm(4) and acpi_video(4). Edit /boot/loader.conf and add:

acpi_ibm_load="YES"
acpi_video_load="YES"

Set the screen brightness with:

# sysctl hw.acpi.video.lcd0.brightness=80

You can use the Fn keys to increase/decrease the screen brightness by loading acpi_ibm(4). Add to /boot/loader.conf:

acpi_ibm_load="YES"

Add to /etc/devd.conf:

notify 10 {
    match "system"      "ACPI";
    match "subsystem"   "IBM";
    action "/usr/local/sbin/acpi_oem_exec.sh $notify ibm";
};

Create the file /usr/local/sbin/acpi_oem_exec.sh:

#!/bin/sh

if [ "$1" = "" -o "$2" = "" ]
then
    echo "usage: $0 notify oem_name"
    exit 1
fi

NOTIFY=`echo $1`
LOGGER="logger"
CALC="bc"
BC_PRECOMMANDS="scale=2"
ECHO="echo"
CUT="cut"
MAX_LCD_BRIGHTNESS=7
MAX_VOLUME=14
OEM=$2
DISPLAY_PIPE=/tmp/acpi_${OEM}_display

case ${NOTIFY} in
    0x05)
        LEVEL=`sysctl -n dev.acpi_${OEM}.0.bluetooth`
        if [ "$LEVEL" = "1" ]
        then
            sysctl dev.acpi_${OEM}.0.bluetooth=0
            MESSAGE="bluetooth disabled"
        else
            sysctl dev.acpi_${OEM}.0.bluetooth=1
            MESSAGE="bluetooth enabled"
        fi
        ;;
    0x10)
        LVL=`sysctl -n hw.acpi.video.lcd0.brightness`
        LVL=$(((LVL / 10 + 1) * 10))
        sysctl hw.acpi.video.lcd0.brightness=${LVL}
        MESSAGE="LEVEL ${LVL}"
        ;;
    0x11)
        LVL=`sysctl -n hw.acpi.video.lcd0.brightness`
        LVL=$((( (LVL + 1) / 10 - 1) * 10))
        [ ${LVL} -lt 10 ] && LVL=5
        sysctl hw.acpi.video.lcd0.brightness=${LVL}
        MESSAGE="LEVEL ${LVL}"
        ;;
    0x12)
        LEVEL=`sysctl -n dev.acpi_${OEM}.0.thinklight`
        if [ "$LEVEL" = "1" ]
        then
            MESSAGE="thinklight enabled"
        else
            MESSAGE="thinklight disabled"
        fi
        ;;
    0x15|0x16)
        LEVEL=`sysctl -n dev.acpi_${OEM}.0.volume`
        PERCENT=`${ECHO} "${BC_PRECOMMANDS} ; ${LEVEL} / ${MAX_VOLUME} * 100" | ${CALC} | ${CUT} -d . -f 1`
        MESSAGE="volume level ${PERCENT}%"
        ;;
    0x17)
        LEVEL=`sysctl -n dev.acpi_${OEM}.0.mute`
        if [ "$LEVEL" = "1" ]
        then
            MESSAGE="volume muted"
        else
            MESSAGE="volume unmuted"
        fi
        ;;
    *)
        ;;
esac
${LOGGER} ${MESSAGE}
if [ -p ${DISPLAY_PIPE} ]
then
    ${ECHO} ${MESSAGE} >> ${DISPLAY_PIPE} &
fi
exit 0

Set sysctl dev.acpi_ibm.0.handlerevents='0x04 0x10 0x11' and add to /etc/sysctl.conf:

dev.acpi_ibm.0.handlerevents=0x04\ 0x10\ 0x11

Wi-Fi

Wi-Fi is supported by the iwn(4) driver. Add the following lines to /boot/loader.conf:

if_iwn_load="YES"
wlan_wep_load="YES"
wlan_ccmp_load="YES"
wlan_tkip_load="YES"

Assumed your WiFi uses the WPA2 protocol, add the network to /etc/wpa_supplicant.conf:

network={
    ssid="Your WiFi"
    psk="correcthorsebatterystaple"
    key_mgmt=WPA-PSK
}

Create a new wireless LAN device with:

# ifconfig wlan0 create wlandev iwn0

You can add the device to /etc/rc.conf:

# sysrc wlans_iwn0="wlan0"

Scan for networks with:

# ifconfig wlan0 up scan

Connect to your Wi-Fi network:

# wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B

Obtain an IP address with:

# dhclient wlan0

You should be connected now. For more information on Wi-Fi networks, see the FreeBSD online handbook.

Card Reader

The card reader of the X230 can be used after loading the appropriate kernel modules. Add the following lines to /boot/loader.conf:

mmc_load="YES"
mmcsd_load="YES"
sdhci_load="YES"

Mount an SD card with:

# mount_msdosfs /dev/mmcsd0 /media

Valid XHTML 1.0 Valid CSS