Compile Mainline Kernel

来自Firefly wiki
跳转至: 导航搜索

Prebuilt Firmware

We provide an prebuilt Ubuntu 14.04 firmware, armed with mainline kernel, with features listed below:

  1. Builtin Mali kernel/user drivers, and compiled OpenGL ES demos from SDK.
  2. Use internal eMMC storage, instead of extra TF card.
  3. HDMI display support.

Please download using one of the following cloud storage:

and flash the firmware with this guide.


The working directory below is assumed to be "~/proj/linux-rockchip":

   mkdir -p ~/proj/linux-rockchip

Install Development Packages

Install development packages:

   sudo apt-get install build-essential lzop libncurses5-dev libssl-dev
   # If using 64 bits Ubuntu, you need also:
   sudo apt-get install libc6:i386

Cross Compiling Toolchain

We use the Android SDK's prebuilt cross compiling toolchain.

Copy Android SDK's prebuilt to the working directory:

   cd ~/proj/linux-rockchip
   cp -rl ANDROID_SDK/prebuilts .

arm-eabi-4.6 and arm-eabi-4.7 are required in "prebuilts/gcc/linux-x86/arm/". arm-eabi-4.7 is used to compile U-boot, while arm-eabi-4.6 is used to compile kernel.


Install some tools in the stock ANDROID SDK to system for convenience:

   cp ./kernel/mkkrnlimg /usr/local/bin
   cp ./RKTools/linux/Linux_Upgrade_Tool_v1.2/upgrade_tool /usr/local/bin

rkflashkit is recommended to install:


Here's the content of parameter file used in the prebuilt firmware, with essential info of partition scheme:

  • kernel: flashed with kernel.img (RK KNRL format, packed with mkkrnlimg)
  • boot: flashed with boot.img (RK KNRL format, packed with mkkrnlimg)
  • linuxroot: flashed with linuxroot.img (ext4fs format)
   MAGIC: 0x5041524B
   ATAG: 0x60000800
   MACHINE: 3066
   CHECK_MASK: 0x80
   PWR_HLD: 0,0,A,0,1
   #KERNEL_IMG: 0x62008000
   #FDT_NAME: rk-kernel.dtb
   #RECOVER_KEY: 1,1,0,20,0
   CMDLINE:console=ttyS2,115200 earlyprintk root=/dev/block/mtd/by-name/linuxroot rw rootfstype=ext4 init=/sbin/init initrd=0x62000000,0x00800000 mtdparts=rk29xxnand:0x00008000@0x00002000(kernel),0x00008000@0x0000A000(boot),0x00002000@0x00012000(misc),0x00001000@0x00014000(backup),-@0x00015000(linuxroot)

Flash parameter file to device:

   sudo rkflashkit flash @parameter parameter.txt

To fetch parameter file from device, run:

   sudo rkflashkit backup @parameter parameter.txt


Mainline kernel needs modified U-Boot, instead of the one in the SDK.

Compile U-Boot

Download and compile U-Boot:

   cd ~/proj/linux-rockchip
   git clone -b u-boot-rk3288 u-boot
   cd u-boot
   make rk3288_defconfig
   make -j4

If U-Boot is built succeesfully, the last lines of the build process are:

   LD u-boot
   OBJCOPY u-boot.bin
   OBJCOPY u-boot.srec
   ./tools/boot_merger --subfix ".01.bin" ./tools/rk_tools/RKBOOT/RK3288.ini
   fix opt:RK3288UbootLoader_V2.19.01.bin
   merge success(RK3288UbootLoader_V2.19.01.bin)

"RK3288UbootLoader_V2.19.01.bin" is the newly built u-boot image which is ready to flash using upgrade_tool:

Flash U-Boot

   sudo upgrade_tool ul RK3288UbootLoader_V2.19.01.bin


Pace of mainline kernel development is fast. Up till now, our test branch is based on v4.0-rc1 .

The test branch is at:

This branch is based on:

And import Mali kernel drive code from:

Since support of command line parameter "mtdparts=" is added, eMMC partition scheme can be specified in the parameter file, which is RK SDK's traditional way.

Compile Kernel

First, fetch the source code:

   cd ~/proj/linux-rockchip
   git clone -b firefly kernel

Then make kernel.img and modules using following commands:

   cd ~/proj/linux-rockchip/kernel
   export ARCH=arm
   export CROSS_COMPILE=$PWD/../prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
   make rk3288_firefly_defconfig
   make -j4 zImage
   make rk3288-firefly.dtb
   cat arch/arm/boot/zImage arch/arm/boot/dts/rk3288-firefly.dtb > zImage-dtb
   mkkrnlimg zImage-dtb kernel.img    
   # compile and install modules
   make -j4 modules
   [ -d install_mod ] && rm -rf install_mod
   make INSTALL_MOD_PATH=$PWD/install_mod modules_install
   # Install the files in install_mod to the root filesystem.

Flash Kernel

   sudo rkflashkit flash @kernel /path/to/kernel.img


Create boot.img

   cd ~/proj/linux-rockchip
   git clone
   make -C initrd
   mkkrnlimg initrd.img boot.img # pack as RK KRNL format

Flash boot.img

   sudo rkflashkit flash @boot /path/to/boot.img

Root Filesystem

To create the Linux root filesystem, please refer to Build Ubuntu Rfs.

Flash linuxroot.img:

   sudo upgrade_tool di linuxroot /path/to/linuxroot.img


Known Issues

  • VGA: VGA display support not added.
  • WiFi:AP6335 driver not ported.

Mainline kernel support of RK3288 is constantly improving, but not stable yet. You may encounter slow refreshness of HDMI display, not perfect support of USB devices, etc.

What Is zImage-dtb ?

zImage-dtb appends the dtb to the kernel image, which works only if CONFIG_ARM_APPENDED_DTB turns on.