Mic92 / nixos-aarch64-images

Build NixOS images for various ARM single computer boards
77 stars 20 forks source link

Add support for NanoPi Neo3 #24

Open majkrzak opened 1 hour ago

majkrzak commented 1 hour ago

I see that NanoPi Neo3 is based on RK3328 and therefore may run NixOS like the rock64

https://wiki.friendlyelec.com/wiki/index.php/NanoPi_NEO3

majkrzak commented 1 hour ago

I mannaged to compile image with more or less working u-boot with:

{ pkgs ? import <nixpkgs> {} }:

let
  unfreePkgs = import pkgs.path {
    config.allowUnfree = true;
    inherit (pkgs) system;
  };
  aarch64Pkgs = unfreePkgs.pkgsCross.aarch64-multiplatform;

  buildImage = pkgs.callPackage ./pkgs/build-image {};
  aarch64Image = pkgs.callPackage ./pkgs/aarch64-image {};
  rockchip = uboot: pkgs.callPackage ./images/rockchip.nix {
    inherit uboot;
    inherit aarch64Image buildImage;
  };

in {
  inherit aarch64Image;

  neo3 = rockchip (aarch64Pkgs.buildUBoot {
    defconfig = "nanopi-r2s-rk3328_defconfig";
    extraMeta.platforms = [ "aarch64-linux" ];
    BL31="${aarch64Pkgs.armTrustedFirmwareRK3328}/bl31.elf";
    filesToInstall = [ "u-boot.itb" "idbloader.img" "u-boot-rockchip.bin" ];
  });

}

This causes image to fail botting as follows:

U-Boot SPL 2024.10 (Oct 07 2024 - 14:54:35 +0000)
Trying to boot from MMC2
## Checking hash(es) for config config-1 ... OK
## Checking hash(es) for Image atf-1 ... sha256+ OK
## Checking hash(es) for Image u-boot ... sha256+ OK
## Checking hash(es) for Image fdt-1 ... sha256+ OK
## Checking hash(es) for Image atf-2 ... sha256+ OK
NOTICE:  BL31: v2.10.0  (release):
NOTICE:  BL31: Built : 00:00:00, Jan  1 1980
NOTICE:  BL31:Rockchip release version: v1.2

U-Boot 2024.10 (Oct 07 2024 - 14:54:35 +0000)

Model: FriendlyElec NanoPi R2S
DRAM:  2 GiB
PMIC:  RK805 (on=0x40, off=0x00)
Core:  243 devices, 29 uclasses, devicetree: separate
MMC:   mmc@ff500000: 1
Loading Environment from MMC... Reading from MMC(1)... *** Warning - bad CRC, using default environment

In:    serial@ff130000
Out:   serial@ff130000
Err:   serial@ff130000
Model: FriendlyElec NanoPi R2S
Net:   eth0: ethernet@ff540000
Hit any key to stop autoboot:  0 
No EFI system partition
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
No EFI system partition
Failed to persist EFI variables
** Booting bootflow '<NULL>' with efi_mgr
Loading Boot0000 'mmc 1' failed
EFI boot manager: Cannot load any image
Boot failed (err=-14)
** Booting bootflow 'mmc@ff500000.bootdev.part_3' with extlinux
------------------------------------------------------------
1:      NixOS - Default
Enter choice: 1:        NixOS - Default
Retrieving file: /boot/extlinux/../nixos/pwp33061mnchz50a8byi6mr4av2xbpg8-linux-6.6.45-Image
Retrieving file: /boot/extlinux/../nixos/zs7941s8j6mgm73s8xkvwcf6zlrpv53l-initrd-linux-6.6.45-initrd
append: init=/nix/store/g5v3i1qrf5dsijymsxm29hn4g3zhl6dp-nixos-system-nixos-24.05.3914.c3d4ac725177/init console=ttyS0,115200n8 console=ttyAMA0,115200n8 console=tty0 nohibernate loglevel=7
Retrieving file: /boot/extlinux/../nixos/pwp33061mnchz50a8byi6mr4av2xbpg8-linux-6.6.45-dtbs/rockchip/rk3328-nanopi-r2s.dtb
Moving Image from 0x2080000 to 0x2200000, end=6530000
ERROR: RD image overlaps OS image (OS=2200000..6530000)
Boot failed (err=-14)

While Armbian image boots like:

U-Boot 2022.04-armbian-2022.04-Se4b6-P2db4-H8c72-Vb574-Bda0a-R448a (Oct 02 2024 - 03:40:27 +0000)

Model: FriendlyElec NanoPi R2S
DRAM:  2 GiB
PMIC:  RK8050 (on=0x40, off=0x00)
Core:  223 devices, 20 uclasses, devicetree: separate
MMC:   mmc@ff500000: 1
Loading Environment from MMC... MMC Device 0 not found
*** Warning - No MMC card found, using default environment

In:    serial@ff130000
Out:   serial@ff130000
Err:   serial@ff130000
Model: FriendlyElec NanoPi R2S
Net:   eth0: ethernet@ff540000
Hit any key to stop autoboot:  0 
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:1...
Found U-Boot script /boot/boot.scr
2764 bytes read in 4 ms (674.8 KiB/s)
## Executing script at 00500000
336 bytes read in 3 ms (109.4 KiB/s)
30095872 bytes read in 1306 ms (22 MiB/s)
30498871 bytes read in 1325 ms (22 MiB/s)
65884 bytes read in 11 ms (5.7 MiB/s)
Moving Image from 0x2080000 to 0x2200000, end=3f60000
## Loading init Ramdisk from Legacy Image at 06000000 ...
   Image Name:   uInitrd
   Image Type:   AArch64 Linux RAMDisk Image (gzip compressed)
   Data Size:    30498807 Bytes = 29.1 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
   Loading Ramdisk to 7c211000, end 7df26ff7 ... OK
   Loading Device Tree to 000000007c1fd000, end 000000007c21015b ... OK

Starting kernel ...

May it be matter of aligning some stuff to make it work?