3. Compile Android12.0 firmware

3.1. Download Android12.0 SDK

SDK source code and bundle compression package are stored in the Google Drive.

3.1.1. Download Android SDK

  • The SDK can be obtained by email. Send the order number to sales@t-firefly.com and indicate the required SDK name firefly_rk3588_android12.0_git_20220311

  • After downloading, verify the MD5 code:

     $ md5sum /path/to/firefly_rk3588_android12.0_git_20220311.7z.001
     $ md5sum /path/to/firefly_rk3588_android12.0_git_20220311.7z.002
     $ md5sum /path/to/firefly_rk3588_android12.0_git_20220311.7z.003
     $ md5sum /path/to/firefly_rk3588_android12.0_git_20220311.7z.004
     $ md5sum /path/to/firefly_rk3588_android12.0_git_20220311.7z.005
     $ md5sum /path/to/firefly_rk3588_android12.0_git_20220311.7z.006
    
     8f48ca82f247426d0a7111b851d65f0f  firefly_rk3588_android12.0_git_20220311.7z.001
     e99d68485860b86c2ec5b67aeda7249d  firefly_rk3588_android12.0_git_20220311.7z.002
     cb45fc9e39848b459398467c08acd6f1  firefly_rk3588_android12.0_git_20220311.7z.003
     7774a64cc73dbf4381c100ad1d703fa9  firefly_rk3588_android12.0_git_20220311.7z.004
     cd53c8c752a5162a0638da1cf9a0ed8f  firefly_rk3588_android12.0_git_20220311.7z.005
     fd7744c8098791a8f1dd62527fcac32c  firefly_rk3588_android12.0_git_20220311.7z.006
    
  • After confirming that it is correct, we can unzip:

     cd ~/proj/
     7z x ./firefly_rk3588_android12.0_git_20220311.7z.001 -oRK3588_Android12.0
     cd ./RK3588_Android12.0
     git reset --hard
    

    Attention: To avoid unnecessary errors, please do not unzip the SDK in shared folders, mounted folders or non-english directories.

3.1.1.1. Second, Update SDK

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/RK3588_Android12.0

2. Download remote bundle repository
git clone https://gitlab.com/T-Firefly/rk3588-android12.0-bundle.git .bundle

3. If the download warehouse fails, it may be stuck or failed problems during synchronization. 
we can download and unzip it from the cloud disk link below to the SDK root directory.

7z x rk3588-android12.0-bundle.7z  -r -o. && mv rk3588-android12.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

Google Driver Android12.0 Bundle

3.2. ROC-RK3588S-PC product compilation method

3.2.1. The overall compilation

3.2.1.1. HDMI Firmware Compilation

./FFTools/make.sh -d roc-rk3588s-pc -j8 -l roc_rk3588s_pc-userdebug
./FFTools/mkupdate/mkupdate.sh -l roc_rk3588s_pc-userdebug

3.2.1.2. 10.1‘ MIPI DSI0 Firmware Compilation:

./FFTools/make.sh -d roc-rk3588s-pc-mipi101-M101014-BE45-A1 -j8 -l roc_rk3588s_pc_mipi-userdebug
./FFTools/mkupdate/mkupdate.sh -l roc_rk3588s_pc_mipi-userdebug

3.2.2. Step by step to compile

  • Compile the kernel:

cd ~/path/to/sdk/kernel-5.10
export PATH=../prebuilts/clang/host/linux-x86/clang-r416183b/bin:$PATH
alias msk='make CROSS_COMPILE=aarch64-linux-gnu- LLVM=1 LLVM_IAS=1'
msk ARCH=arm64  firefly_defconfig android-11.config pcie_wifi.config
msk ARCH=arm64   BOOT_IMG=../rockdev/Image-roc_rk3588s_pc/boot.img roc-rk3588s-pc.img -j8
  • Compile uboot:

cd ~/path/to/sdk/u-boot/
./make.sh rk3588
  • Compile Android:

cd ~/path/to/sdk/
source build/envsetup.sh
lunch roc_rk3588s_pc-userdebug
make installclean
make -j8
./mkimage.sh

3.2.3. Packaged into unified firmware update.img

After compilation, you can use Firefly official scripts to package into unified firmware, execute the following command:

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

After packaging, it will be in rockdev/Image-XXX/ Generate unified firmware under the directory: (product name )XXX_XXX_date XXX.img

It is also very simple to package the unified firmware update.img under Windows. Copy the generated files to the rockdev \ Image directory of AndroidTool, and then run the mkupdate.bat batch file under the rockdev directory to create up date.img and store it in rockdev \ Image directory.

3.3. OTA Compilation

3.3.1. Firefly full OTA compilation and upgrade

3.3.1.1. Add the -o parameter for OTA full compilation

./FFTools/make.sh -d roc-rk3588s-pc -j8 -l roc_rk3588s_pc-userdebug -o

3.3.1.2. Generate the full package path

out/target/product/roc_rk3588s_pc/roc_rk3588s_pc-ota-eng.xxx.zip 

3.3.1.3. Generate the base material package path

out/target/product/roc_rk3588s_pc/obj/PACKAGING/target_files_intermediates/roc_rk3588s_pc-target_files-eng.xxx.zip

Copy the base material package and rename it, mainly for subcontracting upgrades.

cp out/target/product/roc_rk3588s_pc/obj/PACKAGING/target_files_intermediates/roc_rk3588s_pc-target_files-eng.xxx.zip ~/ota/v1.zip 

3.3.1.4. Package compiled firmware and upgrades

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

In the rockdev/Image-roc_rk3588s_pc/ directory, find the corresponding firmware and burn it to the machine, then the machine can carry out the full package upgrade and the difference package upgrade,put ‘update.zip’ into /sdcard/ and restart the full package as prompted.

3.3.2. Generate the incremental OTA package

3.3.2.1. Generate a new base material package

The v1.zip basic material package has been made, and another v2.zip material package needs to be made to generate the difference package. You need to modify the kernel DTS code or Android code, and then run the command again.

./FFTools/make.sh -d roc-rk3588s-pc -j8 -l roc_rk3588s_pc-userdebug -o

Regenerate a new base material package that we can copy.

 cp out/target/product/roc_rk3588s_pc/obj/PACKAGING/target_files_intermediates/roc_rk3588s_pc-target_files-eng.xxx.zip  ~/ota/v2.zip

3.3.2.2. Generate the incremental OTA package command

out/host/linux-x86/bin/ota_from_target_files --block -v -i ~/ota/v1.zip -p out/host/linux-x86/ -k build/target/product/security/testkey ~/ota/v2.zip update.zip

3.3.2.3. Upgrade OTA incremental OTA package

Put update.zip to the machine sdcard directory reboot, it will automatically recognize, and then click the steps to complete the upgrade.

3.3.3. OTA server setup

Refer to OTA Documentation to setup the sever.