NixOS on ARM/PINE64 ROCK64

From NixOS Wiki
Revision as of 23:41, 27 November 2019 by imported>Bennofs (→‎Downstream kernel)

The ROCK64 is a single board computer built around the Rockchip RK3328 SoC.

PINE64 ROCK64
A PINE A64-LTS with eMMC.
Manufacturer PINE64 (Pine Microsystems Inc.)
Architecture AArch64
Bootloader Downstream (ayufan) U-Boot[1]
Boot options SD, eMMC, SPI NOR Flash

There are three models of the board, with 1, 2 or 4 GB of RAM. It can boot from an microSD card or an eMMC. It also has a 128 Mbit SPI flash that can be used to store the bootloader.

Status

It is possible to run NixOS on this board using a downstream U-Boot and kernel. This can be done with manual partitioning and nixos-install or possibly by building an SD image with the correct kernel and bootloader, but the latter has not been tested.

The upstream aarch64 SD image may boot if U-Boot is placed at the correct location as described below, but this has not been tested. There may be issues with ethernet and USB with the mainline kernel.

U-Boot for this board is packaged in nixpkgs, and Hydra builds can be found here: https://hydra.nixos.org/job/nixpkgs/trunk/ubootRock64.aarch64-linux This bootloader is not entirely open, incorporating a blob for the tertiary program loader (TPL).

Board-specific installation notes

U-Boot needs to be copied to sector 64 on the microSD card or eMMC with dd. Download/build U-Boot for the board, and copy idbloader.img to the correct location with (replace /dev/mmcblkX with the correct path to the SD card device):

sudo dd if=idbloader.img of=/dev/mmcblkX bs=512 seek=64

On many kernels, the ethernet driver cannot handle hardware check-summing of large packets, therefore this feature must be disabled for the ethernet to be stable. This can be done with the following NixOS configuration:

networking.localCommands = ''
  ${pkgs.ethtool}/bin/ethtool -K eth0 rx off tx off
'';

Serial console

The ROCK64 uses a GPIO pinout compatible with the Raspberry Pi 2 and newer. This means that the following pins can be used to connect a serial adapter:

Pi-2 Bus
Pin Function
6 GND
8 UART0_TX
10 UART0_RX

The serial console runs at 1500000 baud in the bootloader. When using the standard NixOS aarch64 sd image, set console=ttyS2,115200n8 as kernel option in extlinux/extlinux.conf on the boot partition of the sdimage to get a serial linux console. For debugging, console=uart8250,mmio32,0xff130000 should give you an early UART console, before the full serial console is up.

Compatibility notes

Mainline kernel
Ethernet
  • Works on 4.20, if hardware check-summing is disabled (see above)
USB
  • As of 4.20, USB 3.0 does not work
ayufan-rock64/linux-mainline-kernel
Ethernet
  • Works if hardware check-summing is disabled (see above)
USB
  • USB hot plugging does not work

Downstream kernel

To use all hardware functionality, it is currently necessary to use a downstream kernel:

Note: The kernel image built from ayufan-rock64/linux-mainline-kernel is too large to fit into the default memory layout defined in the ROCKPro64 u-boot. This means that, when unpacked, the kernel will overwrite the beginning of the initrd in memory, rendering the initrd unusable and causing the boot to fail. This can be fixed by setting the u-boot environment variable, ramdisk_addr_r to a larger value, either by interrupting u-boot, or by patching the ubootRockPro64 sources to change the default.
Note: Keep in mind that using non-upstream forks of the kernel always incurs some security risk.

Resources