FreeBSD on the X1 Carbon Gen 7

Author: Jonathan Vasquez <jon@xyinn.org>
Last Updated: 2022-07-29-1245
Currently On: FreeBSD 13.1-STABLE #0 stable/13-n251972-fb8e858c69f: Thu Jul 28 12:05:36 EDT 2022     root@leslie:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
Machine: Thinkpad X1 Carbon Gen 7

2022-07-27-1200

I've completely switched from using the native iwlwifi driver to using wifibox in the meantime. Once the FreeBSD driver is complete and stable, I'll switch back to it.

Thoughts

After getting FreeBSD set up on the Thinkpad X260 and starting to live with it, I decided that there were some things and workflows I still wanted to have. Primarily, I wanted to still retain a USB-C port since all my connectors (Charging, Ethernet, Wireless Keyboard/Mouse Adapters, and HDMI) are all connected to my Anker Dongle. I use this dongle to quickly provide all those functionalities and quickly be able to switch between my personal computer and my work laptop, over the same Type C connection. Besides that, I also wanted to have a slightly lighter and thinner machine, have a bigger screen (14") and also upgrade to a machine with more processors. The machine also needed to still be FreeBSD compatible, and thus I decided to pick up this X1 Carbon Gen 7. I actually had a Gen 8 a few years ago but it wasn't compatible, and to make things "interesting", I noticed that the FreeBSD foundation had funded some development on the X1 Carbon Gen 7 -.-, haha. Now things have come back full circle, but now I've picked up a Gen 7 instead on eBay. I was able to relatively easily install FreeBSD on it, and then I rsynced all my stuff from the Thinkpad X260 over SSH to the X1C7. Then do a few minor tweaks / quirk fixing for this machine specifically, and it's been relatively good. You'll need to be careful with the iwlwifi driver since it's still buggy and will crash your machine. This is the same driver that the Framework Laptop is using so we will have similar issues. I'm usually on Ethernet but sometimes I'll switch over only to WiFi via DHCP. If you try to assign it an IP, it will sometimes (mostly) crash. If it doesn't crash immediately, it will probably crash your system when you try to do a service netif restart.

Overall everything works fairly well. You can take a look at the information below for further details and tweaks needed. Specifically you'll want to apply the quirk to disable intel pstates. Currently this driver will crash this system as soon as the system gets any load. I experienced crashes even at the start of the FreeBSD installer! Applying the quirk (workaround) allowed the system to no longer crash.

The X1C7 I got came with the following:

After setting everything all up on FreeBSD 13.1-RELEASE and starting to daily drive this machine, I changed the resolution immediately to 1600x900 resolution. Since Xorg doesn't support per display scaling (Wayland does), A combination of 1920x1080 @ 100% for my External HDMI monitor and 1600x900 @ 100% for the internal display, is the sweet spot.

System Status Overview

Definitions

Status Overview

Functionality Status Remarks
Graphics Works Works perfectly fine with drm-kmod.
Ethernet Untested This is untested since it requires a proprietary connector. I'm using my Anker Dongle's Ethernet connector instead. However, the Thinkpad X260 also had a I219-V Ethernet jack as well (with a regular RJ-45 jack), so it probably does work.
WiFi Unstable 802.11a only on iwlwifi module. It seems that for my regular use (when on wireless) 802.11a/g surprisingly is fast enough lol. I'm usually on Ethernet though so the speed can go through there if needed. On another note, when resuming from sleep, the card associates back with the AP quickly, but getting an IP from DHCP sometimes takes a while. Since we are using the iwlwifi module which has issues with state, attempting to assign a static IP will hard crash your system pretty quickly.). Use wifibox in the meantime. You can switch back to the FreeBSD driver once it's complete and stable.
HDMI Fails My monitor signal light turns on for a bit but I don't get any status changes within xrandr for any of the HDMI devices shown. Using my Anker Dongle HDMI instead.
Sound (Speakers) Works
Sound (3.5 mm) Works Works perfectly fine and will automatically switch to the headphones when they are plugged in.
Sleep/Resume Works Don't use if_iwlwifi since that will make it crash on resume. Use wifibox as suggested above for now.
USB Ports Works
Trackpoint Works
Trackpad Works See below for adding more gestures.
Camera Untested
Microphone Untested Most likely doesn't work from reports since this microphone apparently uses some fancy 4 way spacial audio - or something like that.
Hibernate Untested I haven't tested this but it most likely doesn't work. From what I've "heard", FreeBSD doesn't have the hibernation code implemented.
Fingerprint Reader Untested I don't use this.
Bluetooth Untested I don't use this on laptops, just on my phone.

Issues / Workarounds / Misc

Crashes in a few seconds to minutes.

The machine was crashing for me in a matter of seconds (to minutes) immediately after I booted the installer. The only thing that stopped it from crashing was using the same fix that I used on my Thinkpad X260, which is to disable intel pstates. You can still use powerd if you need some type of basic power management. Add the following to /boot/loader.conf:

# Stops the system from crashing every few minutes (workaround).
hint.hwpstate_intel.0.disabled=1

I've left comments in the following posts: 253288 and 248659.

Touchpad (Tapping / Scrolling / Right Click)

The second issue is that you still need to get the gestures (two finger tap (right click), tap to click, etc).

In order to get gestures (scrolling, right click, tap to click, etc) you'll want to add the following into /usr/local/etc/X11/xorg.conf.d/40-libinput.conf:

Section "InputClass"
        Identifier "libinput touchpad catchall"
        MatchDriver "libinput"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Option "Tapping" "on"
EndSection

Speakers sound low

I noticed that my X1C7 speakers sounded pretty low (even at 100%). It turns out that the X1C7 actually has 4 speakers: two on the top (these sound low) and two on the bottom (which are much louder and have the bass). There is already an older bug report about this from 2021 but it doesn't have much progress.

This is the original pin and original patch configuration detected on 13.1-STABLE:

hdaa0: Original pins configuration:
hdaa0: nid   0x    as seq device       conn  jack    loc        color   misc
hdaa0: 18 411111f0 15 0  Speaker       None  1/8     Rear       Black   1
hdaa0: 19 40000000 0  0  Line-out      None  Unknown 0x00       Unknown 0
hdaa0: 20 90170110 1  0  Speaker       Fixed Analog  Internal   Unknown 1
hdaa0: 22 411111f0 15 0  Speaker       None  1/8     Rear       Black   1
hdaa0: 23 90170111 1  1  Speaker       Fixed Analog  Internal   Unknown 1
hdaa0: 24 411111f0 15 0  Speaker       None  1/8     Rear       Black   1
hdaa0: 25 04a11040 4  0  Mic           Jack  1/8     Right      Black   0
hdaa0: 26 411111f0 15 0  Speaker       None  1/8     Rear       Black   1
hdaa0: 27 411111f0 15 0  Speaker       None  1/8     Rear       Black   1
hdaa0: 29 40600001 0  1  Modem-line    None  Unknown 0x00       Unknown 0
hdaa0: 30 411111f0 15 0  Speaker       None  1/8     Rear       Black   1
hdaa0: 33 04211020 2  0  Headphones    Jack  1/8     Right      Black   0

hdaa0: Patching widget caps nid=29 0x00400400 -> 0x00700400
hdaa0: Patching pin config nid=33 0x04211020 -> 0x0321101f

hdaa0: Patched pins configuration:
hdaa0: nid   0x    as seq device       conn  jack    loc        color   misc
hdaa0: 18 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
hdaa0: 19 40000000 0  0  Line-out      None  Unknown 0x00       Unknown 0 DISA
hdaa0: 20 90170110 1  0  Speaker       Fixed Analog  Internal   Unknown 1
hdaa0: 22 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
hdaa0: 23 90170111 1  1  Speaker       Fixed Analog  Internal   Unknown 1
hdaa0: 24 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
hdaa0: 25 04a11040 4  0  Mic           Jack  1/8     Right      Black   0
hdaa0: 26 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
hdaa0: 27 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
hdaa0: 30 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
hdaa0: 33 0321101f 1  15 Headphones    Jack  1/8     Left       Black   0

Both the top and bottom speakers are properly in the same association and have independent unique seq numbers. However, since the devices actually are on separate DACs, we aren't getting any output with the latter sequenced audio device.

dev.hdaa.0.nid20_original: 0x90170110 as=1 seq=0 device=Speaker conn=Fixed ctype=Analog loc=Internal color=Unknown misc=1
dev.hdaa.0.nid20_config: 0x90170110 as=1 seq=0 device=Speaker conn=Fixed ctype=Analog loc=Internal color=Unknown misc=1
dev.hdaa.0.nid20: pin: Speaker (Fixed)
     Widget cap: 0x0040058d PWR UNSOL STEREO
    Association: 0 (0x0001)
        Pin cap: 0x00010014 PDC OUT EAPD
     Pin config: 0x90170110 as=1 seq=0 device=Speaker conn=Fixed ctype=Analog loc=Internal color=Unknown misc=1
    Pin control: 0x00000040 OUT
           EAPD: 0x00000002 EAPD
     Output amp: 0x80000000 mute=1 step=0 size=0 offset=0 (0/0dB)
    Connections: 1
          + <- nid=2 [audio output]

dev.hdaa.0.nid23_original: 0x90170111 as=1 seq=1 device=Speaker conn=Fixed ctype=Analog loc=Internal color=Unknown misc=1
dev.hdaa.0.nid23_config: 0x90170111 as=1 seq=1 device=Speaker conn=Fixed ctype=Analog loc=Internal color=Unknown misc=1
dev.hdaa.0.nid23: pin: Speaker (Fixed)
     Widget cap: 0x0040058d PWR UNSOL STEREO
    Association: 0 (0x0002)
        Pin cap: 0x0000001c PDC HP OUT
     Pin config: 0x90170111 as=1 seq=1 device=Speaker conn=Fixed ctype=Analog loc=Internal color=Unknown misc=1
    Pin control: 0x00000040 OUT
     Output amp: 0x80000000 mute=1 step=0 size=0 offset=0 (0/0dB)
    Connections: 3
          + [DISABLED] <- nid=2 [audio output]
          + <- nid=3 [audio output] (selected)
          + [DISABLED] <- nid=6 [audio output] [DISABLED]

I've added the following quirk to my /boot/loader.conf in order to reverse the bottom speakers sequence number with the top, allowing the louder speakers to be used. The top speakers won't output anything with this configuration, but at least I won't have multiple independent pcm devices showing up. Plugging in the headphones will still properly automatically mute the bottom speakers and output through the headphones as well.

# Prefer bottom louder speakers over top speakers (for now).
# NOTE: The nid20 speakers won't work with this configuration but
# it will at least hide them from audio selection.
hint.hdaa.0.nid23.config="as=1 seq=0"
hint.hdaa.0.nid20.config="as=1 seq=1"
hint.hdaa.0.nid33.config="as=1 seq=15"