ThinkPad X13s

From Gentoo Wiki
Jump to:navigation Jump to:search
This article is a stub. Please help out by expanding it - how to get started.
Resources

ThinkPad X13s is an ARM64 powered 13in laptop.

Hardware

ThinkPad X13s Specifications

CPU: Qualcomm Snapdragon 8cx Gen 3

Graphics: Qualcomm Adreno 690 (integrated)

Memory: 16GB LPDDR4X-4266

Storage: 512GB PCIe Gen 4 SSD

Display: 13.3-inch, 1920 x 1200, 16:10

Networking: Qualcomm WCN685x Wi-Fi 6E, Qualcomm Snapdragon X55 5G, Bluetooth 5.1

Ports: 2x USB Type-C 3.2 Gen 2, 3.5 mm headphone jack, SIM card slot, Kensington lock slot

Camera: 5 megapixel camera, infrared

Battery: 49.5 WHr

Power Adapter: 65 W

Dimensions (WxDxH): 11.76 x 8.13 x 0.53 inches / 298.7 x 206.4 x 13.4 mm

Weight: 2.35 pounds / 1.06 kg

Review and Benchmarks

X13s review with benchmarks (mainly similar size x86 laptops): https://www.notebookcheck.net/Lenovo-ThinkPad-X13s-G1-Laptop-review-Introducing-the-Qualcomm-Snapdragon-8cx-Gen-3.665008.0.html

Installation

Installing Gentoo on the ThinkPad X13s is very similar to how one installs Gentoo on just about any EFI-based laptop. The main parts that need special attention are the GPU and the kernel/dtb (plus firmware blobs).

Requirements and constraints

Due to the "freshness" of all the x13s kernel and devicetree bits, the install path starts with building a kernel and creating a bootable USB stick for this device. This can either be done natively (on another arm64 device) or using a cross-compiler and qemu. Either of these methods will also require some additional hardware, either a USB-C flash drive or a small USB-C dock/hub with type-A USB ports (a USB-C ethernet adapter can also be very helpful).

Although the walk-through document uses windows boot manager, the preferred tool is efibootmgr.

The Gentoo arm64 USB image does not seem to successfully boot, but there is custom Arch boot image that does and it has all the tools necessary to install Gentoo on it.

References

The install walk-through for the hacked debian installer .iso can be a helpful resource. Other related repositories and readmes may also be of interest:

Bootloader

No u-boot here, just EFI BIOS firmware and any of the usual EFI bootloaders, ie, Grub works with both install modes, as well as an EFI stub kernel. Either of these methods requires both an initramfs and the devicetree blob passed to the kernel (note: grub will not add devicetree to the config so it must be added manually for now).

You'll need to pass some parameters to the kernel to get your system to boot and run optimally. These can be added to your grub config.

FILE /etc/default/grub
GRUB_CMDLINE_LINUX="efi=noruntime pd_ignore_unused clk_ignore_unused iommu.passthrough=0 iommu.strict=0"
  • pd_ignore_usused - keeps some power domains from being erroneously turned off
  • clk_ignore_unused - keeps some clocks from being erroneouly turned off, this keeps the display from turning off immediately after boot
  • iommu - improves performance of usb devices

After adding these make sure to run run the following command in order have them added to the grub config on your boot partition

root #grub-mkconfig -o /boot/grub/grub.cfg

After installing a new kernel and running grub-mkconfig, remember to add the following line to each boot stanza in grub.cfg, where version, path, etc, matches your local install:

FILE /boot/grub/grub.cfg
devicetree	/boot/dtbs/6.3.0-rc2-x13s-r0/qcom/sc8280xp-lenovo-thinkpad-x13s.dtb

initrd

When generating an initrd make sure the following kernel modules are included and loaded early, to ensure the display output is working.

The list below was scraped from one of the install docs. Depending on which tool you use to generate the initrd, all or some of those might be included automatically.

When using dracut to build the initrd, add a configuration file that looks like this:

FILE /etc/dracut.conf.d/20_thinkpad-x13s.conf
force_drivers+=" nvme phy_qcom_qmp_pcie pcie_qcom i2c_hid_of i2c_qcom_geni leds_qcom_lpg pwm_bl qrtr pmic_glink_altmode gpio_sbu_mux phy_qcom_qmp_combo panel-edp msm phy_qcom_edp "

With nothing else in the above config, a minimal but working initramfs of approx. 12 MBs can be generated via the following:

root #dracut --kver 6.3.0-rc2 -m "kernel-modules rootfs-block base"

Kernel

Since kernel patches are still in the patch queue/review process, the working patch set is in this repos but be sure and check for the latest branch version. Use one of the configs in the kernel source to start; a good choice is laptop_defconfig.

For now, check for the latest 6.3_rc branch, currently lenovo-x13s-v6.3-rc7.

It is recommended to clone with a depth of 1 initially; the default (manual) kernel install paths work fine (see example in grub.cfg snippet).

User-space

The user-space configuration consists mainly of firmware blobs (not yet in linux-firmware) and some Qualcomm-specific user-space daemons borrowed from Android. The a690 GPU patches have recently been mainlined in mesa HEAD so the live ebuild is currently required.

  • Alarm x13s repo - WLAN/BT, GPU, Audio firmware (sys-firmware/x13s-firmware)
    • install linux-firmware and edit the savedconfig file to remove the wifi board file
      • under the path ath11k/WCN6855/hw2.x remove both occurrences of board-2.bin and save the config
    • reinstall linux-firmware with USE=savedconfig then continue with the overlay packages
  • qrtr - namespace daemon for net/qrtr in the Linux kernel (sys-power/qrtr)
  • pd-mapper - Qualcomm Protection Domain mapper daemon (sys-power/pd-mapper)
    • install sys-power/pd-mapper and add it to the boot runlevel
  • audio config - ALSA UCM configuration files (media-libs/alsa-ucm-conf)


Preliminary ebuilds for the above can be found in the embedded overlay. Be sure to install and activate the overlay before installing an actual desktop, eg, Gnome or XFCE. Manually installing sys-firmware/x13s-firmware and sys-power/pd-mapper along with one of the big desktops should pull in all the required bits.

Post-install

These devices are generally "new" enough to need BIOS firmware updates, which can be obtained from the Lenovo support page. If the device no longer has the vendor-installed OS, follow the steps here to create a bootable USB stick for updating the BIOS firmware. Selecting the USB disk from the (BIOS) Boot Menu will automatically launch the EFI firmware installer.

Possibly some configuration nits may also need to be addressed; feel free to add your own here.

f0 respawning

With a default arm64 system, error messages like this may appear both on the default TTY and in the system log:

Id "f0" respawning too fast: disabled for 5 minutes

To get rid of those, edit the inittab at /etc/inittab and remove or comment out the last line, that looks something like this:

FILE /etc/inittab
# Architecture specific features
f0:12345:respawn:/sbin/agetty 9600 ttyAMA0 vt100

Then, restart the system.

Clock loses time on reboot

The default configuration may not assume a builtin RTC with a battery, so check the following config and go ahead and treat this device like a real laptop (NTP use is completely optional).

FILE /etc/conf.d/hwclock
clock_hctosys="YES"
clock_systohc="YES"