4. 编译 Android14.0 固件

4.1. 下载 Android14.0 SDK

SDK 源码与 bundle 压缩包均存放在云盘中。如有需要请联系商务 : sales@t-firefly.com

4.1.1. 下载 SDK

  • SDK通过邮件的方式获取,把订单号发送到sales@t-firefly.com邮箱并注明需要的SDK名称firefly_rk3588_android14_git_20240822

  • 下载完成后,在解压前先校验下 MD5 码:

    $ md5sum /path/to/firefly_rk3588_android14_git_240822.7z.001
    $ md5sum /path/to/firefly_rk3588_android14_git_240822.7z.002
    $ md5sum /path/to/firefly_rk3588_android14_git_240822.7z.003
    $ md5sum /path/to/firefly_rk3588_android14_git_240822.7z.004
    $ md5sum /path/to/firefly_rk3588_android14_git_240822.7z.005
    $ md5sum /path/to/firefly_rk3588_android14_git_240822.7z.006
    $ md5sum /path/to/firefly_rk3588_android14_git_240822.7z.007
    $ md5sum /path/to/firefly_rk3588_android14_git_240822.7z.008
    $ md5sum /path/to/firefly_rk3588_android14_git_240822.7z.009
    $ md5sum /path/to/firefly_rk3588_android14_git_240822.7z.010
    $ md5sum /path/to/firefly_rk3588_android14_git_240822.7z.011
    
    c9cc4863a3ad3b48f3c74d1f061d0438  firefly_rk3588_android14_git_240822.7z.001
    e81083e1b9b435e4e666f7d08dcd1bd6  firefly_rk3588_android14_git_240822.7z.002
    49b7aace84ab01b9a014b410fa26f42f  firefly_rk3588_android14_git_240822.7z.003
    1632fc98d881d5f4a8ed953afc9c73b1  firefly_rk3588_android14_git_240822.7z.004
    f581633cefdef6103de584501612e5dd  firefly_rk3588_android14_git_240822.7z.005
    f0e591f54a8969755775642567dabb17  firefly_rk3588_android14_git_240822.7z.006
    ee3d00d688ac0ad2bb43f8fe73f354bd  firefly_rk3588_android14_git_240822.7z.007
    09dc458646cce9f53a792d68e0ece3ec  firefly_rk3588_android14_git_240822.7z.008
    add00c4da466d50782ea5dba279c72d1  firefly_rk3588_android14_git_240822.7z.009
    51438ba104f0a67fd4fa09b5fee0d301  firefly_rk3588_android14_git_240822.7z.010
    b733f1d13c070862b5af6ce71052c020  firefly_rk3588_android14_git_240822.7z.011
    
  • 然后解压:

    cd ~/proj/
    7z x ./firefly_rk3588_android14.0_git_20240822.7z.001 -oRK3588_Android14.0
    cd ./RK3588_Android14.0
    git reset --hard
    

注意:不要在共享文件夹、挂载文件夹以及非英文目录解压SDK,避免产生不必要的错误

4.2. iCore-3588MQ 产品编译方法

4.2.1. 整体编译

4.2.1.1. HDMI 固件编译

./FFTools/make.sh -d rk3588-firefly-aio-3588q -j8 -l rk3588_firefly_aio_3588q-userdebug
./FFTools/mkupdate/mkupdate.sh -l rk3588_firefly_aio_3588q-userdebug

4.2.1.2. 显示屏 DM-M10R800 V2 固件编译:

./FFTools/make.sh -d rk3588-firefly-aio-3588q-mipi101-M101014-BE45-A1 -j8 -l rk3588_firefly_aio_3588q_mipi-userdebug
./FFTools/mkupdate/mkupdate.sh -l rk3588_firefly_aio_3588q_mipi-userdebug

4.2.1.3. edp 显示屏 NV156FHM-T06 固件编译:

./FFTools/make.sh -d rk3588-firefly-aio-3588q-edp-NV156FHM-T06 -j8 -l rk3588_firefly_aio_3588q_edp-userdebug
./FFTools/mkupdate/mkupdate.sh -l rk3588_firefly_aio_3588q_edp-userdebug

4.2.1.4. 双目摄像头 CAM-2MS2MF 编译

4.2.1.4.1. HDMI+CAM-2MS2MF
  • 修改 dts

--- a/kernel-6.1/arch/arm64/boot/dts/rockchip/rk3588-firefly-aio-3588q.dts
+++ b/kernel-6.1/arch/arm64/boot/dts/rockchip/rk3588-firefly-aio-3588q.dts
@@ -7,8 +7,8 @@
 #include "rk3588-firefly-aio-3588q.dtsi"
-#include "rk3588-firefly-aio-cam-8ms1m.dtsi"
-//#include "rk3588-firefly-aio-cam-2ms2mf.dtsi"
+//#include "rk3588-firefly-aio-cam-8ms1m.dtsi"
+#include "rk3588-firefly-aio-cam-2ms2mf.dtsi"
 #include "rk3588-firefly-demo.dtsi"

4.2.1.5. 双目摄像头 CAM-2MS2MF 编译:

  • 编译

./FFTools/make.sh -d rk3588-firefly-aio-3588q -j8 -l rk3588_firefly_aio_3588q-userdebug
./FFTools/mkupdate/mkupdate.sh -l rk3588_firefly_aio_3588q-userdebug

4.2.1.6. HDMI TO MIPI_CSI(RK628D) 编译

  • 修改 dts

--- a/kernel-6.1/arch/arm64/boot/dts/rockchip/rk3588-firefly-aio-3588q.dts
+++ b/kernel-6.1/arch/arm64/boot/dts/rockchip/rk3588-firefly-aio-3588q.dts
@@ -7,9 +7,9 @@
 /dts-v1/;
 
 #include "rk3588-firefly-aio-3588q.dtsi"
-#include "rk3588-firefly-aio-cam-8ms1m.dtsi"
+//#include "rk3588-firefly-aio-cam-8ms1m.dtsi"
 //#include "rk3588-firefly-aio-cam-2ms2mf.dtsi"
-//#include "rk3588-firefly-aio-3588q-tf-hdmi-mipi-rk628.dtsi"
+#include "rk3588-firefly-aio-3588q-tf-hdmi-mipi-rk628.dtsi"
 #include "rk3588-firefly-demo.dtsi"
  • 编译

./FFTools/make.sh -d rk3588-firefly-aio-3588q -j8 -l rk3588_firefly_aio_3588q-userdebug
./FFTools/mkupdate/mkupdate.sh -l rk3588_firefly_aio_3588q-userdebug

4.2.2. 分步编译

  • 编译 kernel:

cd ~/proj/RK3588_Android14.0/kernel-6.1
export PATH=../prebuilts/clang/host/linux-x86/clang-r487747c/bin:$PATH
alias msk='make CROSS_COMPILE=aarch64-linux-gnu- LLVM=1 LLVM_IAS=1'
msk ARCH=arm64  firefly_defconfig android-14.config pcie_wifi.config
msk ARCH=arm64   BOOT_IMG=../rockdev/Image-rk3588_firefly_aio_3588q/boot.img rk3588-firefly-aio-3588q.img -j8
  • 编译 uboot:

cd ~/proj/RK3588_Android14.0/u-boot/
./make.sh rk3588
  • 编译 Android:

cd ~/proj/RK3588_Android14.0/
source build/envsetup.sh
lunch rk3588_firefly_aio_3588q-userdebug
make installclean
make -j8
./mkimage.sh

4.2.3. 打包成统一固件 update.img

编译完可以用Firefly官方的脚本打包成统一固件,执行如下命令:

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

打包完成后将在rockdev/Image-rk3588_firefly_aio_3588q/ 目录下生成统一固件: product名XXX_XXX_日期XXX.img

在 Windows 下打包统一固件 update.img 也很简单,将编译生成的文件拷贝到 AndroidTool 的 rockdev\Image 目录中,然后运行 rockdev 目录下的 mkupdate.bat 批处理文件即可创建 update.img 并存放到 rockdev\Image 目录里。

4.3. 其他编译说明

4.3.1. Android14.0 不能直接烧写 kernel.img 和 resource.img

Android14.0的kernel.imgresource.img包含在boot.img中,编译kernel后需要在android根目录下执行./mkimage.sh重新打包boot.img,然后烧写rockdev/Image-rk3588_firefly_aio_3588q/目录下的boot.img

4.3.2. 单独编译kernel生成boot.img

编译的原理:在kernel目录下将编译生成的 kernel.imgresource.img 替换到旧的 boot.img 中, 所以编译的时候需要用 BOOT_IMG=xxx 参数指定boot.img的路径,命令如下:

cd ~/proj/RK3588_Android14.0/kernel-6.1
export PATH=../prebuilts/clang/host/linux-x86/clang-r487747c/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-rk3588_firefly_aio_3588q/boot.img rk3588-firefly-aio-3588q.img -j8

编译后可以直接烧写kernel目录下的boot.img

4.4. 分区镜像

编译的时候执行 ./mkimage.sh 会重新打包 boot.imgsuper.img, 并将其它相关的镜像文件拷贝到目录 rockdev/Image-rk3588_firefly_aio_3588q/ 中。以下列出一般固件用到的镜像文件:

固件 说明
boot.img 包含ramdis、kernel、dtb
dtbo.img Device Tree Overlays
MiniLoaderAll.bin 包含一级loader
misc.img 包含recovery-wipe开机标识信息,烧写后会进行recovery
parameter.txt 包含分区信息
recovery.img 包含recovery-ramdis、kernel、dtb
super.img 包含odm、product、vendor、system、system_ext分区内容
uboot.img 包含uboot固件
vbmeta.img 包含avb校验信息,用于AVB校验
update.img 包含以上需要烧写的img文件,可以用于工具直接烧写整个固件包

请参照 《使用USB线缆升级固件》 一文来烧写分区镜像文件。

4.5. OTA 编译

请参照《OTA编译》章节

4.6. 常见问题

4.6.1. git clone 远程 bundle 仓库失败

Q:更新SDK时,git clone 远程 bundle 仓库出错:

$ git clone https://gitlab.com/T-Firefly/rk3588-Android14.0-bundle.git .bundle
Cloning into '.bundle'...
remote: Enumerating objects: 20, done.
remote: Counting objects: 100% (20/20), done.
remote: Compressing objects: 100% (18/18), done.
error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with unexpected length was received.
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: unpack-objects failed

A:缓冲区大小不够,需要扩大缓冲区:

git config --global https.postBuffer 1048576000