David Schlachter

FreeBSD 12.0-RELEASE on the Lenovo Thinkpad T480

August 21, 2019

Recently I replaced my 2014 MacBook Air with a Lenovo Thinkpad T480, on which I've installed FreeBSD, currently 12.0-RELEASE. This page documents my set-up along with various configuration tweaks and fixes.

So far working:

Not working: Bluetooth (causes hang on reboot), 802.11ac (no support in FreeBSD). I don't have any Thunderbolt devices to test and don't have a fingerprint sensor installed.

X11 and HiDPI

X11 requires that the latest Intel video drivers be installed from the package drm-kmod. Load them at boot by adding
kld_list="/boot/modules/i915kms.ko"
to /etc/rc.conf.

For HiDPI support, the scaling factor must be set using xrandr. I do this in my .xinitrc:

xrandr --dpi 140 && xrdb -merge $HOME/.Xresources
exec i3 # start the window manager

Fonts in Firefox are jagged unless bitmap fonts are disabled system-wide:
sudo "cd /usr/local/etc/fonts/conf.d && ln -s ../conf.avail/70-no-bitmaps.conf"

By default the cursor will be tiny. To increase the size of the cursor, select a cursor theme that has multiple cursor sizes and set the cursor size in .Xresources:

Xcursor.size: 48
Xcursor.theme: whiteglass

However, this will only work if you create the following symlink:
ln -s /usr/local/share/icons ~/.icons

The cursor will still be very small in GTK apps (Firefox, xfce4-terminal); to fix, set the same cursor theme as in .Xresources in ~/.config/gtk-3.0/settings.ini and ~/.gtkrc-2.0.

To enable the synaptics driver (two-finger scrolling, two-finger tap for right click, etc), add hw.psm.synaptics_support="1" to /boot/loader.conf, as well as moused_enable="YES" and moused_flags="-V" to /etc/rc.conf.

i3 window manager

For i3wm, the generated configuration is more limited than the default loaded configuration (e.g. the generated config does not have a hotkey to exit i3). Copy the example configuration as a starting point:
mkdir -p ~/.i3 && cp /usr/local/etc/i3/config ~/.i3/config

5GHz WiFi networks

5 GHz networks won't be visible unless the country code is properly set for the WiFi interface (otherwise connectivity will be limited to the 2.4GHz band). I set the country code (for me, Canada, "CA") on this line in /etc/rc.conf:
ifconfig_wlan0="WPA country CA powersave"

Suspend / resume

To enable suspend / resume on lid close when running X11, add hw.acpi.lid_switch_state=S3 to /etc/sysctl.conf.

The ethernet interface drops and won't connect again on resume. To fix, install the latest drivers from the intel-em-kmod package.

Also note that the TPM must be disabled in the BIOS for suspend/resume to work.

Camera

The IR camera is the only camera option included with the WQHD screen. Setting up webcamd with default settings has the infrared camera working fine but only as creepy night vision!

usbconfig shows two camera devices:

ugen0.2: <Bison Integrated IR Camera> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (500mA)
ugen0.3: <SunplusIT Inc Integrated Camera> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (500mA)

To use the visible light camera instead of the IR camera, set webcamd_0_flags in /etc/rc.conf to indicate the right device to use, e.g.
webcamd_enable="YES"
webcamd_0_flags="-d ugen0.3 -B"

Alternatively, set up both cameras (as shown below in /etc/rc.conf) so that apps will ask which one you want to use.

Configuration files

For anything not described above:

/etc/rc.conf

#
# Added by installer
#
clear_tmp_enable="YES"
syslogd_flags="-ss"
sendmail_enable="NONE"
hostname="t480"
ntpdate_enable="YES"
ntpd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"

# Power saving, see https://www.c0ffee.net/blog/freebsd-on-a-laptop/
powerdxx_enable="YES"
performance_cx_lowest="Cmax"
economy_cx_lowest="Cmax"

# Intel Graphics driver
kld_list="/boot/modules/i915kms.ko"

# Readable font size at console
allscreens_flags="-f terminus-b32"

# For XOrg
dbus_enable="YES"

# Don't pause during boot for DHCP
background_dhclient="YES"

# Networking; use ethernet if available, otherwise use WiFi
# https://www.freebsd.org/doc/handbook/network-aggregation.html
ifconfig_em0="up"
wlans_iwm0="wlan0"
ifconfig_wlan0="WPA country CA powersave"
create_args_wlan0="wlanaddr 98:fa:9b:6c:e4:4f"
cloned_interfaces="lagg0"
ifconfig_lagg0="up laggproto failover laggport em0 laggport wlan0 DHCP"

# Webcam
webcamd_enable="YES"
webcamd_0_flags="-d ugen0.3" # visible light camera
webcamd_1_flags="-d ugen0.2" # IR camera

# Touchpad
moused_enable="YES"
moused_flags="-V -A 1.8 -a 1.2 -U 4 -L 1.5"

# CUPS (allow printing)
cupsd_enable="YES"

# Virtualbox bridged networking
vboxnet_enable="YES"

# Access to USB devices for operator group
# (references ruleset name in /etc/devfs.rules)
devfs_system_ruleset="system"

# Powersave mode for built-in USB devices
usbconfig -u 0 -a 2 power_save
usbconfig -u 0 -a 3 power_save
usbconfig -u 0 -a 4 power_save

/etc/sysctl.conf

# Added by the installer
security.bsd.unprivileged_read_msgbuf=0
security.bsd.unprivileged_proc_debug=0
kern.randompid=1
vfs.zfs.min_auto_ashift=12

# Allow sleep on lid close
hw.acpi.lid_switch_state=S3

# Disable system bell / bell everywhere
kern.vt.enable_bell=0

# Allow mounting FUSE filesystems
vfs.usermount=1

/boot/loader.conf

# Added by installer
aesni_load="YES"
geom_eli_load="YES"
security.bsd.allow_destructive_dtrace=0
kern.geom.label.disk_ident.enable="0"
kern.geom.label.gptid.enable="0"
zfs_load="YES"

# Ethernet goes out on suspend/resume, fix by using newest Intel drivers
if_em_updated_load="YES"

# Improved power and video support
acpi_video_load="YES"
acpi_ibm_load="YES" # Not actually available for T480 atm, maybe in November?

# For webcam
cuse_load="YES"

# WiFi
if_iwm_load="YES"
iwm8265fw_load="YES"

# Virtualbox
vboxdrv_load="YES"

# Touchpad driver
hw.psm.synaptics_support="1"

# FUSE
fuse_load="YES"

# Place devices in low power state when suitable driver not found
# (man 4 pci)
hw.pci.do_power_nodriver=3