Jump to content

NixOS on ARM/PINE64 ROCK64: Difference between revisions

Update to account for upstream U-Boot
imported>Bennofs
imported>Lopsided98
(Update to account for upstream U-Boot)
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.
 
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
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).
This bootloader is not entirely open, incorporating a binary blob for the tertiary program loader (TPL).


== 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):
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">sudo dd if=idbloader.img of=/dev/mmcblkX bs=512 seek=64</syntaxhighlight>
<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>


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:
{{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.}}
<syntaxhighlight lang="nix">
networking.localCommands = ''
  ${pkgs.ethtool}/bin/ethtool -K eth0 rx off tx off
'';
</syntaxhighlight>


== Serial console==
== Serial console==
Line 70: Line 66:


== Compatibility notes ==
== Compatibility notes ==
{{Expansion | Need to verify hardware support on different kernels, this was written from memory}}


{| class="table arm-compatibility"
{| class="table arm-compatibility"
!colspan="2" style="background: #fafafa"| Mainline kernel
|
! style="background: #fafafa" | Mainline kernel !! style="background: #fafafa" | ayufan-rock64/linux-mainline-kernel
|-
|-
! Ethernet
! Ethernet  
|
| Works || Works
* Works on 4.20, if hardware check-summing is disabled (see above)
|-
|-
! USB
! USB
|
| As of 5.4, USB 3.0 does not work || Works
* As of 4.20, USB 3.0 does not work
|-
!colspan="2" style="background: #fafafa"| ayufan-rock64/linux-mainline-kernel
|-
! Ethernet
|
* Works if hardware check-summing is disabled (see above)
|-
|-
! USB
! HDMI
|
| Works || Works
* USB hot plugging does not work
|}
|}


Line 102: Line 88:
* [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).
* [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 ROCK64 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 ubootRock64 sources to change the default.}}
{{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. }}
{{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=7147 Official product page]
* [https://www.pine64.org/?page_id=7147 Official product page]
Anonymous user