Can someone with serial console access try NixOS kernel on Librem 5?

I do, and I recoil :stuck_out_tongue:

1 Like

I was trying to picture an L5 with the old 25 pins parallel printer connector. :laughing:

To be serious: there are USB to serial adapters, I used to use them when configuring switches at the console port. They where a pain in the a## . When they worked all was fine, but to get them going was always a nightmare.

You not say :slightly_smiling_face:

On the subject of connecting All The Things™ to a phone:

On this picture, it’s the phone that’s attached to the thing…

So downloaded kernel source linux-6.2-rc2, copied contents of Librem 5 /proc/config.gz to .config, edited to enable KEXEC and compiled the kernel on an rpi4 just to be sure arch-wise.

Much to my surprise the resulting kernel does not boot. The led even switches off.

Do the kernels need to be signed for some kind of secure boot or something?

I would say “no”, both because that totally gets away from Purism’s approach and because I was able to build Jumpdrive from sources and boot it on my Librem 5 (which wouldn’t work if anyone other than I was needed to sign the resulting kernel).

2 Likes

To test the kernel, I recommend to start with uuu.

This script will boot a given kernel: https://source.puri.sm/Librem5/librem5-devkit-tools/-/blob/pureos/byzantium/uuu_scripts/boot_librem5.lst

I appreciate you take the time to reply, but from my original message it should be quite obvious that I am using uuu.

In the mean time I’ve discovered that the Linux kernel source from https://source.puri.sm/Librem5/linux does produce a booting kernel so some essential code seems not available in upstream.

I’m trying to build a module-less variant to boot NixOS with.

With “build Jumpdrive”, you also mean the kernel? If yes, I assume you we not using upstream kernel as your source?

Oh, sorry. I only looked at the most recent message. Anyway, I think you know as much as I do now.

1 Like

Yes

Correct. git cloned from something on source.puri.sm

1 Like

I’ve managed to get NixOS running on the Librem 5 with a kernel build from https://source.puri.sm/Librem5/linux.git

Biggest issue atm is that I do not have sound in calls due to callaudiod segfaulting.

One of the minor issues that I have to run mkimage by hand to update /boot/boot.scr on configuration changes, to to boot into a new NixOS environment. It seems Purism u-boot does not support u-boot’s Generic Distro Configuration Concept which supports /boot/extlinux/ extlinux.conf: https://u-boot.readthedocs.io/en/latest/develop/distro.html

The part in /etc/nixos/configuration.nix that builds the Purism kernel is:

boot = {
    initrd = {
        kernelModules                       = [ "bq25891_charger" "dwc3" "imx_dcss" "imx_sdma" "mtdblock" "ofpart" "phy_fsl_imx8mq_usb" "snvs_pwrkey" "spi_nor" "tps6598x" "xhci_hcd" "usbcore" "usb_storage" "uas" "xhci_plat_hcd" ];
    };
    kernelParams                            = [ "console=tty0" "earlyprintk=vga" "ignore_loglevel" "rootwait" ];
    loader = {
        generic-extlinux-compatible.enable  =  true;
        grub.enable                         =  false;
    };
    kernelPackages = let
        linux_librem5_pkg = { fetchgit, buildLinux, ... } @ args:
            buildLinux (args // rec {
                defconfig = "librem5_defconfig";
                version = "6.1.6-librem5";
                modDirVersion = version;
                src = fetchgit {
                    url = "https://source.puri.sm/Librem5/linux.git";
                    hash = "sha256-EE6WHqgBmoRuZnbCPO3NrydOHPxG8G7lZXxDNm/2Kq4=";
                };
                kernelPatches = [];
            } // (args.argsOverride or {}));
            linux_librem5 = pkgs.callPackage linux_librem5_pkg{};
        in
            pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor linux_librem5);
};
3 Likes

Perhaps this merge request may be of interest to you:

If it is we can share here how to install it.

2 Likes

Also do you have the mandatory screenshot of it running NixOS :slight_smile:

:scream:
That seems exactly what is needed! Please share :blush:

Will create :yum:

Well…

On a debian based system…

You would download the .deb package from here;

  1. https://source.puri.sm/a-wai/uboot-imx/-/jobs/405334/artifacts/raw/debian/output/u-boot-librem5_2022.10-librem5.1_arm64.deb

install it with:

sudo apt install ./u-boot-librem5_2022.10-librem5.1_arm64.deb

then run sudo u-boot-install-librem5 /dev/mmcblk0

1 Like

But maybe @angus.ainslie can assist with how to do this on a non PureOS system ^^.

$ curl -LOC - https://source.puri.sm/a-wai/uboot-imx/-/jobs/405334/artifacts/raw/debian/output/u-boot-librem5_2022.10-librem5.1_arm64.deb
$ ar -x u-boot-librem5_2022.10-librem5.1_arm64.deb
$ tar xf data.tar.xz
$ cat usr/bin/u-boot-install-librem5
$ sudo dd if=/dev/zero of=/dev/mmcblk0 bs=1024 count=1055 seek=2
$ sudo dd if=usr/lib/u-boot/librem5/u-boot.imx conv=notrunc of=/dev/mmcblk0 bs=1024 seek=33

I’ll need to verify and execute this.

edit: this works, thanks! :partying_face:

3 Likes

I’ve revived my Librem 5 after it has been laying on my desk for months - plugged in once a week to prevent the battery from draining to zero - after a failed u-boot update, and wanted to finally follow up to your request:

[ookhoi@librem5:~]$ nix run -- nixpkgs#screenfetch
          ::::.    ':::::     ::::'           ookhoi@librem5
          ':::::    ':::::.  ::::'            OS: NixOS 24.11.20241001.e277415 (Vicuna)
            :::::     '::::.:::::             Kernel: aarch64 Linux 6.6.52-librem5
      .......:::::..... ::::::::              Uptime: 1h 25m
     ::::::::::::::::::. ::::::    ::::.      Packages: 1306
    ::::::::::::::::::::: :::::.  .::::'      Shell: bash 5.2.32
           .....           ::::' :::::'       Disk: 11G / 30G (38%)
          :::::            '::' :::::'        CPU: Unknown @ 4x 1.5GHz
 ........:::::               ' :::::::::::.   GPU:
:::::::::::::                 :::::::::::::   RAM: 682MiB / 2888MiB
 ::::::::::: ..              :::::
     .::::: .:::            :::::
    .:::::  :::::          '''''    .....
    :::::   ':::::.  ......:::::::::::::'
     :::     ::::::. ':::::::::::::::::'
            .:::::::: '::::::::::
           .::::''::::.     '::::.
          .::::'   ::::.     '::::.
         .::::      ::::      '::::.

Not much installed yet.

4 Likes