FreeBSD on X1 Carbon (Gen 6)

Base Installation

 * grab ISO
 * encryption info goes here

/etc/src/conf - source build options
WITHOUT_ASSERT_DEBUG=true # compile without the assert(3) checks. WITHOUT_AUDIT=true # Set to not build audit support into system programs. WITHOUT_BSNMP=true # Set to not build or install bsnmpd(1) WITHOUT_CALENDAR=true # Set to not build calendar(1) WITHOUT_TESTS=true # Set to not build nor install the FreeBSD Test Suite WITHOUT_INET6=true WITHOUT_MAIL=true WITHOUT_QUOTAS=true WITHOUT_DEBUG_FILES=true WITH_SVN=true # Set to install svnlite(1) as svn(1).
 * 1) WITHOUT_LIB32=true
 * 1) WITHOUT_CROSS_COMPILER=true
 * 2) WITHOUT_KERBEROS=true # some pkgs do not like to have it without

/etc/make.conf - system build information
CPUTYPE?=skylake          # no kabylake yet?

FreeBSD source and installation
rm -rf /usr/src/* svnlite checkout https://svn0.eu.FreeBSD.org/base/stable/12 /usr/src

BIOS Updates
sudo portmaster -i sysutils/geteltorito geteltorito -o usb-bios-update.img n23ur13w.is sudo dd if=usb-bios-update.img of=/dev/daX bs=10M
 * Get latest BIOS update from Lenovo as bootable CD ISO file.
 * Convert the ISO to something that you can boot from USB
 * Write the image to your USB device
 * plug USB in X1, (re)boot
 * Press enter, then F12 to choose temporary startup device
 * Choose your USB device (USB HDD)
 * Follow instructions from BIOS update utility

Microcode Updates
sudo portmaster -iB sysutils/x86info sudo kldload cpuctl.ko sudo x86info -a | grep Microcode     # To note current Microcode version sudo portmaster -iB sysutils/devcpu-data cpu_microcode_load="YES" cpu_microcode_name="/boot/firmware/intel-ucode.bin"
 * Information about current microcode version can be accessed this way (needs to install a small tool first)
 * Latest microcode can be fetched by installing the following port:
 * Edit  to add:
 * 1) Microcode update
 * Reboot and check if Microcode version has changed :)

WiFi
wlans_iwm0="wlan0" background_dhclient="YES" ifconfig_wlan0="WPA DHCP country NL"
 * in /etc/rc.conf
 * 1) Wireless (change to relevant country code)

Trackpad/Touchpad
With the update of  to 1.20.7, xorg-server has switched from using the   backend to the   backend for device configuration on FreeBSD 12 and 13. If you do not do anything, the trackpad and touchpad that used to work out of the box, will... not work anymore. If you want then back: [X] EVDEV [X] LIBINPUT [X] MOUSE [X] SYNAPTICS kern.evdev.rcpt_mask=12 hw.psm.trackpoint_support="0" hw.psm.synaptics_support="0"
 * Make sure these options are enabled with :
 * Add to
 * 1) Enable evdev hardware mouse + hardware keyboard
 * Tell the PS/2 driver to not handle the Trackpoint and Trackpad
 * 1) Disable Trackpoint and Trackpad support in psm

DRM Next Kernel Module
portmaster -i graphics/drm-next-kmod kld_list="/boot/modules/i915kms.ko" pw usermod ${USERNAME} -G video shutdown -r now
 * Install the port
 * in /etc/rc.conf
 * 1) drm-next-kmod port
 * add your main user to video group
 * reboot

Xorg
Section "Device" Identifier "Intel Graphics" Driver     "intel" Option     "TearFree" "true" EndSection Note: These days all the useful options are enabled by default so no need to add too many extra parameters.
 * /etc/X11/xorg.conf

Audio over HDMI
Seems to be currently broken with drmnext. Need to be investigated further.

Headphones
To make the headphone plug work, add the following in /boot/device.hints (and reboot): hint.hdaa.0.nid33.config="as=1 seq=15"
 * 1) Enable headphones

Webcam
Note: this does not quite work as expected due to a small conflict between cuse.ko and cuse4bsd.ko, the former need to be unloaded first, need to investigate... portmaster -iB multimedia/cuse4bsd-kmod multimedia/webcamd multimedia/pwcview cuse4bsd_load="YES" webcamd_enable="YES" pwcview -s uxga -f 30
 * Install the  kernel module and
 * Load the  kernel module at boot time, edit  :
 * 1) Character device driver for webcams
 * Start  daemon at boot time, edit  :
 * 1) Webcam daemon
 * Test webcam with:

Thinkpad drivers
Used for LCD control, suspend, etc... acpi_video_load="YES" acpi_ibm_load="YES"
 * in /boot/loader.conf
 * 1) Thinkpad stuff

Sleep
sudo zzz
 * You need at least BIOS 1.30 (see BIOS section to know how to update BIOS)
 * In BIOS change sleep state mode to Linux
 * when you want to suspend to RAM:

Another Note: See optional config bits below for sleeping when closing lid.

Optional
Section "Files" FontPath "/usr/local/share/fonts/Caladea/" FontPath "/usr/local/share/fonts/Carlito/" FontPath "/usr/local/share/fonts/GentiumBasic/" FontPath "/usr/local/share/fonts/Liberation/" FontPath "/usr/local/share/fonts/LinLibertineG/" FontPath "/usr/local/share/fonts/TerminusTTF/" FontPath "/usr/local/share/fonts/TTF/" FontPath "/usr/local/share/fonts/Type1/" FontPath "/usr/local/share/fonts/cyrillic/" FontPath "/usr/local/share/fonts/dejavu/" FontPath "/usr/local/share/fonts/encodings/" FontPath "/usr/local/share/fonts/terminus-font/" FontPath "/usr/local/share/fonts/twemoji-color-font-ttf/" FontPath "/usr/local/share/fonts/util/" EndSection OPTIONS_SET+=SNDIO     # BSD specific sound system OPTIONS_UNSET+=DOCS    # I only install specific ones OPTIONS_UNSET+=EXAMPLES # Same OPTIONS_UNSET+=IPV6    # IPV6 free laptop already saved the day twice xset rate r rate 250 34 kbdcontrol -r fast hw.syscons.bell=0 kern.vt.enable_bell=0
 * xorg.conf
 * 1) All non-default X11 font directories must specified manually because
 * 2) the X server does not search directories recursively...
 * 3) Also, check /var/log/Xorg.0.log for missing fonts.dir files
 * 4) Most likely some directories will miss theirs, in which case you need
 * 5) to cd there and run mkfontdir...
 * Don't want some options, /etc/make.conf
 * Keyboard rate
 * in /etc/sysctl.conf
 * 1) No BEEPS!

hw.acpi.lid_switch_state=S3 me:\ :charset=UTF-8:\ :lang=en_GB.UTF-8:\ :setenv=LC_COLLATE=C: dbus_enable="YES"      # Enable DBUS dumpdev="NO"           # Disable crash dumps
 * 1) Suspend to RAM when closing lid (for laptop with a working S3)
 * If you don't like the touchpad and only use the emblematic Thinkpad pointing stick, you can disable the touchpad entirely in the BIOS (hurray!)
 * in ~/.login.conf
 * in /etc/rc.conf