NixOS on ARM/Orange Pi Zero2 H626

From NixOS Wiki
Jump to: navigation, search
Orange Pi Zero2 (H616)
An Orange Pi Zero Plus2 (H5).
Manufacturer Xunlong / Orange Pi
Architecture AArch64
Bootloader Upstream u-boot[1]
Maintainer Ein-shved


Upstream unstable NixOS AArch64 image will boot on the Orange Pi Zero2 (H616), using the proper upstream u-boot.

The support of allwiner H616 soc was introduced to the Linux upstream kernel since 6.0 version, but the 5.15.78 kernel still able to boot from unstable NixOS brunch.

Board-specific installation notes

Fastest way

First follow the generic installation steps to get the installer image on an SD card.

U-Boot needs to be copied to specific sectors on the microSD card with dd. Download u-boot for the board, and copy it to the correct location with (again, replace /dev/sdX with the correct path to the SD card device):

sudo dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=1024 seek=8

Then, install using the installation and configuration steps.

Better way

You can use next flake to prepare ready-to-work image

  description = "Build image for Orange Pi Zero2 H616";
  inputs.nixpkgs.url = github:nixos/nixpkgs;
  outputs = { self, nixpkgs }: rec {
    # Better to avoid cross-compiling to 
    # download derivations from cache 
    system = "aarch64-linux";
    nixosConfigurations.orpiz2 = nixpkgs.lib.nixosSystem rec {
      system = "aarch64-linux";
      modules = [
        # Based on generic aarch64 image
          config = let
            # Appropriate bootloader
            bootloader = nixpkgs.legacyPackages.
          in {
            system.stateVersion = "22.11";
            # Use the supported kernel
            boot.kernelPackages = nixpkgs.legacyPackages.
            sdImage.postBuildCommands = ''
              # Emplace bootloader to specific place in firmware file
              dd if=${bootloader}/u-boot-sunxi-with-spl.bin of=$img \
                  bs=1024 seek=8 \
                  conv=notrunc # avoid truncation of image
    images = {
      orpiz2 =;
nix build .#images.orpiz2
to prepare image

Serial console

The default console configuration from sd-image-aarch64 works out of the box.


Connected at 1Gbps mode.


The vanilla dts from kernel 6.0.9 does not contains required usb sections. Working on correct dts overlay for it.


Not tested


Not tested