I picked up a Firefly-RK3399 to get more familiar with 64 bit arm linux, modern Cortex-A* series SoC and virtualization on ARM. First step is to compile the Linux kernel.

Board Info

The Firefly-RK3399 is an ARM64 SBC, using the big-little architecture with 2x CortexA72 and 4x CortexA53.

Both the Board vendor and the SoC vendor maintain kernel source trees:

The board vendor has compilation info here.

By default the board has Android installed on the eMMC. I’d like to install Linux on the SDCARD, with the ability to update the Kernel.

I’m doing it a little different, using Ubuntu 18.04 and directly downloading and installing the 7.3.1-2018.05 Linaro toolchain and device tree compiler. Most of the above flow works, with a few changes.

Ubuntu 18.04 setup

The firefly instructions are for an older Ubuntu. These packages were used on Ubuntu 18.04:

sudo apt-get install git gnupg flex bison gperf build-essential zip tar curl libc6-dev  libreadline-dev  g++-multilib cmake tofrodos python-markdown libxml2-utils xsltproc  libssl-dev
sudo apt-get install lzop libncurses5-dev libssl1.0.0 libssl-dev
sudo apt-get install libyaml-dev pkg-config # for dtc
sudo apt-get install libncurses5-dev bc # menuconfig. makefiles

DTC Install

git clone https://git.kernel.org/pub/scm/utils/dtc/dtc.git
cd dtc
sudo make install PREFIX=/opt/dtc

GCC Cross Compiler

cd ~/Downloads
wget https://releases.linaro.org/components/toolchain/binaries/7.3.1-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz 
cd /opt
sudo tar xJvf ~/Downloads/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz 

Check it runs:

aarch64-linux-gnu-gcc -v

Create a new Image

export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-

git clone -b firefly https://github.com/FireflyTeam/kernel.git
mv kernel firefly-kernel
cd firefly-kernel

make firefly_linux_defconfig

make menuconfig

(Update kernel .config from the default firefly_linux_defconfig- I’ve enabled KVM)

I’ve disabled these warnings to complete the compile: (As we are using a different compiler to what the board vendor compiled with).

edit Makefile

KBUILD_CFLAGS += -Wno-format-security -Wno-format-truncation -Wno-int-in-bool-context -Wno-duplicate-decl-specifier -Wno-memset-elt-size -Wno-misleading-indentation -Wno-tautological-compare -Wno-format-overflow -Wno-pointer-compare\


make rk3399-firefly-linux.img -j4

This makes two files kernel.img and resource.img.

Vendor Image Format

The %.img target is built by the arch/arm64/Makefile using the normal arch/arm64/boot/Image. This format seems to come from rockchip.

It uses the scripts/mkkrnlimg binary tool to package Image into kernel.img, and the scripts/resource_tool to package the device tree and kernel.img.