4. Compile Android10.0

4.1. Download Android SDK

Due to the larger SDK, you can choose the cloud disk to download Firefly-RK3399_Android10.0_git_20211222.7z from the download page :

Download link

Note: the source code and bundle are stored in the Google Driver

After downloading, verify the MD5 code:

$ md5sum /path/to/Firefly-RK3399_Android10.0_git_20211222.7z.001
$ md5sum /path/to/Firefly-RK3399_Android10.0_git_20211222.7z.002
$ md5sum /path/to/Firefly-RK3399_Android10.0_git_20211222.7z.003
$ md5sum /path/to/Firefly-RK3399_Android10.0_git_20211222.7z.004
$ md5sum /path/to/Firefly-RK3399_Android10.0_git_20211222.7z.005

fb41fcdc48b1cf90ecac4a5bb8fafc7a  Firefly-RK3399_Android10.0_git_20211222.7z.001
82d665fb54fb41245d9317312e7b7578  Firefly-RK3399_Android10.0_git_20211222.7z.002
0dd40827976200a6fb61623c9e87fe7c  Firefly-RK3399_Android10.0_git_20211222.7z.003
32324c3afe615394ee4cdf842c53ea8d  Firefly-RK3399_Android10.0_git_20211222.7z.004
9b1656ae07b4fe9ddf7d9ef2dfa2f95a  Firefly-RK3399_Android10.0_git_20211222.7z.005

After confirming that it is correct, you can unzip:

cd ~/proj/
7z x ./Firefly-RK3399_Android10.0_git_20211222.7z.001 -ork3399_Android10.0
cd ./rk3399_Android10.0
git reset --hard

Note: Be sure to update the remote warehouse after decompression. The following is how to update from gitlab:

1. Enter the SDK root directory
cd ~/proj/rk3399_Android10.0

2. Download remote bundle repository
git clone https://gitlab.com/TeeFirefly/rk3399-android10.0-bundle.git .bundle

3. 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 rk3399-android10.0-bundle.7z  -r -o. && mv rk3399-android10.0-bundle/ .bundle/

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

5. Follow the prompts to update the content to FETCH_HEAD, synchronize FETCH_HEAD to the firefly branch
git rebase FETCH_HEAD

4.2. AIO-3399J product compilation method

4.2.1. Overall Compilation

4.2.1.1. Public Compile

4.2.1.1.1. HDMI
./FFTools/make.sh -j24 -d rk3399-firefly-aio -l rk3399_firefly_aio-userdebug
./FFTools/mkupdate/mkupdate.sh -l rk3399_firefly_aio-userdebug

4.2.1.2. Display DM-M10R800 Compile

4.2.1.2.1. LVDS+HDMI
./FFTools/make.sh  -d rk3399-firefly-aio-lvds-HSX101H40C -j8 -l rk3399_firefly_aio_lvds-userdebug
./FFTools/mkupdate/mkupdate.sh -l rk3399_firefly_aio_lvds-userdebug

4.2.1.3. Dual Camera SV-TAYSH-TQ Compile

4.2.1.3.1. HDMI+SV-TAYSH-TQ

note:
The camera only supports aio-3399j Standard Edition and does not support HDMI_In version

  • Modify kernel/arch/arm64/boot/dts/rockchip/rk3399-firefly-aio.dtsi

    xc7160b@1b{
+    status = "disabled";
    };
    xc7160f@1b{
+    status = "disabled";
    };

    XC6130b@23{
+    status = "okay";
    };
    XC7022b@1b{
+    status = "okay";
    };
  • Compile

./FFTools/make.sh -j24 -d rk3399-firefly-aio -l rk3399_firefly_aio-userdebug
./FFTools/mkupdate/mkupdate.sh -l rk3399_firefly_aio-userdebug

4.2.2. Compile step by step AIO-3399J

Before compiling, execute the following command to configure environment variables:

source ./FFTools/build.sh
  • Compile kernel:

cd ~/proj/rk3399_Android10.0/kernel/
make ARCH=arm64 firefly_defconfig android-10.config rk3399.config
make ARCH=arm64 BOOT_IMG=../rockdev/Image-rk3399_firefly_aio/boot.img rk3399-firefly-aio.img -j8
  • Note:If you going to do kernel debug,you need pack the resource.img and kernel.img together into boot.img,then upgrade the boot,img into boot partition.

  • Compile uboot:

cd ~/proj/rk3399_Android10.0/u-boot/
./make.sh rk3399
  • Compile Android:

cd ~/proj/rk3399_Android10.0/
lunch rk3399_firefly_aio-userdebug
make -j8
./mkimage.sh

4.3. Package into a unified firmware

After compiling, execute the following command first, then use Firefly official script to package into a unified SD card firmware, execute the following command:

./FFTools/mkupdate/mkupdate.sh -l rk3399_firefly_aio-userdebug

According to different -l XXX-userdebug parameters, the packaged unified firmware will be stored in different directories (rockdev/image-XXX/): product name XXX_XXX_date XXX.img

Packing the unified firmware update.img under Windows is also very simple. Copy the compiled files to the rockdev/Image directory of AndroidTool, and then run the mkupdate.bat batch file under the rockdev directory. Create update.img and store it in the rockdev/Image directory.

4.4. Some Introduction about Compiling

4.4.1. 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.

4.4.2. 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-rk3399_firefly_aio/boot.img rk3399-firefly-aio.img -j24

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

4.5. 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 afte v

  • 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

  • super.img include odm、vendor、system partition content

  • 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 包含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

4.6. Flash Image

Reference: 《Flash Image》