NixOS on ARM/NanoPi-R6C: Difference between revisions

From NixOS Wiki
imported>Jakubgs
Setup instructions for NanoPi-R6C
 
imported>Maxhbr
minor fix of partition names in partitioning script
 
(3 intermediate revisions by one other user not shown)
Line 2: Line 2:
<div class="infobox">
<div class="infobox">
{|class="table"
{|class="table"
!colspan="2" class="title"|NanoPi-R6C
!colspan="2" class="title"|NanoPi-R6C & NanoPi-R6S
|-
|-
|colspan="2"|[[File:NanoPi-R6C.jpg|frameless|256px|NanoPi-R6C SBC]]
|colspan="2"|[[File:NanoPi-R6C.jpg|frameless|256px|NanoPi-R6C SBC]]
Line 13: Line 13:
|-
|-
!Bootloader
!Bootloader
| [https://github.com/edk2-porting/edk2-rk3588 EDK2 UEFI firmware for Rockchip RK3588 platforms] or
| [https://github.com/edk2-porting/edk2-rk3588 EDK2 UEFI firmware for Rockchip RK3588 platforms] or [https://github.com/friendlyarm/uboot-rockchip/tree/nanopi6-v2017.09 Original FriendlyARM U-Boot]
| [https://github.com/friendlyarm/uboot-rockchip/tree/nanopi6-v2017.09 Original FriendlyARM U-Boot]
|-
|-
!Boot order
!Boot order
Line 25: Line 24:


== Hardware ==
== Hardware ==
NanoPi-R6C is a single board computer built around the Rockchip RK3588S SoC.
NanoPi-R6C and R6S are single board computers built around the Rockchip RK3588S SoC.


* '''CPU''': ARM Cortex-A76 and Cortex-A55
* '''CPU''': ARM Cortex-A76 and Cortex-A55
Line 57: Line 56:


In '''Boot Manager''' You can select what device to boot from this time and in '''Boot Maintenance Manager''' You can configure permanent boot order.
In '''Boot Manager''' You can select what device to boot from this time and in '''Boot Maintenance Manager''' You can configure permanent boot order.
Keep in mind this example uses the image for R6C and you'll need the right UEFI image for R6S.


=== Booting NixOS ===
=== Booting NixOS ===
Line 77: Line 78:
   mkswap    "${DEV}p2";
   mkswap    "${DEV}p2";
   mkfs.vfat "${DEV}p1";
   mkfs.vfat "${DEV}p1";
   mkfs.ext4 "${DEV}p2";
   mkfs.ext4 "${DEV}p3";
}
}
</syntaxhighlight>
</syntaxhighlight>
Line 86: Line 87:
swapon /dev/nvme0n1p2
swapon /dev/nvme0n1p2
mount  /dev/nvme0n1p3 /mnt
mount  /dev/nvme0n1p3 /mnt
mkdir /mnt/boot
mount  /dev/nvme0n1p1 /mnt/boot
mount  /dev/nvme0n1p1 /mnt/boot
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 20:01, 22 November 2023

NanoPi-R6C & NanoPi-R6S
NanoPi-R6C SBC
Manufacturer FriendlyElec
Architecture AArch64
Bootloader EDK2 UEFI firmware for Rockchip RK3588 platforms or Original FriendlyARM U-Boot
Boot order official: eMMC, SD Card
Maintainer jakubgs

Hardware

NanoPi-R6C and R6S are single board computers built around the Rockchip RK3588S SoC.

  • CPU: ARM Cortex-A76 and Cortex-A55
  • GPU: Mali-G610 MP4
  • RAM: 4GB/8GB LPDDR4X at 2133MHz
  • MMC: None or 32GB eMMC
  • NET: Native Gigabit Ethernet, PCIe 2.5G Ethernet
  • USB: 1x USB 3.0 Type-A, 1x USB 2.0 Type-A
  • PCIe: 1x M.2 Key M connector with PCIe 2.1 x1

Status

The board boots systems like Armbian from USB pendrive or microSD reader out of the box. But stock NixOS arch64 images do not boot correctly due to lack of correct DTS file called rockchip-nanopi6.dtb. You can see details of research into the boot process here.

The official documentation, which is comprehensive, can be found on the FriendlyElec wiki.

U-Boot for this board can be compiled from source, and an example of how that can be done with Nix is here. But the best way to manage booting on this device is using the EDK2 UEFI firmware which supports booting from all available storage options, including NVMe, and works well both with standard NixOS ISO images as well as Armbian ones.

Board Specific Installation Notes

UEFI Firmware

Boot into a working Linux system, like Armbian using USB pendrive or SD Card, then simply write the UEFI image to the eMMC:

wget https://github.com/edk2-porting/edk2-rk3588/releases/download/v0.9.1/nanopi-r6c_UEFI_Release_v0.9.1.img
sudo dd if=nanopi-r6c_UEFI_Release_v0.9.1.img of=/dev/mmcblk2 bs=1M

Once that has been done the UEFI firmware should be visible via UART console or over HDMI after reboot:

NanoPi-R6C UEFI Firmware screen

In Boot Manager You can select what device to boot from this time and in Boot Maintenance Manager You can configure permanent boot order.

Keep in mind this example uses the image for R6C and you'll need the right UEFI image for R6S.

Booting NixOS

Since EDK2 UEFI firmware does not support extlinux an ISO aarch64 image needs to be used to successfully boot NixOS.

Currently NixOS 23.11 images can see the NVMe without issues, but eMMC storage is unavailable.

Installing NixOS

A very basic partition layout could look like this:

format() {
  DEV="${1}" # First argument is NVMe path.
  wipefs -a "${DEV}"
  parted -s --align optimal "${DEV}" -- mklabel gpt;
  parted -s --align optimal "${DEV}" -- mkpart 'EFI'  2MB   6GiB  set 1 esp on;
  parted -s --align optimal "${DEV}" -- mkpart 'SWAP' 6GiB  16GiB;
  parted -s --align optimal "${DEV}" -- mkpart 'ROOT' 16GiB '100%';
  parted -s --align optimal "${DEV}" -- print;
  mkswap    "${DEV}p2";
  mkfs.vfat "${DEV}p1";
  mkfs.ext4 "${DEV}p3";
}

Just call it it with format /dev/nvme0n1 and then mount your partitions:

swapon /dev/nvme0n1p2
mount  /dev/nvme0n1p3 /mnt
mkdir /mnt/boot
mount  /dev/nvme0n1p1 /mnt/boot

And you can continue with the installation as you normally would. A working bootloader configuration looks like this:

  boot.loader = {
    efi.canTouchEfiVariables = true;
    systemd-boot.enable = true;
    grub.enable = false;
  };