From Gentoo Wiki
Jump to:navigation Jump to:search



PINE64 ROCKPro64 — a Rockchip RK3399 (ARMv8-A, Cortex-A72/A53 big.LITTLE) based, exceptionally libre software friendly SBC.

Serial comms

I'm using a C232HD DDHSP-0 - FTDI based USB -> Serial (3.3v) connector

Connected GND (black) to pin 6 and (yellow) Rx (i.e. RockPro64 Tx) to pin 8. RockPro64 Wiki

This is just to monitor when things go wrong.

Note: If build of Das U-boot is successful, it should be possible to use Monitor and Keyboard if U-Boot fails to boot the kernel.

To talk to U-boot using the serial interface, also connect pin 10 to Tx (Orange), but only after powered up and starting of U-boot as there seems to be an issue if connected before.

USB to serial adapter — details the process of enabling support for USB to serial (RS-232, RS-422, RS-485 etc) adapters in the Linux kernel.

Build Environment

When building the Trusted Firmware you need both the ARM 64 and ARM 32 compilers, so even if building this on a ARM 64 environment, the cross compiler for ARM 32 needs to be installed.

Setup cross-compiler

Cross build environment — provides instructions on creating a cross build environment using crossdev.

root #emerge --ask sys-devel/crossdev

Create a separate ebuild repository as per link above, reminds below..

root #emerge --ask app-eselect/eselect-repository
root #eselect repository create crossdev

Build Arm32 and/or Arm64 tool dependent on the build machine architecture

root #crossdev --target aarch64-unknown-linux-gnu
root #crossdev --target arm-none-eabi -s4

RockPro64 installation steps

From the factory nothing stored in SPI flash. I don't have eMMC, just a 32G SD-Card..

Step 1 build das U-boot

Useful links:

Install Software required for building U-boot

Device tree compiler

root #emerge --ask sys-apps/dtc

Das U-Boot tools

root #emerge --ask dev-embedded/u-boot-tools

Kernel sources

root #emerge --ask sys-kernel/gentoo-sources

Das U-Boot. U-boot is very active so best checkout a known good tagged version

user $git checkout v2023.4

Arm trusted firmware (ATF)

ELF manipulation used by u-boot make

root #emerge --ask dev-python/pyelftools


Set some environment variables

user $export CROSS_COMPILE=aarch64-unknown-linux-gnu-
user $cd arm-trusted-firmware
user $make PLAT=rk3399
user $export BL31=path/to/arm-trusted-firmware/build/rk3399/release/bl31/bl31.elf
user $cd ..
user $cd u_boot
user $make rockpro64-rk3399_defconfig
user $make oldconfig

Das U-Boot menuconfig is like kernel menuconfig, so you can modify the build config.

user $make menuconfig

Finally when happy with the config.. build u-boot

user $make

ideas I want to try are:

  • Changing location of U-Boot / ATF as it needs to be at offset 16384 x block size in SD-Card which seems lot of space wasted at start of SD-CARD?
  • Remove Network bootloading functionality (don't need this)

Result should be two files idbloader.img & u_boot.itb

Item Contents SD location
idbloader.img TPL & SPL LBA 64
u_boot.itb U-Boot & ATF LBA 16384

see Boot Sequence for details of boot sequence, but in summary ROM code -> TPL -> Rom Code -> SPL -> ATF -> U-Boot

For future reference a defconfig can be saved like so

user $cd u_boot
user $make savedefconfig
user $cp defconfig my_rockpro64-rk3399_defconfig

My latest defconfig can downloaded from guthub using

Step 2 Format SD-Card

Format the SD-CARD with GPT (see Handbook:AMD64/Installation/Disks), but importantly, allowing enough freespace after the GPT before the first partition for U-Boot images.

dev names are those seen when mounted on rockpro64. For MMC devices, eMMC = 0, SD-CARD = 1

Device on RockPro64 mount point Start Sectors Type Comment
/dev/mmcblk1p1 /boot 32768 376832 EFI System Must start after the u_boot.itb
/dev/mmcblk1p2 / 409600 45146112 Linux filesystem Standard Rootfs, aligned for best SD performance
/dev/mmcblk1p3 N/A 45555712 16778207 Linux Swap 8G of Swap

Note: device name depends on the host PC; for me they are sdbX on my laptop

Note: Normal GPT block ends at LBA 63 so avoid exceeding this.

Use dd to place idloader.img & u_boot.itb at the necessary sector/Block address like so.

root #dd if=xxx of=/dev/mmcblk0 seek=yyy

xxx is the image, yyy is 64 or 16384

Create the other filesystems in the normal way, use FAT 32 for the boot to comply to EFI. I used ext4 for the Root, but pick your favourite.

Step 3 Install stage3

Get stage3 for the Arm64 "stage3-arm64-openrc-xxx.tar.bz2

Mount sd card root parition and untar stage3, standard stuff (see elsewhere for details)..::

root #mount /dev/sdb2 /mnt/rockpro
root #mount /dev/sdb1 /mnt/rockpro/boot
root #tar -xpf stage3-xxx -C /mnt/rockpro

Get portage portage-latest.tar.bz2

unzip, standard stuff (see elsewhere for details)..::

root #tar -xpf portage-latest.tar.bz2 -C /mnt/rockpro/usr
root #mkdir /mnt/rockpro/etc/portage/repos.conf
root #cp /mnt/rpi/usr/share/portage/config/repos.conf /mnt/rpi/etc/portage/repos.conf/gentoo

Step 4 Build Kernel

First get latest standard kernel source like so:

root #emerge --ask sys-kernel/gentoo-sources

Obtain a kernel build configuration for the rockpro64 platform. I originally started with a known working distro see RockPro64 Wiki

My latest config can be downloaded from

and is called rockpro64_linux_config. Make a Symlink

user $ln -s /usr/src/linux-5.16.16-gentoo /usr/src/linux

. The exact path depends on the version of linux source installed.

Copy the default config to "/usr/src/linux/arch/arm64/configs".

change to directory of the kernel sources "/usr/src/linux" and run the usually commands to cross-compile the kernel like so:

user $make ARCH=arm64 rockpro64_linux_defconfig
user $make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- oldconfig
user $make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- menuconfig
user $make ARCH=arm64 CROSS_COMPILE=armv6j-unknown-linux-gnu-

where menuconfig can be used to tweak the build configuration.

The configuration can be saved for future reference like so

user $make CROSS_COMPILE=aarch64-unknown-linux-gnu- savedefconfig
user $cp defconfig my_rockpro64_linux_defconfig

Step 5 Install kernel & U-boot script

  • TODO: Copy dtb and kernel to boot parition

The following boot.cmd file was created

FILE boot.cmd
setenv rootdev "/dev/mmcblk1p2"
setenv rootfstype "ext4"
setenv console "console=tty1 console=ttyS2,1500000"

setenv bootargs "root=${rootdev} rootwait rootfstype=${rootfstype} ${console}"

load ${devtype} ${devnum} ${kernel_addr_r} kernel.img
load ${devtype} ${devnum} ${fdt_addr_r} rk3399-rockpro64.dtb

booti ${kernel_addr_r} - ${fdt_addr_r}

Note: Change where applicable. e.g. if kernel image or root filesystem is different or kernel cmdline is different

Use mkimage from u-boot-tools to compile to a script for Das U-Boot

user $mkimage -C none -A arm -T script -d boot.cmd boot.scr

Copy boot.scr to the boot partition of sd-card.

Step 6 Boot the board

  • TODO: issues see, plus solutions...

RockPro64 Additional software, etc

  • TODO: