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

Can someone with serial console access on Librem 5 (or devkit?) try to boot these aarch64 NixOS kernel, initrd and dtb, and let me know what error it gives?

https://humilis.net/u-boot-librem5.bin
https://humilis.net/nixos-linux-6.1.2-image
https://humilis.net/nixos-linux-6.1.2-initrd
https://humilis.net/imx8mq-librem5-r4.dtb

boot-nixos-with-uuu.lst:

uuu_version 1.0.1
CFG: FB:  -vid 0x316d -pid 0x4c05
CFG: SDP: -chip MX8MQ -compatible MX8MQ -vid 0x316d -pid 0x4c05

SDP: boot -f u-boot-librem5.bin
SDPU: delay 1000
SDPU: write -f u-boot-librem5.bin -offset 0x57c00
SDPU: jump

SDPV: delay 1000
SDPV: write -f u-boot-librem5.bin -skipspl
SDPV: jump

SDPS: boot -f u-boot-librem5.bin
SDPS: delay 1000

FB: ucmd setenv bootargs earlyprintk=vga console=tty0 ignore_loglevel

FB: ucmd setenv fastboot_buffer 0x40000000
FB: download -f nixos-linux-6.1.2-image
FB: ucmd setenv fastboot_buffer 0x44000000
FB: download -f imx8mq-librem5-r4.dtb
FB: ucmd setenv fastboot_buffer 0x44800000
FB: download -f nixos-linux-6.1.2-initrd

FB: acmd booti 0x40000000 0x44800000:${fastboot_bytes} 0x44000000
FB: Done

uuu -v boot-nixos-with-uuu.lst

This is the hardest ARM device I’ve ever encountered :slight_smile:

I’ve spend the past two weeks trying to boot NixOS, and self-compiled barebox and u-boot on my Librem 5. As Librem 5 has no serial console port - https://puri.sm/posts/avoid-boot-loops-try-librem-5-serial/ - trying boot software is a matter of trial and error. (Purism, please include a serial port on the next version).

barebox might not support Librem 5: closest I found was for i.MX8MP-EVK: https://www.barebox.org/doc/latest/boards/imx/nxp-imx8mp-evk.html
This produces barebox-nxp-imx8mq-evk.img but seems not bootable.

u-boot seems to support Librem 5: https://u-boot.readthedocs.io/en/latest/board/purism/librem5.html
but these build instructions seem way too limited compared to the Purims u-boot build script: https://source.puri.sm/Librem5/u-boot-builder/-/blob/librem5/build_uboot.sh

Last resort was using kexec but:

purism@pureos:~$ sudo kexec -l /boot/nixos/ch4w8c2x2i9l5hr2q9013a8ajl64yniv-linux-6.1.2-Image
[sudo] password for purism:
Can't open (/proc/kcore).
Can't open (/proc/kcore).
kexec_load failed: Function not implemented
entry       = 0x437af690 flags = 0xb70000
nr_segments = 3
segment[0].buf   = 0xffffbafd6010
segment[0].bufsz = 0x36d0a00
segment[0].mem   = 0x40000000
segment[0].memsz = 0x37a0000
segment[1].buf   = 0xaaaafd1a1d10
segment[1].bufsz = 0xe080
segment[1].mem   = 0x437a0000
segment[1].memsz = 0xf000
segment[2].buf   = 0xaaaafd1b02d0
segment[2].bufsz = 0x3460
segment[2].mem   = 0x437af000
segment[2].memsz = 0x4000

purism@pureos:~$ zgrep KEXEC /proc/config.gz
# CONFIG_KEXEC is not set
# CONFIG_KEXEC_FILE is not set

Did you see https://source.puri.sm/Librem5/community-wiki/-/wikis/hardware/Serial-Console ?

I don’t say it’s easy…

3 Likes

I had not :slightly_smiling_face: Thanks for the link!

I’m not comfortable making hardware modifications to my Librem 5. I would have bought a devkit if that was still available. Or maybe a spare Librem 5 board when that gets available.

edit: actually the first solution does not require hardware modifications to Librem 5

Yes and that makes it so interesting. But nobody yet found a different, cheaper dock than the Dell one.

Depending on where you’re based I might be able to help you with mine…

1 Like

:open_mouth:
You have all hardware required for serial console access?? I live in Arnhem. I’m currently compiling a kernel for Librem 5 with kexec enabled. If that does not enable me to boot a NixOS kernel and no one follows up on my request your offer could be my last resort to get NixOS on my phone :hugs:

I’m trying to wrap my head conceptualizing a 25 or 9 pin RS-232 serial connector on a phone.

1 Like

Nobody uses RS-232 any more. It’s all UART over TTL.

You just don’t see the humor in it.

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

1 Like

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);
};
2 Likes