Skip to content

Instantly share code, notes, and snippets.

@joske
Last active November 30, 2024 19:39
Show Gist options
  • Save joske/52be3f1e5d0239706cd5a4252606644b to your computer and use it in GitHub Desktop.
Save joske/52be3f1e5d0239706cd5a4252606644b to your computer and use it in GitHub Desktop.
Arch Linux Arm on Lenovo Yoga Slim 7x (X elite)

Arch

This is the method I used to install Arch on the yoga slim 7x. This is from memory so I may have forgotten things

prerequisites

  • disable bitlocker in windows
  • resize the windows partition
  • disable secure boot in BIOS

installation

  • Download the Debian 12 image from https://git.codelinaro.org/linaro/qcomlt/demos/debian-12-installer-image
  • write it to USB, use gparted to resize the partition
  • download the latest (ancient) arch linux arm generic image from https://archlinuxarm.org/platforms/armv8/generic
  • unpack the initrd and add this tarball
  • also add some tools like mkfs.ext4 and fdisk (I downloaded debian 12 versions and unpacked the necessary libs and binaries)
  • boot from the USB (use F12)
  • once in installer, press Fn+alt+F2 to get to another TTY
  • create a wpa_supplicant file and start wpa_supplicant
  • back on tty1, continue the installer until it has setup networking
  • return to tty2
  • create /boot and / partitions (and any other you want)
  • mount / on /mnt
  • unpack the tarball into /mnt
  • mount /boot on /mnt/boot
  • bind mount /sys, /dev, /proc and /run in /mnt
  • chroot in /mnt
  • set the date with the date command (otherwise signature verification fails)
  • use
pacman-key --init
pacman-key --populate archlinuxarm
  • update with pacman -Syyu
  • copy kernel, initrd and device tree from the USB
  • do the rest of Arch setup
  • do some of the steps outlined by linaro, in particular the zink environment
  • exit the chroot
  • edit the USB grub to load from the nvme
  • reboot with F12 and boot from the nvme
  • build newer kernel, initrd and dtb
  • get firmware from https://github.com/Seraphin-/linux-firmware-x1e80100-lenovo-yoga-slim7x

post installation

  • I replaced the windows nvme with a bigger one that has only linux, that way I was able to update the UEFI boot manager to load Arch without the USB stick
    • Download shellaa64.efi and place it on USB stick
    • use the following grub entry:
    menuentry "UEFI Shell" {
      insmod fat
      insmod chain
      search --no-floppy --set=root --file /shellaa64.efi
      chainloader /shellaa64.efi
    }
    
    • boot to UEFI shell
    • use the commands in the debian 12 image explanation to set Arch as first boot entry
  • install mesa from this PKGBUILD https://github.com/joske/PKGBUILDs-x1e/tree/master/mesa
@smedir
Copy link

smedir commented Aug 8, 2024

Please, could you elaborate on-
-unpack the initrd and add this tarball

and

-build newer kernel, initrd and dtb

Does the debian installer have the dtb? and how do you build the newer dtb?

@kuruczgy
Copy link

@smedir to answer your questions:

  • The steps for unpacking and repacking the initrd are described in the linked debian-12-installer-image repo, look for the steps involving gzip and cpio.
  • The kernel and the dtb come from the linux repo, this is not X1E specific, you should look for generic instructions for your distribution for how to compile custom kernels.

I did attempt following this guide, but decided to choose a different approach halfway through. Nonetheless here are some notes I took that expand on some of the steps above, in case they are useful to someone:

  • GRUB for some reason did not work for me initially using the built-in keyboard, but then started working after a while. You might need to plug in an external keyboard to press "Enter" in grub. (You could also try doing a firmware update (comes through Windows update AFAICT), it might have been what fixed it for me.)
  • In linux the external keyboard didn't seem to work, but now the internal one did.
  • Fair warning, the terminal font size is tiny, it will not be a very comfortable experience.
  • To connect to Wi-Fi
    • First create a wpa_supplicant.conf file using nano, with the following contents:
      network={
        ssid="your-ssid"
        psk="your-password"
      }
      
    • Run wpa_supplicant -i wlP5p1s0 -c wpa_supplicant.conf. (Your interface name could be different, check with ip link.)
  • The debian install iso has an old version of glibc, you have to somehow manually update it, this reddit post also points this out: https://www.reddit.com/r/SurfaceLinux/comments/1efmyb3/managed_to_install_baremetal_linux_on_snapdragon/

Unfortunately I don't have any more tips for installing Arch as I decided to use NixOS instead, if someone is perhaps interested in that here is my repo with some instructions: https://github.com/kuruczgy/x1e-nixos-config/

@smedir
Copy link

smedir commented Aug 21, 2024

Thank you very much for your reply @kuruczgy. I was able to install debian with the method described here, was able to go on wi fiI. I was able to boot into the system natively, Gnome came up, however the track pad was not working, only the keyboard would work.

I updated to the latest firmware in lib firmware from the link on this site. Unfortunately I lost wi fi I after that, and was unable to download and compile a kernel natively in debian. Or maybe it was a windows update that caused it.

Even after going back to the installer I am still unable to get a wi fi device since. It does show up and work in Windows!

I have compiled a new dtb from the 6.11. rc-3, and tried that with the latest firmware in the initrd, and a arm kernel crosscompiled on Arch. That just boots to a black screen even though it is the dtb is the correct one for the Yoga device.

The new/latest dtb will boot with the 6.5 kernel on the debian installer, but no keyboard! Also on trying to boot with that kernel and dtb to the debian system already installed on disk passing root=/dev/nvme...., no root device error, no /dev/nvme!. Booting with the old dtb and 6.5 kernel, still finds the root device at dev/nvme and boots into debian, however on wi fi again.

Kind of stuck right now. Maybe will try Nix Os, always wanted to try it.

@weoses
Copy link

weoses commented Sep 10, 2024

I followed this method and stuck on kernel building

Looks like current 6.11-rc kernels already contains snapdragon device tree and drivers, but

  • Codelinaro image might be a bit outdated, i cant proceed debian installation further than "downloading additional components", cause of glibc version mismatch in anna binary

  • I created partitions on nvme,
    Copied arch tarball files into it;
    Chrooted in this unpacked arch-env;
    Built 6.11-rc7 kernel from kernel.org in this chroot;
    Installed it into chroot, generated a new initramfs;

    Now i can 'boot' kernel, using grub on usb stick (specify new initramfs, kernel and devicetree in grub console), but kernel boot logs just stops and switches to black screen. Looks like graphics fault, cause i can enter login creds and 'reboot' command, and laptop really trying to poweroff

So, what can i do wrong? Did anyone tried to build latest kernel from kernel.org for this laptop? How to build newer kernel for it, or just debug kernel loading at least?

@joske
Copy link
Author

joske commented Sep 10, 2024

It's probably due to the initrd. I have a 'working' base initrd (I think based on the debian one) and another based on the arch one that does not work for some reason. I was not yet able to figure out why

@smedir
Copy link

smedir commented Sep 10, 2024

@weoses

Do you have the graphic firmware files in the initrd?

@joske
Copy link
Author

joske commented Sep 11, 2024

yes

@joske
Copy link
Author

joske commented Sep 11, 2024

try with this initrd (replace the kernel modules and repack)

https://drive.google.com/file/d/1TzLcW2DT19YDOfXs4VHpCHk1CIuBpjPu/view?usp=sharing

@joske
Copy link
Author

joske commented Sep 11, 2024

@weoses you probably want to use this branch: https://github.com/jhovold/linux/tree/wip/x1e80100-6.11-rc7

Linus' tree still misses bits

@weoses
Copy link

weoses commented Sep 12, 2024

Do you have the graphic firmware files in the initrd?

I have a lot of firmware in initrd (i even disabled autodetect in mkinitcpio), and i really not sure which of it is for gpu part for this soc....

try with this initrd (replace the kernel modules and repack)

I tried boot from it as is (i thought we build kernels from same sources, but got strange error, and stuck in initramfs without keyboard)
And I merged firmware from it to my laptop, not helps

@weoses you probably want to use this branch: https://github.com/jhovold/linux/tree/wip/x1e80100-6.11-rc7

After building jhovold`s kernel and disabling kms i got boot with systemd logs few seconds after initramfs and with working keyboard (i am not sure that exactly this helps), looks like it is really graphics driver fault
Likely i really missed firmware somewhere

So i rebuilt kernel from https://github.com/jhovold/linux/tree/wip/x1e80100-6.11-rc7 using defconfig from author ( commit jhovold/linux@b9c3748),
added some kernel cmdline parameters as described in https://github.com/jhovold/linux/wiki/X13s
added firmwares from @joske initrd image
and gpu still fails

I will try to setup ssh server on laptop and at least check logs

@smedir
Copy link

smedir commented Sep 12, 2024

The latest kernel gives working keyboard, touchscreen and trackpad.

Now working- bluetooth, sound, microphone, camera and battery monitoring. Also now real suspend and hiberante.

@joske
Copy link
Author

joske commented Sep 12, 2024

@smedir how did you get sound working? Do you mean using USB headphones or bluetooth?

For battery monitoring you need a pd-mapper, either in userspace or in kernel. For the userspace one, you need to find the jsn files from windows in firmware folder. The in-kernel one has issues.

@smedir
Copy link

smedir commented Sep 12, 2024

Whoops!, that was a typo- It is Not working, sound, microphone and bluetooth. I wanted to see if anybody else got it working and how 😄 suspend and hibernate also not working.

Thanks for the tip into pd_mapper. I will look into it. I am using gnome, which gives a red battery with no levels, uses upowerd. I see messages in the log from upower - it is getting NaN readings.

@anonymix007
Copy link

anonymix007 commented Sep 12, 2024

Here's the image I used for installation: x1e-endeavouros.img.7z
I've built Calamares while booted from USB from this PKGBUILD with only slight modifications and a dirty hack described here. After pacman -U I overwrote the configs in /etc/calamares/ with configs from calamares_config.tar.gz (same GDrive folder as the image) and installed with systemd-boot.
The partitioning is the following:

  1. ESP (stock from Windows) -> /efi
  2. Other Windows partitions
  3. Separate /boot (XBOOTLDR)
  4. Separate /root (needs to have endeavouros label and be f2fs)
  5. Separate /home

AFAIR it was necessary to create /home/liveuser for Calamares to work,
These configs still need some work (probably eos_bootloader module needs to be dropped), so after installation succeeds, it won't boot.
So one would need to chroot into the installed system, manually install linux-x1e and x1e-uki packages (second is optional; both packages are available in my repo) and create a simple systemd-boot config in /boot/loader/entries/ and then it should boot.
If installing x1e-uki, make sure to first create /etc/kernel/cmdline file:

efi=novamap pd_ignore_unused clk_ignore_unused fw_devlink=off cma=128M root=PARTLABEL=endeavouros rootfstype=f2fs rootwait rw loglevel=7

@kmeaw
Copy link

kmeaw commented Nov 25, 2024

Does KVM virtualization work on those machines?

@kuruczgy
Copy link

@kmeaw: It's... not impossible, but I don't know if anyone has tried it on the slim7x yet. The main difficulty is that by default these machines boot into EL1, and you have to jump through some hoops to boot them in EL2. See here: https://github.com/TravMurav/slbounce

Hardware support in EL2 is currently worse, because the default hypervisor provides some services that are missing when booting into EL2 using slbounce.

Also I don't know how much of KVM support is upstream yet, but I have heard that (with some unmerged patches) both normal and nested virt are working. (The person developing this is doing so on the DevKit AFAIK.)

@kuruczgy
Copy link

@kmeaw just to give an update, in the last 5 days I made a lot of progress. I can now boot my machine in EL2, and run QEMU VMs without issues. Steps that are needed (also see this draft PR for my NixOS repo):

The things that don't work compared to EL1 are the battery indicator and DP altmode.

(There is also a patch that makes slbounce detect whether you are loading an overlayed device tree (see my PR for that), and only do SL if that's the case. This way you can select between EL1 and EL2 mode from the boot menu without having to go through an EFI shell.)

@kmeaw
Copy link

kmeaw commented Nov 30, 2024

@kuruczgy Thank you for the update! I think this information would be really useful for someone considering buying a Snapdragon laptop and running Linux on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment