Avatar (Fabio Alessandro Locati|Fale)'s blog

Fedora on Pine64 ROCKPro64

May 29, 2023

Recently, I was looking for a couple of Single Board Computers (SBCs) for a project I’m working on. Given the characteristics I was looking for, there were not many options; in the end, I opted for the ROCKPro64 by Pine64.

Once I received the SBC, I immediately tried to put Fedora on it. The process proved slightly more complex than I was expecting since I assumed that U-Boot (or some other boot loader) was already present on the board. Turns out, it is not! So, the first step became installing U-Boot. An aspect I really like about the ROCKPro64 is that it has 128Mb of Serial Peripheral Interface (SPI) Flash memory. I appreciate this fact because it allows me to install U-Boot there and then a standard OS on another storage device. Speaking of other storage devices, the ROCKPro64 features both an optional eMMC and the mSD Card slot. The process turned out more complex than I initially thought since my goal was to use Fedora on the eMMC, but I forgot to get the eMMC USB adapter, so I had to leverage the mSD Card as well.

This is the process that I follow, and that should work for you as well!

The first aspect to take care of is the installation of U-Boot on the SPI Flash. The first step is to create an mSD Card with the required image to flash the SPI. It is possible to use arm-image-installer directly from the Fedora repositories and then create the mSD Card with the command:

sudo spi-flashing-disk --target=rockpro64-rk3399 --media=/dev/sdb

Once the mSD Card is ready, it is possible to put it into the ROCKPro64 and boot the SBC. By default, the ROCKPro64 boots from the mSD Card, and it is possible to get to the U-Boot terminal by pressing a button during the boot process when it tells you to do so. Once the U-Boot terminal is available, it is possible to validate the correctness of the filenames on the mSD Card by issuing the following command:

=> ls mmc 1:1
   176128   idbloader.img
   352256   idbloader.spi
  1059328   u-boot.itb
  9415168   u-boot-rockchip.bin

4 file(s), 0 dir(s)

The two important files are idbloader.spi and u-boot.itb.

It is now possible to start the process by probing for the SPI Flash with the following command:

=> sf probe
SF: Detected gd25q128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB

Now that the SPI Flash has been probed, it is possible to load the first file to memory:

=> load mmc 1:1 ${fdt_addr_r} idbloader.spi
352256 bytes read in 19 ms (17.7 MiB/s)

Now the first file is loaded in memory, and it is ready to be written at the beginning of the SPI memory:

=> sf update ${fdt_addr_r} 0 ${filesize}
device 0 offset 0x0, size 0x56000
327680 bytes written, 24576 bytes skipped in 84.137s, speed 4286 B/s

Once completed, the idbloader is properly placed on the SPI Flash. It is important to notice the size (0x56000) since this will be needed for the next step to offset at least that amount to ensure that the second write will not partially re-write the first one. It is now possible to proceed with the second file in a similar way by loading it in memory and then writing it to the SPI Flash:

=> load mmc 1:1 ${fdt_addr_r} u-boot.itb
1059328 bytes read in 49 ms (20.6 MiB/s)

=> sf update ${fdt_addr_r} 60000 ${filesize}
device 0 offset 0x60000, size 0x102a00
104244 bytes written, 61480 bytes skipped in 213.216s, speed 3874 B/s

The process is now complete and it is possible to proceed to reboot to the U-Boot installed on the SPI Flash by typing:

=> reset

Personally, I was using a low-quality keyboard that caused me some issues, so I had to reboot mid-process. Even though this is clearly not preferable, it is completely doable. If you find yourself having to reboot mid-process, you can ground pin 23 (SPI1_CLK) by short-circuiting it with pin 25 (GND) for the first 2 seconds after you start up the SBC. If you keep it grounded for more than 2 seconds, the SPI Flash will be completely disregarded, and you will not be able to write to it.

Once I had U-Boot working, I created a Fedora IoT mSD Card:

sudo arm-image-installer --target none --image Downloads/Fedora-IoT-38.20230419.2-20230419.2.aarch64.raw.xz --media /dev/sdb --addkey /home/fale/.ssh/id_rsa.pub --resizefs --norootpass

After the mSD Card was ready, I mounted it on my PC and copied the raw.xz file on it so that when I booted it from the ROCKPro64, I was able to flash it on the eMMC with:

arm-image-installer --target none --image Fedora-IoT-38.20230419.2-20230419.2.aarch64.raw.xz --media /dev/mmcblk0 --addkey .ssh/authorized_keys --resizefs --norootpass

Removing the mSD Card and rebooting allowed me to have the Fedora IoT I wanted on eMMC.

Putting U-Boot and an operating system on an SBC can be a little intimidating the first time you do it, but I hope that this step-by-step guide, as well as the possibility of restarting the process by grounding a pin, can help a little the less experienced users to do it.