NixOS on ARM/PINE64 ROCKPro64: Difference between revisions

From NixOS Wiki
imported>Thra11
Add note explaining that addr_ramdisk_r needs to be increased to boot the mainline kernel
fix links
 
(16 intermediate revisions by 8 users not shown)
Line 4: Line 4:
!colspan="2" class="title"|PINE64 ROCKPro64
!colspan="2" class="title"|PINE64 ROCKPro64
|-
|-
|colspan="2"|[[File:ROCKPro64.jpg|frameless|256px|A PINE A64-LTS with eMMC.]]
|colspan="2"|[[File:ROCKPro64.jpg|frameless|256px|A PINE64 ROCKPro64.]]
|-
|-
!Manufacturer
!Manufacturer
Line 13: Line 13:
|-
|-
!Bootloader
!Bootloader
|Downstream (ayufan) U-Boot<ref>https://github.com/ayufan-rock64/linux-u-boot</ref>
|Upstream U-Boot
|-
|-
!Boot options
!Boot options
|SD, eMMC, SPI NOR Flash
|microSD, eMMC, SPI NOR Flash
|}
|}
</div>
</div>
Line 26: Line 26:
== Status ==
== 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 <code>nixos-install</code> or possibly by building an SD image with the correct kernel and bootloader, but the latter has not been tested.
This board has upstream U-Boot and kernel support, although the mainline kernel may still be missing some features. NixOS can be installed using manual partitioning and <code>nixos-install</code> or by modifying the aarch64 installation image as described in the next section.


U-Boot for this board is packaged in nixpkgs, and Hydra builds can be found here: https://hydra.nixos.org/job/nixpkgs/trunk/ubootRockPro64.aarch64-linux
U-Boot for this board is packaged in nixpkgs, and Hydra builds can be found here: https://hydra.nixos.org/job/nixpkgs/trunk/ubootRockPro64.aarch64-linux
This bootloader is not entirely open, incorporating blobs for the tertiary program loader (TPL) and ARM trusted firmware (ATF).
 
It can also be [[NixOS on ARM#Compiling through binfmt QEMU | cross compiled]] with
<syntaxhighlight lang="bash">
nix-build '<nixpkgs>' --argstr system aarch64-linux -A ubootRockPro64 --out-link ubootRockPro64
</syntaxhighlight>


== Board-specific installation notes ==
== Board-specific installation notes ==


U-Boot needs to be copied to sector 64 on the microSD card or eMMC with <code>dd</code>. Download/build U-Boot for the board, and copy <code>idbloader.img</code> to the correct location with (replace <code>/dev/mmcblkX</code> with the correct path to the SD card device):
You can use [https://github.com/Mic92/nixos-aarch64-images nixos-aarch64-images] to get an rockpro64 compatible disk image or running the commands manually as described below:
 
U-Boot needs to be copied to specific sectors on the microSD card, eMMC or image with <code>dd</code>. Download/build U-Boot for the board, and write <code>idbloader.img</code> and <code>u-boot.itb</code> to the correct locations with (replace <code>/dev/mmcblkX</code> with the correct path to the card or image):
 
<syntaxhighlight lang="bash">
dd if=idbloader.img of=/dev/mmcblkX conv=fsync,notrunc bs=512 seek=64
dd if=u-boot.itb of=/dev/mmcblkX conv=fsync,notrunc bs=512 seek=16384
</syntaxhighlight>


<syntaxhighlight lang="bash">sudo dd if=idbloader.img of=/dev/mmcblkX bs=512 seek=64</syntaxhighlight>
{{note|Prior to NixOS 20.03, a downstream version of U-Boot 2017.09 was packaged, which placed U-Boot in a single <code>idbloader.img</code> file. If that version is used, simply disregard the second command above.}}


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:
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:
Line 45: Line 56:


== Serial console==
== Serial console==
{{note|Do not connect RxD (pin 10) until the U-Boot SPL is running (see [RK3399 boot sequence|https://wiki.pine64.org/wiki/RK3399_boot_sequence]) or the SPL will not start}}


The ROCKPro64 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:
The ROCKPro64 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:
Line 64: Line 77:
| UART0_RX
| UART0_RX
|}
|}
See https://wiki.pine64.org/wiki/ROCKPro64#GPIO_Pins for list of all pins


The serial console runs at 1500000 baud in the bootloader.
The serial console runs at 1500000 baud in the bootloader.


{{note| It is not recommended to connect the serial adapter to pin 10 (RX) while booting, as this often causes the board to hang early in the bootloader. Disconnecting pin 10 still allows the serial console to be viewed, and it can be reconnected after the board boots, allowing interaction with the console.}}
To connect check your <code>dmesg</code> for an identifier of the serial console:
 
<syntaxHighlight>
[78635.965459] usb 2-1: new full-speed USB device number 8 using xhci_hcd
[78636.119008] usb 2-1: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.63
[78636.119017] usb 2-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[78636.119022] usb 2-1: Product: USB2.0-Serial
[78636.127103] ch341 2-1:1.0: ch341-uart converter detected
[78636.142043] usb 2-1: ch341-uart converter now attached to ttyUSB0
</syntaxHighlight>


== Downstream kernel ==
In our example that coresponds to the <code>ttyUSB0</code> which makes a new device available at <code>/dev/ttyUSB0</code> to which you can connect using for (example) <code>picocom</code>:


Although the mainline kernel contains a device tree for the ROCKPro64, it does not seem to boot correctly as of 4.20. Therefore it is necessary to use a downstream kernel:
<syntaxHighlight lang=console>
# Connect to /dev/ttyUSB0 at baud 1500000
$ nix-shell -p picocom --run "picocom /dev/ttyUSB0 -b 1500000"
</syntaxHighlight>


* [https://github.com/ayufan-rock64/linux-kernel ayufan-rock64/linux-kernel] 4.4 based on Rockchip BSP
See https://wiki.pine64.org/wiki/ROCKPro64#Setup_a_Serial_Console_.28UART.29 for more information on setting up the serial console
* [https://github.com/ayufan-rock64/linux-mainline-kernel ayufan-rock64/linux-mainline-kernel] mainline based, with potentially fewer hardware features supported. This kernel is not based on a kernel stable branch, so it may have more bugs (unrelated to the hardware). {{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, <code>addr_ramdisk_r</code> 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 ==
== Resources ==


* [https://www.pine64.org/?page_id=61454 Official product page]
* [https://www.pine64.org/rockpro64/ Official product page]

Latest revision as of 14:02, 1 April 2024

PINE64 ROCKPro64
A PINE64 ROCKPro64.
Manufacturer PINE64 (Pine Microsystems Inc.)
Architecture AArch64
Bootloader Upstream U-Boot
Boot options microSD, eMMC, SPI NOR Flash

The ROCKPro64 is a powerful single board computer built around the Rockchip RK3399 SoC.

There are two models of the board, with 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

This board has upstream U-Boot and kernel support, although the mainline kernel may still be missing some features. NixOS can be installed using manual partitioning and nixos-install or by modifying the aarch64 installation image as described in the next section.

U-Boot for this board is packaged in nixpkgs, and Hydra builds can be found here: https://hydra.nixos.org/job/nixpkgs/trunk/ubootRockPro64.aarch64-linux

It can also be cross compiled with

nix-build '<nixpkgs>' --argstr system aarch64-linux -A ubootRockPro64 --out-link ubootRockPro64

Board-specific installation notes

You can use nixos-aarch64-images to get an rockpro64 compatible disk image or running the commands manually as described below:

U-Boot needs to be copied to specific sectors on the microSD card, eMMC or image with dd. Download/build U-Boot for the board, and write idbloader.img and u-boot.itb to the correct locations with (replace /dev/mmcblkX with the correct path to the card or image):

dd if=idbloader.img of=/dev/mmcblkX conv=fsync,notrunc bs=512 seek=64
dd if=u-boot.itb of=/dev/mmcblkX conv=fsync,notrunc bs=512 seek=16384
Note: Prior to NixOS 20.03, a downstream version of U-Boot 2017.09 was packaged, which placed U-Boot in a single idbloader.img file. If that version is used, simply disregard the second command above.

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

Note: Do not connect RxD (pin 10) until the U-Boot SPL is running (see [RK3399 boot sequence

The ROCKPro64 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

See https://wiki.pine64.org/wiki/ROCKPro64#GPIO_Pins for list of all pins

The serial console runs at 1500000 baud in the bootloader.

To connect check your dmesg for an identifier of the serial console:

[78635.965459] usb 2-1: new full-speed USB device number 8 using xhci_hcd
[78636.119008] usb 2-1: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.63
[78636.119017] usb 2-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[78636.119022] usb 2-1: Product: USB2.0-Serial
[78636.127103] ch341 2-1:1.0: ch341-uart converter detected
[78636.142043] usb 2-1: ch341-uart converter now attached to ttyUSB0

In our example that coresponds to the ttyUSB0 which makes a new device available at /dev/ttyUSB0 to which you can connect using for (example) picocom:

# Connect to /dev/ttyUSB0 at baud 1500000
$ nix-shell -p picocom --run "picocom /dev/ttyUSB0 -b 1500000"

See https://wiki.pine64.org/wiki/ROCKPro64#Setup_a_Serial_Console_.28UART.29 for more information on setting up the serial console

Resources