- Nix 90.6%
- Shell 9.4%
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| nixos | ||
| pkgs | ||
| .env | ||
| .envrc | ||
| .gitignore | ||
| 99-rockchip.rules | ||
| flake.lock | ||
| flake.nix | ||
| flash.sh | ||
| id_root | ||
| README.md | ||
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:
- Hold the MASK button:
- Plug in USB and power on.
- Release MASK at least 3 s after the LED comes on.
- 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.