NixOS on Rock64Pro

Hi folks,

I’m using a Rock64Pro from Pine64 as my offsite backup device with some HDDs attached.
To get NixOS working on the device I followed all instructions from the Pine64-Wiki and used the NixOS build from here. First boot from the MicroSD card worked and after that I generated a configuration file and rebuilt the system again with some config changes, no errors so far. The new built is instantly running. But after rebooting the device, it booted up into an old built. While booting I have no possibility to select the newest built. It always boots up like this:

.
As you can see, it’s obviously not the newest NixOS-Version and built. After running a nixos-rebuilt switch --upgrade again, it upgrades everything to the newest channel and also config. Running neofetch again, it now displays this:

Rock64Pro uses uboot as boot manager, so I looked up all boot entries in /boot/extlinux/extlinux.conf:

# Generated file, all changes will be lost on nixos-rebuild!

# Change this to e.g. nixos-42 to temporarily boot to an older configuration.
DEFAULT nixos-default

MENU TITLE ------------------------------------------------------------
TIMEOUT 50

LABEL nixos-default
MENU LABEL NixOS - Default
LINUX …/nixos/gq6wvbgp73fgk6r92ma89csq7fdm85yb-linux-6.6.43-Image
INITRD …/nixos/hqrr20g1vg40bw1f4scwfc2pkpp7h7jg-initrd-linux-6.6.43-initrd
APPEND init=/nix/store/888xmyq6pqizx758111zs487wkc4jgdw-nixos-system-backy-24.05.3523.a633d89c6dc9/init loglevel=4
FDTDIR …/nixos/gq6wvbgp73fgk6r92ma89csq7fdm85yb-linux-6.6.43-dtbs

LABEL nixos-5-default
MENU LABEL NixOS - Configuration 5-default (2024-08-05 10:30 - 24.05.3523.a633d89c6dc9)
LINUX …/nixos/gq6wvbgp73fgk6r92ma89csq7fdm85yb-linux-6.6.43-Image
INITRD …/nixos/hqrr20g1vg40bw1f4scwfc2pkpp7h7jg-initrd-linux-6.6.43-initrd
APPEND init=/nix/store/888xmyq6pqizx758111zs487wkc4jgdw-nixos-system-backy-24.05.3523.a633d89c6dc9/init loglevel=4
FDTDIR …/nixos/gq6wvbgp73fgk6r92ma89csq7fdm85yb-linux-6.6.43-dtbs

LABEL nixos-4-default
MENU LABEL NixOS - Configuration 4-default (2024-07-31 20:52 - 24.05.3407.12bf09802d77)
LINUX …/nixos/gq6wvbgp73fgk6r92ma89csq7fdm85yb-linux-6.6.43-Image
INITRD …/nixos/c86rrzbk7mqsadvc6533jh2vv9ks8gav-initrd-linux-6.6.43-initrd
APPEND init=/nix/store/ay5fpvmbd733l8ikrbj0qvm1gp6vr8nx-nixos-system-nixos-24.05.3407.12bf09802d77/init loglevel=4
FDTDIR …/nixos/gq6wvbgp73fgk6r92ma89csq7fdm85yb-linux-6.6.43-dtbs

LABEL nixos-3-default
MENU LABEL NixOS - Configuration 3-default (2024-07-31 20:44 - 24.05.3407.12bf09802d77)
LINUX …/nixos/gq6wvbgp73fgk6r92ma89csq7fdm85yb-linux-6.6.43-Image
INITRD …/nixos/c86rrzbk7mqsadvc6533jh2vv9ks8gav-initrd-linux-6.6.43-initrd
APPEND init=/nix/store/dyd4g0wx4c0l89z63ihk748g609sznb4-nixos-system-nixos-24.05.3407.12bf09802d77/init loglevel=4
FDTDIR …/nixos/gq6wvbgp73fgk6r92ma89csq7fdm85yb-linux-6.6.43-dtbs

LABEL nixos-2-default
MENU LABEL NixOS - Configuration 2-default (2024-07-31 20:31 - 23.05.5533.70bdadeb94ff)
LINUX …/nixos/9b3yq6x6h5nx5v35g631yfg3fv73flz3-linux-6.1.69-Image
INITRD …/nixos/lr7rkdyi92adv4r49pzqg251g0br6shj-initrd-linux-6.1.69-initrd
APPEND init=/nix/store/p74g18fx8dy8mp3nkxnmqs6h15m7z776-nixos-system-nixos-23.05.5533.70bdadeb94ff/init loglevel=4
FDTDIR …/nixos/9b3yq6x6h5nx5v35g631yfg3fv73flz3-linux-6.1.69-dtbs

LABEL nixos-1-default
MENU LABEL NixOS - Configuration 1-default (1970-01-01 00:00 - 23.05.3427.e5f018cf150e)
LINUX …/nixos/l4dqp8306smayy34ab6wcc8ilvm0gba2-linux-6.1.52-Image
INITRD …/nixos/44hj5qq79q2v24776wsy7jjlqjy1macn-initrd-linux-6.1.52-initrd
APPEND init=/nix/store/7wvkshfylm6cilj3jxkdaycarrbbd22h-nixos-system-nixos-23.05.3427.e5f018cf150e/init console=ttyS0,115200n8 console=ttyAMA0,115200n8 console=tty0 nohibernate loglevel=7
FDTDIR …/nixos/l4dqp8306smayy34ab6wcc8ilvm0gba2-linux-6.1.52-dtbs

As you can see, all newer builts are properly listed in this boot configuration, even the default is correct.
But after rebooting the device it always starts into nixos-2-default.

is there anything I need to know about uboot, maybe running a specific command I forgot to refresh the default boot entry?

Thanks in advance!

1 Like

Did you figure this out?

Not yet… :frowning:
Stell waiting for an answer…

Does uboot have a feature of remembering a default?

Sadly I have no idea, there are no special options set in my config, just the basics with

nixos-generate-config

I can’t really help you with the specific issue of booting into the wrong generation. But I’ve been running NixOS on my RockPro64 for while now.

Instead of using u-boot as a bootloader directly, I’ve flashed Tow-Boot - “an opinionated distribution of U-Boot” - which gives a you a nice interface and UEFI working out of the box.
Then I use systemd-boot as the UEFI bootloader, like I do on my other x86 and ARM systems. The installation is exactly the same as on x86: let NixOS install it on the ESP and u-boot will find it. So u-boot really just serves as a UEFI firmware here.
systemd-boot also gives you a nixos generation selector (it should work over a serial cable; while HDMI output works IIRC, using a USB keyboard has been flaky).

I’ve put the ESP (EFI system partition) on an SD card. Having the ESP on the disk itself might also work, I only have it on the SD card because I previously had the rootfs on a ZFS RAID. NixOS itself is installed on an SSD connected via a PCIE SATA controller.

Other than that, the only bit of hardware-specific configuration I’ve got in my NixOS configuration are a few kernel modules for the initrd, a few kernel paramters, and the CPU performance governor:

{...}: {
  boot = {
    initrd = {
      availableKernelModules = [
        "ahci"
        "pcie_rockchip_host"
        "phy_rockchip_pcie"
        "rockchip_dfi"
        "rockchip_thermal"
        "rtc_rk808"
        "rockchip_saradc"
        "uas"
        "fusb302"
      ];
    };
    kernelParams = [
      "console=ttyS2,115200"
      "nohibernate"
    ];
  };
  powerManagement.cpuFreqGovernor = "ondemand";
}

(I think the uas module was from when I had some storage attached to USB. And the nohibernate option is a remnant from when it was a ZFS NAS. But now it’s a router, so it shouldn’t hibernate anyway).

I can really recommend Tow-Boot. I use it on my two ODROID-N2s as well. It’s not perfect, it has bugs; but having a working UEFI environment and being able to use the same bootloader like on x86 just makes things easier. Also it’s built with Nix, so you don’t need to figure out how to built u-boot and inject weird vendor blobs at the right magic offsets.

1 Like