NixOS on ARM/PINE64 ROCKPro64: Difference between revisions

imported>Mic92
Mention nixos-aarch64-images
m Serial console: Dark mode support
 
(7 intermediate revisions by 5 users not shown)
Line 29: Line 29:


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
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 ==
Line 51: 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 56: Line 63:
{| class="table"
{| class="table"
|-
|-
!colspan="2" style="background: #fafafa"| Pi-2 Bus
!colspan="2" style="background: var(--color-inverted)"| Pi-2 Bus
|-
|-
! Pin
! Pin
Line 70: 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:
 
== Downstream kernel ==
 
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:
 
* [https://github.com/ayufan-rock64/linux-kernel ayufan-rock64/linux-kernel] 4.4 based on Rockchip BSP
* [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 old vendor U-Boot 2017.09 did not leave enough room between the kernel and initrd, causing recent kernels to overwrite the beginning of the initrd. This can be fixed by increasing <code>ramdisk_addr_r</code> in the U-Boot console, or using upstream U-Boot. }}


== Custom NixOS Installer ==
<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>


It is possible to build a custom nixos installer image with a downstream kernel that will boot as-is on the rockpro64.
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>:
For a working example see this repo: [https://github.com/AshyIsMe/nixos-installer-rockpro64 nixos-installer-rockpro64]


== Panfrost GPU Driver ==
<syntaxHighlight lang=console>
# Connect to /dev/ttyUSB0 at baud 1500000
$ nix-shell -p picocom --run "picocom /dev/ttyUSB0 -b 1500000"
</syntaxHighlight>


The ROCKPro64's GPU is supported by the open source Panfrost driver. The downstream ayufan-rock64/linux-mainline-kernel is known to work. The mainline kernel may also work, but has not been tested. At the time of writing, support has been added to the required userspace libraries, but the changes have not yet been released. It is therefore necessary to build libdrm, mesa, mesa-glu and kmscube from their respective git sources.
See https://wiki.pine64.org/wiki/ROCKPro64#Setup_a_Serial_Console_.28UART.29 for more information on setting up the serial console


== Resources ==
== Resources ==


* [https://www.pine64.org/rockpro64/ Official product page]
* [https://www.pine64.org/rockpro64/ Official product page]