Jump to content

NixOS on ARM/PINE64 ROCK64: Difference between revisions

Document how to increase space for kernel
imported>Mirrexagon
(Add note about memory corruption on some v2 boards.)
(Document how to increase space for kernel)
 
(8 intermediate revisions by 5 users not shown)
Line 22: Line 22:
The ROCK64 is a single board computer built around the Rockchip RK3328 SoC.
The ROCK64 is a single board computer built around the Rockchip RK3328 SoC.


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.
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 (not populated on recently manufactured boards) that can be used to store the bootloader.


== Status ==
== Status ==
Line 45: Line 45:




{{note|There is known memory corruption on some ROCK64 v2 boards using both upstream TPL and Rockchip's 786 MHz proprietary blob. The solution is to use the proprietary 333 or 400 MHz blob instead. See discussion here: https://github.com/NixOS/nixpkgs/pull/145506#issuecomment-974985012}}
{{note|ROCK64 v2 boards have marginal DRAM routing and may experience memory corruption with the standard U-Boot build. It is recommended to use the <code>ubootRock64v2</code> package for these devices, which reduces the DRAM clock to increase stability.}}


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


U-Boot needs to be copied to specific sectors on the microSD card, eMMC or image with <code>dd</code>.  
U-Boot needs to be copied to specific sectors on the microSD card, eMMC or image with <code>dd</code>.  This can be done either by using a prebuilt image or by manually formatting the storage.


You can use [https://github.com/Mic92/nixos-aarch64-images nixos-aarch64-images] to get an rock64 compatible disk image
=== Using Prebuilt Images ===
or running the commands manually.
 
You can use [https://github.com/Mic92/nixos-aarch64-images nixos-aarch64-images] to get an ROCK64 compatible disk image.
 
=== Manually Formatting ===
 
To manually format your storage, first install the NIXOS ARM 64 image by following the instructions here. Download and flash the SD Card/SBC image to your SD Card
 
[[NixOS_on_ARM#SD card images (SBCs and similar platforms)]]
 
Next, download/build U-Boot for the board, and write <code>idbloader.img</code> and <code>u-boot.itb</code> to the storage. As mentioned previously, Hydra builds can be found here:
 
https://hydra.nixos.org/job/nixpkgs/trunk/ubootRock64.aarch64-linux


Download/build U-Boot for the board, and write <code>idbloader.img</code> and <code>u-boot.itb</code>.
Replace in the command below <code>/dev/mmcblkX</code> with the correct device to the sdcard i.e.  <code>/dev/mmcblk0</code>. You can use the <code>lsblk</code> command to get a list of all devices:
Replace in the command below <code>/dev/mmcblkX</code> with the correct device to the sdcard i.e.  <code>/dev/mmcblk0</code>. You can use the <code>lsblk</code> command to get a list of all devices:


Line 64: Line 74:
This will make the first partition of the installation device unmountable and it can be deleted, but the space needs to be kept to not overwrite the bootloader with another filesystem.
This will make the first partition of the installation device unmountable and it can be deleted, but the space needs to be kept to not overwrite the bootloader with another filesystem.


{{note|As an alternative to the above, the <code>u-boot-rockchip.bin</code> file combines both  <code>idbloader.img</code> and <code>u-boot.itb</code> and can be written using the single command below:
<syntaxhighlight lang="bash">
dd if=u-boot-rockchip.bin of=/dev/mmcblkX 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.}}
{{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.}}
=== uboot Memory Issues  ===
If you are facing memory issues, kernel panics, kernel oops or general system instability while using the uboot images above (especially with the Rock64 version 2), you can use the ubootRock64v2 image instead, which improves system stability by lowering the memory clock speed at the cost of memory bandwidth.
Hydra builds can be found here (note the v2) https://hydra.nixos.org/job/nixpkgs/trunk/ubootRock64v2.aarch64-linux
Simply follow the manual formatting instructions as above.


== Serial console==
== Serial console==
Line 88: Line 113:
|}
|}


The serial console runs at 1500000 baud in the bootloader. When using the standard NixOS aarch64 sd image, set <code>console=ttyS2,115200n8</code> as kernel option in <code>extlinux/extlinux.conf</code> on the boot partition of the sdimage to get a serial linux console. For debugging, <code>console=uart8250,mmio32,0xff130000</code> should give you an early UART console, before the full serial console is up.
The serial console runs at 1500000 baud in the bootloader. When using the standard NixOS aarch64 sd image, set <code>console=tty1 console=ttyS2,1500000n8</code> as kernel option in <code>extlinux/extlinux.conf</code> on the boot partition of the sdimage to get a serial linux console (tty1 is for standard HDMI output and ttyS2 is for the serial, baud rate setting is optional, simple console=ttyS2 seems to be working fine too). For debugging, <code>console=uart8250,mmio32,0xff130000</code> should give you an early UART console, before the full serial console is up.
 
From the host computer run (update /dev/ttyUSB0 with your USB-to-serial device)
 
<code>
minicom -b 1500000 -8 -D /dev/ttyUSB0  --color=on
</code>
 


== Compatibility notes ==
== Compatibility notes ==
Line 122: Line 154:
This provides sound over HDMI, which the default kernel does not.
This provides sound over HDMI, which the default kernel does not.


{{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. }}
=== Initrd fails to unpack during boot ===
 
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.
 
Here is how to achieve in the uboot console (hit enter during boot to access it):
 
<syntaxHighlight>
=> print ramdisk_addr_r # this prints the old value
ramdisk_addr_r=0x06000000
=> set ramdisk_addr_r 0x07000000 # this sets a new value
=> saveenv # this persist the the configuration
=> boot # than you can normally boot, if it still fails, you can try to increase the ramdisk_addr_r value further
</syntaxHighlight>


== Video decoding ==
== Video decoding ==
Line 149: Line 193:
== Resources ==
== Resources ==


* [https://www.pine64.org/devices/single-board-computers/rock64/ Official product page]
* [https://pine64.org/devices/rock64/ Official product page]