Minimal NixOS configuration for NanoPi Zero2 (RK3528A) on eMMC.
  • Nix 90.6%
  • Shell 9.4%
Find a file
sid 6791c17889
All checks were successful
Release image / release (push) Successful in 6m49s
uboot uses cross pkgs, so use x64 system
2026-09-14 17:30:44 +02:00
.forgejo/workflows initial commit 2026-09-14 11:09:17 +02:00
nixos reference renamed uboot package in nanopi-zero2 config 2026-09-14 17:20:37 +02:00
pkgs mirgrate nanopi zero2 boot chain to mainline uboot 2026-09-14 17:13:16 +02:00
.env initial commit 2026-09-14 11:09:17 +02:00
.envrc initial commit 2026-09-14 11:09:17 +02:00
.gitignore initial commit 2026-09-14 11:09:17 +02:00
99-rockchip.rules initial commit 2026-09-14 11:09:17 +02:00
flake.lock initial commit 2026-09-14 11:09:17 +02:00
flake.nix uboot uses cross pkgs, so use x64 system 2026-09-14 17:30:44 +02:00
flash.sh initial commit 2026-09-14 11:09:17 +02:00
id_root initial commit 2026-09-14 11:09:17 +02:00
README.md initial commit 2026-09-14 11:09:17 +02:00

NixOS on NanoPi Zero2

Minimal NixOS configuration for NanoPi Zero2 (RK3528A) on eMMC.

Build the image

Cross-compile the bootable SD-card image (RK3528 U-Boot, NixOS root, extlinux):

nix build .#nixosConfigurations.nanopi-zero2.config.system.build.sdImage

The result is a compressed disk image under result/sd-image/:

nixos-image-sd-card-<date>.<rev>-aarch64-linux.img.zst

Verify the partition layout and bootloader placement:

zstd -d result/sd-image/*.img.zst -o sd-card.img
partx -o NR,START,SECTORS,TYPE sd-card.img
dd if=sd-card.img bs=512 skip=64 count=4 2>/dev/null | xxd

Expected: partition 1 START = 32768 (16 MiB firmware partition), and the Rockchip bootloader magic RKNS at sector 64.

Host udev rule

To let an unprivileged user flash the Rockchip maskrom device (vendor 2207) without sudo, install the rule shipped in this repo:

sudo install -m 0644 99-rockchip.rules /etc/udev/rules.d/99-rockchip.rules
sudo udevadm control --reload

The rule sets MODE="0666" and GROUP="dialout" (so the user must be in the dialout group) and keeps the USB power-controller persistent across re-plugs.

Flash the image

With the board in MaskROM mode, flash the whole disk:

empty/erased eMMC auto-enters MaskROM mode at power-up; otherwise, see MaskROM recovery below.

zstd -d result/sd-image/nixos-image-sd-card-*.img.zst -o sd-card.img
nix run .#flash -- sd-card.img

MaskROM recovery

If a previous flash left the board unbootable, force MaskROM:

  1. Hold the MASK button:
  2. Plug in USB and power on.
  3. Release MASK at least 3 s after the LED comes on.
  4. Re-flash as above.

Troubleshooting: flaky USB loader state

After repeated rkdeveloptool db/rd/wl cycles the RK3528 USB BootROM can return Downloading bootloader failed / Reset Device failed even with a known-good loader. Power-cycle the board and re-run the flash command.

References