Building my own image for the Turing RK1

2 min read

linux, arm

I recently received the Turing Pi 2.5 with 4 Turing RK1 modules, I wanted to build and maintain my own operating system images for the RK1s.

The first step in this adventure, is to build the bootloader, U-Boot.

Pre-requirements

I am using ArchLinux, the commands below will be for this operating system. First, you'll have to install the appropriate GCC toolchain as well as any other dependencies required, I may forgot to list some in the command below.

❯ sudo pacman -S aarch64-linux-gnu-gcc make git

Getting required Blobs for building U-Boot

If you try to jump directly to building U-Boot, you will eventually run into the following two missing blobs.

atf-bl31

  1. Clone arm-trusted-firmware:

    ❯ git clone https://github.com/ARM-software/arm-trusted-firmware.git
    
  2. Build:
    You can check the value for PLAT by checking in the plat directory of the repository.

    ❯ make PLAT=rk3588 CROSS_COMPILE=aarch64-linux-gnu- bl31 -j
    

    Write down the path for bl31.elf outputed at the end of the build.

rockchip-tpl

  1. Clone rkbin:

    ❯ git clone https://github.com/rockchip-linux/rkbin.git
    
  2. Look for a file named rk3588_ddr_lp4_2112MHz_lp5_2400MHz_v1.16.bin which should be in the bin/rk35 directory inside the repository.

OP-TEE (optional)

OP-TEE seems to not support the RK3588 for now. Repository: https://github.com/OP-TEE/optee_os. U-Boot will still build fine without OP-TEE, although you may get a warning.

Building U-Boot

  1. Clone U-Boot:

    ❯ git clone https://source.denx.de/u-boot/u-boot.git
    
  2. Make the default config for the RK1:

    Device Tree Source Code of the RK1 is included in the main branch, you can check with:

    ❯ ls arch/arm/dts | grep turing
    rk3588-turing-rk1-u-boot.dtsi
    

    Check the default config name then create the config from the default config:

    ❯ ls configs/ | grep turing
    turing-rk1-rk3588_defconfig
    ❯ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- turing-rk1-rk3588_defconfig
    #
    # configuration written to .config
    #
    
  3. Building U-Boot:
    I had to install a few additionnal dependencies before building.

    ❯ sudo pacman -S swig
    ❯ pip install pyelftools
    ❯ ROCKCHIP_TPL=../rkbin/bin/rk35/rk3588_ddr_lp4_2112MHz_lp5_2400MHz_v1.16.bin \
          BL31=../arm-trusted-firmware/build/rk3588/release/bl31/bl31.elf \
          ARCH=arm64 \
          CROSS_COMPILE=aarch64-linux-gnu- \
          make -j
    

Create the bootable image

❯ dd if=/dev/zero of=final.img bs=512 count=32767
❯ dd if=./idbloader.img of=final.img bs=512 seek=64
❯ dd if=./u-boot.itb of=final.img bs=512 seek=16384

Flashing on a Node

Flash the iamge on the node using tpi:

❯ tpi flash --image-path ./final.img --node 4

Now your RK1 module should boot into U-Boot, you can check with the following command:

❯ tpi uart --node 4 get

Next steps

Actually install an operating system!

Resources

Here is a list of additional resources I used to get here: