Compiling Android 8.1


Hardware Requiremnts

Recommended hardware requirement of development workstation compiling Android 8.1:

  • 64 bit CPU

  • 16GB Physical memory + Swap memory

  • 30GB Free disk space is used for building, and the source tree takes about 8GB

See also the hardware and software configuration stated in Google official document:

Software Requiements

Installing JDK 8

sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk

Installing required packages

sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev \
  libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl \
  libncurses5-dev zlib1g-dev pngcrush schedtool libxml2 libxml2-utils \
  xsltproc lzop libc6-dev schedtool g++-multilib lib32z1-dev lib32ncurses5-dev \
  lib32readline-gplv2-dev gcc-multilib libswitch-perl

sudo apt-get install gcc-arm-linux-gnueabihf \
  libssl1.0.0 libssl-dev \

Downloading Android SDK

Due to the huge size of the Android SDK, please select one of the following clouds to download Firefly-RK3399_Android8.1_xxx.7za:


After the download completes, verify the MD5 checksum before extraction:

$ md5sum /path/to/Firefly-RK3399_Android8.1_git_xxx.7z
6d34e51fd7d26e9e141e91b0c564cd1f Firefly-RK3399_Android8.1_git_xxx.7z

Then extract it:

mkdir -p ~/proj/roc-rk3399-pc
cd ~/proj/roc-rk3399-pc
7z x /path/to/Firefly-RK3399_Android8.1_git_xxx.7z -o./
git reset --hard

Update the correct git remote:

git remote rm origin
git remote add gitlab

Synchronize source code from gitlab:

git pull gitlab firefly-rk3399:firefly-rk3399

You can also view the source code online at:

The Overall Compilation of Android 8.1

HDMI Displays Compilation

./FFTools/  -d rk3399-roc-pc -j8 -l ROC_RK3399_PC-userdebug
./FFTools/mkupdate/ -l ROC_RK3399_PC-userdebug 

HDMI+EDP Displays Compilation

./FFTools/  -d rk3399-roc-pc-edp -j8 -l ROC_RK3399_PC-userdebug
./FFTools/mkupdate/ -l ROC_RK3399_PC-userdebug 

Manually Compiling Android 8.1

Before compilation, execute the following commands to configure environment variables:

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar

Compiling Kernel

cd ~/proj/roc-rk3399-pc/kernel/
make ARCH=arm64 firefly_defconfig
make -j8 ARCH=arm64 rk3399-roc-pc.img

Compiling U-Boot

cd ~/proj/roc-rk3399-pc/u-boot/
make rk3399_defconfig
make ARCHV=aarch64 -j8

Compiling Android

cd ~/proj/roc-rk3399-pc/
source build/
lunch ROC_RK3399_PC-userdebug
make installclean
make -j8

Packing Rockchp Firmware

Packing Fimware in Linux

After compiling you can use Firefly official script to pack all partition image files into the one true Rockchip firmware, by executing the following command:

./FFTools/mkupdate/ update

The resulting file is rockdev/Image-ROC_RK3399_PC/update.img.

Packing Fimware in Windows

It is also very simple in packaging Rockchip firmware update.img under Windows:

  1. Copy all the compiled files in rockdev/Image-ROC_RK3399_PC/ to the rockdev/Image directory of AndroidTool

  2. Run the mkupdate.bat batch file in the rockdev directory of AndroidTool.

  3. update.img will be created in rockdev/Image directory.

Create firmware for TF Card startup

Compiled with Firefly’s script can be packaged into ROC_RK3399_PC_Android8.1_MP_19****.img, run:

./FFTools/mkupdate/ -t sd #different from Android7.1

update After the package is finished, the ROC_RK3399_PC_Android8.1_MP_19****.img will be generated under rockdev/Image-ROC_RK3399_PC/ . Using the way below to create SD boot. Flashing to the SD Card

Partition Images

update.img is the firmware released to end users, which is convenient to upgrade the system of the deveopment board.

During development cycle, it is a great time saving to only flash modified partition images.

Here’s a table summarising the partition image in various stage:

| Stage            | Product             | Partition |
| Compiling Kernel | kernel/kernel.img   | kernel    |
|                  | kernel/resource.img | resource  |
| Compiling U-Boot | u-boot/uboot.img    | uboot     |
| ./     | boot.img            | boot      |
|                  | system.img          | system    |

Note that by excuting ./, boot.img and system.img will be repacked wth the compiled results of Android in out/target/product/ROC_RK3399_PC/ directory, and all related image files will be copied to the directory rockdev/Image-ROC_RK3399_PC/.

The following is a list of the image files:

  • boot.img: Android initramfs image, contains base filesystem of Android root directory, whcih is responsible for initializing and loading the system partition.

  • system.img: Android system partition image in ext4 filesystem format.

  • kernel.img: kernel image.

  • resource.img: Resource image, containing boot logo and kernel device tree blob.

  • misc.img: misc partition image, responsible for starting the mode switch and first aid mode parameter transfer.

  • recovery.img: Recovery mode image.

  • rk3328_loader_v1.08.244.bin: Loader files.

  • uboot.img: U-Boot image file.

  • trust.img: Arm trusted file (ATF) image file.

  • parameter.txt: Partition layout and kernel command line.

  • baseparameter.img:

  • vendor.img:

  • oem.img: