ThinkPad X13s

ThinkPad X13s is Article description::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.

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).

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:

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:

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

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.

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  and edit the   file to remove the wifi board file
 * under the path remove both occurrences of   and save the config
 * reinstall  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  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  and   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  and in the system log: Id "f0" respawning too fast: disabled for 5 minutes

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

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).