NixOS on ARM/Radxa ROCK5 Model B: Difference between revisions

From NixOS Wiki
imported>Samueldr
m Update U-Boot diff link
imported>Jakubgs
Updating with info about EDK2 UEFI firmware.
Line 2: Line 2:
<div class="infobox">
<div class="infobox">
{|class="table"
{|class="table"
!colspan="2" class="title"|Radxa ROCK5 Model B
!colspan="2" class="title"|[https://radxa.com/rock5b/ Radxa ROCK 5B]
|-
|colspan="2"|[[File:Radxa_ROCK_5B.jpg|frameless|256px|Radxa R SBC]]
|-
|-
!Manufacturer
!Manufacturer
|Radxa
|[https://radxa.com/ Radxa]
|-
|-
!Architecture
!Architecture
|AArch64
|AArch64
|-
|-
!Platform firmware
!Bootloader
|Vendor BSP
|Vendor BSP
|-
|-
!Startup order
!Boot order
|SPI NOR Flash, eMMC, SD
|SPI NOR Flash, eMMC, SD
|-
|-
!Maintainer
!Maintainer
|
|[https://github.com/jakubgs jakubgs]
|}
|}
</div>
</div>


The Radxa ROCK5 Model B is a Single-Board Computer with a Rockchip RK3588 SoC.
The [https://wiki.radxa.com/Rock5/5B Radxa ROCK 5B] is a Single-Board Computer with a Rockchip RK3588 SoC.
 
* '''CPU''': ARM Cortex-A76 and Cortex-A55
* '''GPU''': Mali-G610 MP4
* '''RAM''': 4GB/8GB/16GB LPDDR4X at 2133MHz
* '''MMC''': eMMC Connector for up to 512GB
* '''NET''': 2.5 Gigabit Ethernet
* '''USB''': 2x USB 3.1 Type-A, 2x USB 2.0 Type-A
* '''PCIe''': 1x M.2 Key M connector with PCIe 2.1 x1
 
== Status ==


Support of this system is YMMV (your mileage may vary), and depends on vendor-provided BSP (Board Support Package) based components.
Support of this system is YMMV (your mileage may vary), and depends on vendor-provided BSP (Board Support Package) based components.


== Platform Firmware ==
Three types of bootloaders are available:


=== Vendor Platform Firmware ===
* [https://dl.radxa.com/rock5/sw/images/loader/rock-5b/ Vendor U-Boot] - Works well for eMMC and SD card boot, not for NVMe.
* [https://github.com/samueldr/Tow-Boot/tree/wip/rock5-vendor Community U-Boot] - Supports eMMC and SD card, NVMe sometimes.
* [https://github.com/edk2-porting/edk2-rk3588 EDK2 UEFI Firmware] - Supports all storage boot options, including NVMe.


{{note|The Vendor Platform Firmware operates at the 1500000 baud rate. Your system may need to be configured to use 1500000 baud rate to make the serial console usable.}}
The official hardware documentation can be found [https://wiki.radxa.com/Rock5/hardware/5b on the Radxa wiki].
 
== Bootloader Firmware ==
 
=== Vendor U-Boot Firmware ===


Booting the system with the vendor-provided platform firmware may not work due to a [https://github.com/samueldr/u-boot/commit/a0af72272b8db4b5d83df2f14ad950d3e30b3e04 known issue in older U-Boot].
Booting the system with the vendor-provided platform firmware may not work due to a [https://github.com/samueldr/u-boot/commit/a0af72272b8db4b5d83df2f14ad950d3e30b3e04 known issue in older U-Boot].
Line 35: Line 53:
If using the vendor-provided platform firmware is desired, [https://gitlab.com/K900/nix/-/blob/1ae5db476aee96fab9c445d7b690a8f5cf7fbe75/hacks/orangepi5/kernel/default.nix#L20 renaming the kernel derivation to a shorter name] should allow boot to succeed.
If using the vendor-provided platform firmware is desired, [https://gitlab.com/K900/nix/-/blob/1ae5db476aee96fab9c445d7b690a8f5cf7fbe75/hacks/orangepi5/kernel/default.nix#L20 renaming the kernel derivation to a shorter name] should allow boot to succeed.


=== Community Platform Firmware ===
{{note|The Vendor Platform Firmware operates at the 1500000 baud rate. Your system may need to be configured to use 1500000 baud rate to make the serial console usable.}}
 
=== Community UEFI Firmware ===
 
The best available bootloader is [EDK2 UEFI firmware for Rockchip RK3588 platforms](https://github.com/edk2-porting/edk2-rk3588). The [`0.9.1`](https://github.com/edk2-porting/edk2-rk3588/releases/tag/v0.9.1) release is confirmed working.
 
In order to flash this bootloader we'll need to download two files:
 
* [https://dl.radxa.com/rock5/sw/images/loader/rock-5b/release/rk3588_spl_loader_v1.08.111.bin <tt>rk3588_spl_loader_v1.08.111.bin</tt>] - SPI bootloader image.
* [https://github.com/edk2-porting/edk2-rk3588/releases/download/v0.9.1/rock-5b_UEFI_Release_v0.9.1.img <tt>rock-5b_UEFI_Release_v0.9.1.img</tt>] - UEFI bootloader image.
 
Then use the <tt>rkdeveloptool</tt> tool in version <tt>1.32</tt> or higher as described in [https://wiki.radxa.com/Rock5/install/spi SPI flashing documentation]:
<syntaxhighlight lang="bash">
> nix-shell -p rkdeveloptool
 
[nix-shell:~/rk3588]$ rkdeveloptool --version
rkdeveloptool ver 1.32
 
[nix-shell:~/rk3588]$ sudo rkdeveloptool db rk3588_spl_loader_v1.08.111.bin
Downloading bootloader succeeded.
 
[nix-shell:~/rk3588]$ sudo rkdeveloptool wl 0 rock-5b_UEFI_Release_v0.9.1.img
Write LBA from file (100%)
 
[nix-shell:~/rk3588]$ sudo rkdeveloptool rb
</syntaxhighlight>
 
Now the device has a graphical bootloader available when pressing <tt>Escape</tt> at boot time:
 
[[File:Radxa_ROCK_5B_UEFI_Firmware.png|frameless|600px|NanoPi-R6C UEFI Firmware screen]]
 
{{note|The standard NixOS SD card image supports only <tt>extlinux</tt> so <strong>ISO NixOS image</strong> needs to be used.}}
 
=== Community U-Boot Firmware ===


{{note|This Platform Firmware operates at the 115200 baud rate. The 115200 baud rate is more standard, so it may or may not need to be adapted to be usable.}}
{{note|This Platform Firmware operates at the 115200 baud rate. The 115200 baud rate is more standard, so it may or may not need to be adapted to be usable.}}
Line 51: Line 102:
To build:  
To build:  


<pre>
<syntaxhighlight lang="bash">
$ nix-build -A radxa-rock5b
nix-build -A radxa-rock5b
</pre>
</syntaxhighlight>


The SD or eMMC shared storage image can be flashed as usual:
The SD or eMMC shared storage image can be flashed as usual:


<pre>
<syntaxhighlight lang="bash">
# dd if=shared.disk-image.img of=/dev/XXX bs=1M oflag=direct,sync status=progress
dd if=shared.disk-image.img of=/dev/XXX bs=1M oflag=direct,sync status=progress
</pre>
</syntaxhighlight>


The SPI image <strong>cannot</strong> be installed using the usual installer. For now you should [https://wiki.radxa.com/Rock5/install/spi follow the vendor instructions] to write the <code>binaries/Tow-Boot.spi.bin</code> file to SPI. In other words using <code>rkdeveloptool</code> for the installation, or any other way to write to SPI flash.
The SPI image <strong>cannot</strong> be installed using the usual installer. For now you should [https://wiki.radxa.com/Rock5/install/spi follow the vendor instructions] to write the <code>binaries/Tow-Boot.spi.bin</code> file to SPI. In other words using <code>rkdeveloptool</code> for the installation, or any other way to write to SPI flash.
Line 65: Line 116:
== System configuration ==
== System configuration ==


None of the basic components (Kernel, HW acceleration drivers) are available from upstream NixOS.
A [https://github.com/jakubgs/nixos-config/blob/16cc3ccf5448259e6d88a24bdfa70ee2f455e200/hosts/arael/configuration.nix#L21-L33 working bootloader configuration] looks like this:


Building a working system requires additional configuration.
<syntaxHighlight lang=nix>
  boot.loader = {
    efi.canTouchEfiVariables = true;
    systemd-boot.enable = true;
    grub.enable = false;
  };
</syntaxHighlight>
 
The current NixOS 23.05 release with 6.1 Linux kernel detects NVMe but not the eMMC.


=== @aciceri's flake ===
=== @aciceri's flake ===


Nix flake for building OS image: https://github.com/aciceri/rock5b-nixos
Nix flake for building OS image: https://github.com/aciceri/rock5b-nixos
To build:
<pre>
$ nix-build
</pre>


Flash result to a new second legacy bootable ext4 partition on the installation media
Flash result to a new second legacy bootable ext4 partition on the installation media


Boot into system
Boot into system:
 
<syntaxhighlight lang="bash">
<pre>
sudo nixos-rebuild switch --flake github:jonahbron/config/aciceri-rebooted-into-this#rock5b
$ sudo nixos-rebuild switch --flake github:jonahbron/config/aciceri-rebooted-into-this#rock5b
</syntaxhighlight>
</pre>
 
== Resources ==
 
* [https://wiki.radxa.com/Rock5 Official vendor documentation page]


[[Category:Hardware]]
[[Category:Hardware]]

Revision as of 21:40, 15 November 2023

Radxa ROCK 5B
Radxa R SBC
Manufacturer Radxa
Architecture AArch64
Bootloader Vendor BSP
Boot order SPI NOR Flash, eMMC, SD
Maintainer jakubgs

The Radxa ROCK 5B is a Single-Board Computer with a Rockchip RK3588 SoC.

  • CPU: ARM Cortex-A76 and Cortex-A55
  • GPU: Mali-G610 MP4
  • RAM: 4GB/8GB/16GB LPDDR4X at 2133MHz
  • MMC: eMMC Connector for up to 512GB
  • NET: 2.5 Gigabit Ethernet
  • USB: 2x USB 3.1 Type-A, 2x USB 2.0 Type-A
  • PCIe: 1x M.2 Key M connector with PCIe 2.1 x1

Status

Support of this system is YMMV (your mileage may vary), and depends on vendor-provided BSP (Board Support Package) based components.

Three types of bootloaders are available:

The official hardware documentation can be found on the Radxa wiki.

Bootloader Firmware

Vendor U-Boot Firmware

Booting the system with the vendor-provided platform firmware may not work due to a known issue in older U-Boot.

If using the vendor-provided platform firmware is desired, renaming the kernel derivation to a shorter name should allow boot to succeed.

Note: The Vendor Platform Firmware operates at the 1500000 baud rate. Your system may need to be configured to use 1500000 baud rate to make the serial console usable.

Community UEFI Firmware

The best available bootloader is [EDK2 UEFI firmware for Rockchip RK3588 platforms](https://github.com/edk2-porting/edk2-rk3588). The [`0.9.1`](https://github.com/edk2-porting/edk2-rk3588/releases/tag/v0.9.1) release is confirmed working.

In order to flash this bootloader we'll need to download two files:

Then use the rkdeveloptool tool in version 1.32 or higher as described in SPI flashing documentation:

 > nix-shell -p rkdeveloptool

[nix-shell:~/rk3588]$ rkdeveloptool --version
rkdeveloptool ver 1.32

[nix-shell:~/rk3588]$ sudo rkdeveloptool db rk3588_spl_loader_v1.08.111.bin
Downloading bootloader succeeded.

[nix-shell:~/rk3588]$ sudo rkdeveloptool wl 0 rock-5b_UEFI_Release_v0.9.1.img
Write LBA from file (100%)

[nix-shell:~/rk3588]$ sudo rkdeveloptool rb

Now the device has a graphical bootloader available when pressing Escape at boot time:

NanoPi-R6C UEFI Firmware screen

Note: The standard NixOS SD card image supports only extlinux so ISO NixOS image needs to be used.

Community U-Boot Firmware

Note: This Platform Firmware operates at the 115200 baud rate. The 115200 baud rate is more standard, so it may or may not need to be adapted to be usable.

A WIP tree to build U-Boot using the infrastructure for Tow-Boot is available. (The end-result is not a proper Tow-Boot build.)

This uses a fork with some fixes, so that an installation on the SPI Flash will work, and allow OS booting from NVMe, eMMC or SD. NVMe support may be YMMV depending on the specific hardware.

The board-specific README has further notes.

Using from shared storage (SD, eMMC) or from SPI should work, and both are as supported.

To build:

nix-build -A radxa-rock5b

The SD or eMMC shared storage image can be flashed as usual:

dd if=shared.disk-image.img of=/dev/XXX bs=1M oflag=direct,sync status=progress

The SPI image cannot be installed using the usual installer. For now you should follow the vendor instructions to write the binaries/Tow-Boot.spi.bin file to SPI. In other words using rkdeveloptool for the installation, or any other way to write to SPI flash.

System configuration

A working bootloader configuration looks like this:

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

The current NixOS 23.05 release with 6.1 Linux kernel detects NVMe but not the eMMC.

@aciceri's flake

Nix flake for building OS image: https://github.com/aciceri/rock5b-nixos

Flash result to a new second legacy bootable ext4 partition on the installation media

Boot into system:

sudo nixos-rebuild switch --flake github:jonahbron/config/aciceri-rebooted-into-this#rock5b