Compiling Android 10.0

Prerequisite

System requirements

Recommended hardware requirement of development workstation compiling Android 10.0:

  • 64 bit Operating System

  • Ubuntu 14.04 or above

  • 16GB Physical memory + Swap memory

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

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 \
  p7zip-full

Downloading Android SDK

Due to the huge size of the Android SDK, it is not possible to directly host it in Gitlab. Therefore the .git directory is compressed as a 7z archive file, uploaded to cloud storage server. The increment update of the SDK is saved in git bundle and hosted in Gitlab.

Because the SDK is about 16G ,please download firefly_rk3328_android10.0_git_20211215 first:

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

$md5sum ~/firefly_rk3328_android10.0_git_20211215.7z.001
$md5sum ~/firefly_rk3328_android10.0_git_20211215.7z.002
$md5sum ~/firefly_rk3328_android10.0_git_20211215.7z.003
$md5sum ~/firefly_rk3328_android10.0_git_20211215.7z.004

1e441dffb2d13f82164ad5aa82bc5dab  firefly_rk3328_android10.0_git_20211215.7z.001
676e644f0e6f1883e53cc95531aa4929  firefly_rk3328_android10.0_git_20211215.7z.002
6c8684d46ae6a9941e700168e02896a9  firefly_rk3328_android10.0_git_20211215.7z.003
9fbe55f8fe7523909fceefc87de6021e  firefly_rk3328_android10.0_git_20211215.7z.004

Then extract it:

mkdir -p  ~/proj/firefly_rk3328_android10.0
cd ~/proj/firefly_rk3328_android10.0
7z x ~/firefly_rk3328_android10.0_git_20211215.7z.001 -r -o.
git reset --hard

For first and subsequent SDK update, run the following commands:

#1 Download remote bundle repository
git clone https://gitlab.com/TeeFirefly/rk3328-android10.0-bundle .bundle

#2 If the download warehouse fails, the current bundle warehouse is about 1.4G, so there may be stuck or failed problems during synchronization. You can download and unzip it from the cloud disk link below to the SDK root directory.
7z x rk3328-android10.0-bundle.7z  -r -o. && mv rk3328-android10.0-bundle/ .bundle/

#3 Update the SDK, and subsequent updates do not need to pull the remote warehouse again, just execute the following command
.bundle/update

#4 Follow the prompts to update the content to FETCH_HEAD, synchronize FETCH_HEAD to the firefly branch
git rebase FETCH_HEAD

Compiling with Firefly Scripts

32-bit full compilation

./FFTools/make.sh -d roc-rk3328-pc -j8 -l roc_rk3328_pc_32-userdebug
./FFTools/mkupdate/mkupdate.sh -l roc_rk3328_pc_32-userdebug

After executing the above command, it will compile the U-Boot, kernel and upper layer of Android, sort out the partition Image and generate unified firmware update.img, and put 64-bit firmware in the directory of rockdev/Image-roc_rk3328_pc/,and put 32-bit firmware in the directory of rockdev/Image-roc_rk3328_pc_32/

Modular compilation

The default is 32-bit compilation. For 64 bit compilation, add -l roc_rk3328_pc-userdebug in the end

Compiling Kernel

./FFTools/make.sh -b -j8

Compiling U-Boot

./FFTools/make.sh -u -j8

Compiling Android

./FFTools/make.sh -a -j8

Compiling all Image

This will compile kernel, U-Boot and Android with a single command:

./FFTools/make.sh -j8

Compiling Without Script

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

make ARCH=arm64 firefly_defconfig android-10.config
make ARCH=arm64 -j8 BOOT_IMG=../rockdev/Image-roc_rk3328_pc_32/boot.img roc-rk3328-pc.img

Compiling U-Boot

./make.sh rk3328

Compiling Android

source build/envsetup.sh
lunch roc_rk3328_pc_32-userdebug
make installclean
make -j8
./mkimage.sh

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/mkupdate.sh -l roc_rk3328_pc_32-userdebug

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

The RK firmware needs to use the SD_Firmware_Tool tool and the function mode to select SD Startup to create the boot card

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-rk3328_roc_pc_box/ 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.

Some Introduction about Compiling

Android 10.0 can’t be written directly kernel.img and resource.img

Android 10.0 kernel.img and resource.img Included in boot.img After the kernel is updated and compiled, it needs to be executed in the Android root directory mkimage.sh Repackage boot.img .After packing, download boot.img in rockdev directory .You can compile the kernel separately by using the following instruction.

Compiling kernel generation separately boot.img

Principle of compilation: in the kernel directory, the generated kernel.img And resource.img Replace with old boot.img So you need to use boot when compiling IMG = XXX parameter specification boot.img The command is as follows:

cd kernel
make ARCH=arm64 firefly_defconfig android-10.config
make ARCH=arm64 BOOT_IMG=../rockdev/Image-roc_rk3328_pc_32/boot.img roc-rk3328-pc.img -j24

After compiling, you can directly download the boot.img To the machine.

Partition image

  • boot.img include ramdis、kernel、dtb

  • dtbo.img Device Tree Overlays

  • kernel.img Currently, it cannot be burned separately, it needs to be packaged into boot.img to burn and write

  • MiniLoaderAll.bin include first loader

  • misc.img include recovery-wipe boot flag information ,enter recovery after download

  • odm.img include android odm,included in super.img partition ,upgrade alone by the fastboot tool

  • parameter.txt include partition information

  • pcba_small_misc.img include pcba boot flag information,enter the simple pcba mode after upgrade

  • pcba_whole_misc.img include pcba boot flag information,enter the full pcba mode after upgrade

  • recovery.img include recovery-ramdis、kernel、dtb

  • resource.img include dtb,kernel and uboot phases log and the uboot charging logo,it should be packed into boot.img,then upgrade it

  • system.img include android system,included in super.img partition ,upgrade alone by the fastboot tool

  • trust.img include BL31、BL32

  • uboot.img include uboot.img

  • vbmeta.img include avb,for AVB verify

  • vendor.img include android vendor,included in super.img partition ,upgrade alone by the fastboot tool

  • update.img include all the img file above,use tools to upgrade the whole firmware package

Flash Image

Reference: 《Flash Image》

Other Android versions

Note:The following SDKs can be used, but mainly maintain Android 10.0

《android_compile_android7》

《android_compile_android8》