From 4a3f3c14739b9a52dbec31d8d25d71d7a2dea675 Mon Sep 17 00:00:00 2001 From: SnickerSun Date: Wed, 24 Jul 2024 12:13:25 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E6=94=B9mkota=E8=84=9A=E6=9C=AC?= =?utf8?q?=EF=BC=8C=E6=94=AF=E6=8C=81=E7=9B=B4=E6=8E=A5=E7=94=A8=E6=8C=87?= =?utf8?q?=E4=BB=A4=E5=88=B6=E4=BD=9Cota=5Fdiff=20=E7=9A=84ota=E5=8C=85?= =?utf8?q?=E3=80=82=E5=90=8C=E6=97=B6=E4=BF=AE=E6=94=B9ota=E5=8C=85?= =?utf8?q?=E6=96=87=E4=BB=B6=E5=90=8D=E5=89=8D=E7=BC=80=EF=BC=8C=E6=9B=B4?= =?utf8?q?=E7=9B=B4=E7=99=BD=E7=9A=84=E8=A1=A8=E8=BE=BE=E6=B8=85=E6=A5=9A?= =?utf8?q?=E6=9C=AC=E5=8C=85=E7=9A=84=E5=88=B6=E4=BD=9C=E5=8F=82=E6=95=B0?= =?utf8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../brandy/build_brandy_update.py | 6 +- .../brandy/fota/fota_app_diff.cfg | 491 ++++++++++++++++++ mkota.sh | 13 +- 3 files changed, 507 insertions(+), 3 deletions(-) create mode 100644 code/sdk/build/config/target_config/brandy/fota/fota_app_diff.cfg diff --git a/code/sdk/build/config/target_config/brandy/build_brandy_update.py b/code/sdk/build/config/target_config/brandy/build_brandy_update.py index 26c4ccc58..d3bc2f41d 100755 --- a/code/sdk/build/config/target_config/brandy/build_brandy_update.py +++ b/code/sdk/build/config/target_config/brandy/build_brandy_update.py @@ -29,7 +29,11 @@ class upg_base_info: # 升级包结构配置文件 self.fota_format_path = os.path.join(self.root_path, "build", "config", "target_config", "brandy", "fota") # 产品升级配置文件 - self.fota_cfg = os.path.join(self.root_path, "build", "config", "target_config", "brandy", "fota", "fota.cfg") + if os.path.exists(os.path.join(self.root_path,"output","ota_diff")) : + self.fota_cfg = os.path.join(self.root_path, "build", "config", "target_config", "brandy", "fota", "fota_app_diff.cfg") + else: + self.fota_cfg = os.path.join(self.root_path, "build", "config", "target_config", "brandy", "fota", "fota.cfg") + # 产品镜像输出路径 self.output = os.path.join(self.root_path, "output", "brandy","TestOTA") # 产品升级镜像包输出路径 diff --git a/code/sdk/build/config/target_config/brandy/fota/fota_app_diff.cfg b/code/sdk/build/config/target_config/brandy/fota/fota_app_diff.cfg new file mode 100644 index 000000000..7f87fa344 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/fota/fota_app_diff.cfg @@ -0,0 +1,491 @@ +# SignSuite : 签名秘钥类型 + # 0: ECDSA_SHA256 + # 1: ECDSA_SHA256_LEA_CTR + # 2: ECDSA_SHA256_LEA_CBC_MAC + # 3: ECDSA_SHA256_AES_CBC + + # 10: SM2_SM3 + # 11: SM2_SM3_LEA_CTR + # 12: SM2_SM3_LEA_CBC_MAC + # 13: SM2_SM3_SM4_CBC + + # 30: RSA 4096 + # 34: RSA 4096 - SHA256 +[SIGN_CFG] +# 此SignSuite默认为非安全升级的34 +# 若想进行安全升级需改为30,并将下方[FOTA_KEY_AREA]中KeyAlg的值修改为0x2A13C845 +SignSuite=34 +UpgImagePath = +UpgSignedImagePath = +RootKeyFile=build/config/target_config/brandy/signature/rsa_4096.pem +SubKeyFile=build/config/target_config/brandy/signature/rsa_4096.pem + +[TOOLS] +UpgToolPath=tools/bin/sign_tool/sign_tool_pltuni +LzmaToolPath=tools/bin/lzma_tool/lzma_tool +UpgToolWinPath=tools\bin\sign_tool\sign_tool_pltuni.exe +LzmaToolWinPath=tools\bin\lzma_tool\lzma_tool.exe + +# Default Single sign mode. If there are 'RootKeyFileExt' & 'SubKeyFileExt' then means Double Sign mode. +# RootKeyFileExt= +# SubKeyFileExt= +[FOTA_KEY_AREA] +ImageId=0xCB8D154E +StructVersion=0x00010000 +KeyOwnerId=0 +KeyId=0 + +# KeyAlg :Algorithm of the external public key: + # 0x2A13C812: ECC256_SHA256 + # 0x2A13C823: SM2_SM3 + # 0x2A13C845: RSA4096_SHA256 + # 0x2A13C856: SHA256(ECC256 FORMAT) + # 0x2A13C867: SHA256(RSA4096) + # 0x2A13C878: SM3_ONLY + # Others: Invalid +KeyAlg=0x2A13C867 + +KeyVersion=0x00000000 +KeyVersionMask=0x00000000 +Msid=0x00000000 +MsidMask=0x00000000 + +[FOTA_INFO_AREA] +ImageId=0xCB8D154E +StructVersion=0x00010000 +Version=0x00000000 +VersionMask=0x00000000 +Msid=0x00000000 +MsidMask=0x00000000 +HardwareID=0 + +[ssb_sign] +HeaderMagic=0x464F5451 +ImageId=0x4B1E3C1E + +# DecompressFlag :升级镜像模式标记 + # 0x3C7896E1 - compressed image + # 0x44494646 - diff image + # other :原始镜像不处理 +DecompressFlag=0x44494646 + +# ReRncFlag:升级镜像加密标记 + # 0x3C7896E1:加密 + # other:不加密 +ReRncFlag=0x0 + +# RootKeyType : 用于加密图像的根密钥,在ReEncFlag启用时有效 + # 0 - ODRK0, for TEE runtime FW image. + # 1 - ODRK1, for Protocol and REE Application image. +RootKeyType=0x0 + +# 用于解密更新映像的1级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL1= + +# 用于解密更新映像的2级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL2= + +version_ext=0x00000000 +version_mask=0x00000000 + +[ssb] +HeaderMagic=0x464F5451 +ImageId=0x4B1E3C2D + +# DecompressFlag :升级镜像模式标记 + # 0x3C7896E1 - compressed image + # 0x44494646 - diff image + # other :原始镜像不处理 +DecompressFlag=0 + +# ReRncFlag:升级镜像加密标记 + # 0x3C7896E1:加密 + # other:不加密 +ReRncFlag=0x0 + +# RootKeyType : 用于加密图像的根密钥,在ReEncFlag启用时有效 + # 0 - ODRK0, for TEE runtime FW image. + # 1 - ODRK1, for Protocol and REE Application image. +RootKeyType=0x0 + +# 用于解密更新映像的1级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL1= + +# 用于解密更新映像的2级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL2= + +version_ext=0x00000000 +version_mask=0x00000000 + +[nv] +HeaderMagic=0x464F5451 +ImageId=0xCB9E063C + +# DecompressFlag :升级镜像模式标记 + # 0 :原始镜像不处理 (nv只能使用该值) +DecompressFlag=0 + +# ReRncFlag:升级镜像加密标记 + # 0x3C7896E1:加密 + # other:不加密 +ReRncFlag=0x0 + +# RootKeyType : 用于加密图像的根密钥,在ReEncFlag启用时有效 + # 0 - ODRK0, for TEE runtime FW image. + # 1 - ODRK1, for Protocol and REE Application image. +RootKeyType=0x0 + +# 用于解密更新映像的1级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL1= + +# 用于解密更新映像的2级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL2= + +version_ext=0x00000000 +version_mask=0x00000000 + +[recovery_sign] +HeaderMagic=0x464F5451 +ImageId=0x4B69871E + +# DecompressFlag :升级镜像模式标记 + # 0x3C7896E1 - compressed image + # 0x44494646 - diff image + # other :原始镜像不处理 +DecompressFlag=0x44494646 + +# ReRncFlag:升级镜像加密标记 + # 0x3C7896E1:加密 + # other:不加密 +ReRncFlag=0x0 + +# RootKeyType : 用于加密图像的根密钥,在ReEncFlag启用时有效 + # 0 - ODRK0, for TEE runtime FW image. + # 1 - ODRK1, for Protocol and REE Application image. +RootKeyType=0x0 + +# 用于解密更新映像的1级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL1= + +# 用于解密更新映像的2级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL2= + +version_ext=0x00000000 +version_mask=0x00000000 + +[recovery] +HeaderMagic=0x464F5451 +ImageId=0x4B69872D + +# DecompressFlag :升级镜像模式标记 + # 0x3C7896E1 - compressed image + # 0x44494646 - diff image + # other :原始镜像不处理 +DecompressFlag=0x3C7896E1 + +# ReRncFlag:升级镜像加密标记 + # 0x3C7896E1:加密 + # other:不加密 +ReRncFlag=0x0 + +# RootKeyType : 用于加密图像的根密钥,在ReEncFlag启用时有效 + # 0 - ODRK0, for TEE runtime FW image. + # 1 - ODRK1, for Protocol and REE Application image. +RootKeyType=0x0 + +# 用于解密更新映像的1级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL1= + +# 用于解密更新映像的2级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL2= + +version_ext=0x00000000 +version_mask=0x00000000 + +[application_sign] +HeaderMagic=0x464F5451 +ImageId=0x4B0F2D1E + +# DecompressFlag :升级镜像模式标记 + # 0x3C7896E1 - compressed image + # 0x44494646 - diff image + # other :原始镜像不处理 +DecompressFlag=0x44494646 + +# ReRncFlag:升级镜像加密标记 + # 0x3C7896E1:加密 + # other:不加密 +ReRncFlag=0x0 + +# RootKeyType : 用于加密图像的根密钥,在ReEncFlag启用时有效 + # 0 - ODRK0, for TEE runtime FW image. + # 1 - ODRK1, for Protocol and REE Application image. +RootKeyType=0x0 + +# 用于解密更新映像的1级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL1= + +# 用于解密更新映像的2级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL2= + +version_ext=0x00000000 +version_mask=0x00000000 + +[application] +HeaderMagic=0x464F5451 +ImageId=0x4B0F2D2D + +# DecompressFlag :升级镜像模式标记 + # 0x3C7896E1 - compressed image + # 0x44494646 - diff image + # other :原始镜像不处理 +DecompressFlag=0x44494646 + +# ReRncFlag:升级镜像加密标记 + # 0x3C7896E1:加密 + # other:不加密 +ReRncFlag=0x0 + +# RootKeyType : 用于加密图像的根密钥,在ReEncFlag启用时有效 + # 0 - ODRK0, for TEE runtime FW image. + # 1 - ODRK1, for Protocol and REE Application image. +RootKeyType=0x0 + +# 用于解密更新映像的1级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL1= + +# 用于解密更新映像的2级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL2= + +version_ext=0x00000000 +version_mask=0x00000000 + +[bt_sign] +HeaderMagic=0x464F5451 +ImageId=0x4BF01E1E + +# DecompressFlag :升级镜像模式标记 + # 0x3C7896E1 - compressed image + # 0x44494646 - diff image + # other :原始镜像不处理 +DecompressFlag=0x44494646 + +# ReRncFlag:升级镜像加密标记 + # 0x3C7896E1:加密 + # other:不加密 +ReRncFlag=0x0 + +# RootKeyType : 用于加密图像的根密钥,在ReEncFlag启用时有效 + # 0 - ODRK0, for TEE runtime FW image. + # 1 - ODRK1, for Protocol and REE Application image. +RootKeyType=0x0 + +# 用于解密更新映像的1级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL1= + +# 用于解密更新映像的2级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL2= + +version_ext=0x00000000 +version_mask=0x00000000 + +[bt] +HeaderMagic=0x464F5451 +ImageId=0x4BF01E2D + +# DecompressFlag :升级镜像模式标记 + # 0x3C7896E1 - compressed image + # 0x44494646 - diff image + # other :原始镜像不处理 +DecompressFlag=0x3C7896E1 + +# ReRncFlag:升级镜像加密标记 + # 0x3C7896E1:加密 + # other:不加密 +ReRncFlag=0x0 + +# RootKeyType : 用于加密图像的根密钥,在ReEncFlag启用时有效 + # 0 - ODRK0, for TEE runtime FW image. + # 1 - ODRK1, for Protocol and REE Application image. +RootKeyType=0x0 + +# 用于解密更新映像的1级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL1= + +# 用于解密更新映像的2级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL2= + +version_ext=0x00000000 +version_mask=0x00000000 + +[dsp_main_sign] +HeaderMagic=0x464F5451 +ImageId=0x5A87A51E + +# DecompressFlag :升级镜像模式标记 + # 0x3C7896E1 - compressed image + # 0x44494646 - diff image + # other :原始镜像不处理 +DecompressFlag=0x44494646 + +# ReRncFlag:升级镜像加密标记 + # 0x3C7896E1:加密 + # other:不加密 +ReRncFlag=0x0 + +# RootKeyType : 用于加密图像的根密钥,在ReEncFlag启用时有效 + # 0 - ODRK0, for TEE runtime FW image. + # 1 - ODRK1, for Protocol and REE Application image. +RootKeyType=0x0 + +# 用于解密更新映像的1级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL1= + +# 用于解密更新映像的2级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL2= + +version_ext=0x00000000 +version_mask=0x00000000 + +[dsp_main] +HeaderMagic=0x464F5451 +ImageId=0x5A87A52D + +# DecompressFlag :升级镜像模式标记 + # 0x3C7896E1 - compressed image + # 0x44494646 - diff image + # other :原始镜像不处理 +DecompressFlag=0x3C7896E1 + +# ReRncFlag:升级镜像加密标记 + # 0x3C7896E1:加密 + # other:不加密 +ReRncFlag=0x0 + +# RootKeyType : 用于加密图像的根密钥,在ReEncFlag启用时有效 + # 0 - ODRK0, for TEE runtime FW image. + # 1 - ODRK1, for Protocol and REE Application image. +RootKeyType=0x0 + +# 用于解密更新映像的1级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL1= + +# 用于解密更新映像的2级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL2= + +version_ext=0x00000000 +version_mask=0x00000000 + +[dsp_overlay_sign] +HeaderMagic=0x464F5451 +ImageId=0x5A87A53A + +# DecompressFlag :升级镜像模式标记 + # 0x3C7896E1 - compressed image + # 0x44494646 - diff image + # other :原始镜像不处理 +DecompressFlag=0x44494646 + +# ReRncFlag:升级镜像加密标记 + # 0x3C7896E1:加密 + # other:不加密 +ReRncFlag=0x0 + +# RootKeyType : 用于加密图像的根密钥,在ReEncFlag启用时有效 + # 0 - ODRK0, for TEE runtime FW image. + # 1 - ODRK1, for Protocol and REE Application image. +RootKeyType=0x0 + +# 用于解密更新映像的1级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL1= + +# 用于解密更新映像的2级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL2= + +version_ext=0x00000000 +version_mask=0x00000000 + +[dsp_overlay] +HeaderMagic=0x464F5451 +ImageId=0x5A87A54B + +# DecompressFlag :升级镜像模式标记 + # 0x3C7896E1 - compressed image + # 0x44494646 - diff image + # other :原始镜像不处理 +DecompressFlag=0x3C7896E1 + +# ReRncFlag:升级镜像加密标记 + # 0x3C7896E1:加密 + # other:不加密 +ReRncFlag=0x0 + +# RootKeyType : 用于加密图像的根密钥,在ReEncFlag启用时有效 + # 0 - ODRK0, for TEE runtime FW image. + # 1 - ODRK1, for Protocol and REE Application image. +RootKeyType=0x0 + +# 用于解密更新映像的1级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL1= + +# 用于解密更新映像的2级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL2= + +version_ext=0x00000000 +version_mask=0x00000000 + +[res_index] +HeaderMagic=0x464F5451 +ImageId=0xCB9E0826 + +# DecompressFlag :升级镜像模式标记 + # 0x3C7896E1 - compressed image + # other :原始镜像不处理 +DecompressFlag=0 + +# ReRncFlag:升级镜像加密标记 + # 0x3C7896E1:加密 + # other:不加密 +ReRncFlag=0x0 + +# RootKeyType : 用于加密图像的根密钥,在ReEncFlag启用时有效 + # 0 - ODRK0, for TEE runtime FW image. + # 1 - ODRK1, for Protocol and REE Application image. +RootKeyType=0x0 + +# 用于解密更新映像的1级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL1= + +# 用于解密更新映像的2级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL2= + +version_ext=0x00000000 +version_mask=0x00000000 + +[res_data] +HeaderMagic=0x464F5451 +ImageId=0xCB9E0832 + +# DecompressFlag :升级镜像模式标记 + # 0x3C7896E1 - compressed image + # other :原始镜像不处理 +DecompressFlag=0 + +# ReRncFlag:升级镜像加密标记 + # 0x3C7896E1:加密 + # other:不加密 +ReRncFlag=0x0 + +# RootKeyType : 用于加密图像的根密钥,在ReEncFlag启用时有效 + # 0 - ODRK0, for TEE runtime FW image. + # 1 - ODRK1, for Protocol and REE Application image. +RootKeyType=0x0 + +# 用于解密更新映像的1级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL1= + +# 用于解密更新映像的2级加密保护密钥,在ReEncFlag启用时有效 +ProtectionKeyL2= + +version_ext=0x00000000 +version_mask=0x00000000 \ No newline at end of file diff --git a/mkota.sh b/mkota.sh index f1068ca4c..728dd0e80 100755 --- a/mkota.sh +++ b/mkota.sh @@ -10,6 +10,7 @@ ROOTDIR=`basename $PWD` ADDITIONAL_RES_DIR=$PWD/code/sdk/output/additional_fs OTA_ALL_FLAG_PATH=$PWD/code/sdk/output/ota_all RES_ONLY_FLAG_PATH=$PWD/code/sdk/output/res_only +OTA_DIFF_FLAG_PATH=$PWD/code/sdk/output/ota_diff if [ ! -d "$SOURCE_DIR" ] ; then echo "$SOURCE_DIR not exist , skip create ota package" echo "" @@ -21,11 +22,18 @@ echo "" exit 0 fi -rm $OTA_ALL_FLAG_PATH $RES_ONLY_FLAG_PATH -f +rm $OTA_ALL_FLAG_PATH $RES_ONLY_FLAG_PATH $OTA_DIFF_FLAG_PATH -f if [ "$3" == "ota_all" ]; then touch $OTA_ALL_FLAG_PATH +OTA_PKG_HEAD=ota_all_ +elif [ "$3" == "ota_diff" ]; then +touch $OTA_DIFF_FLAG_PATH +OTA_PKG_HEAD=ota_diff_ elif [ "$3" == "res_only" ]; then touch $RES_ONLY_FLAG_PATH +OTA_PKG_HEAD=res_only_ +else +OTA_PKG_HEAD=ota_ fi @@ -74,7 +82,8 @@ cd $PWD/code/sdk/ cd - mkdir release/ota -p -target_fwpkg_filepath=release/ota/${SOURCE_VERSION}_2_${TARGET_VERSION}_ota.fwpkg + +target_fwpkg_filepath=release/ota/${OTA_PKG_HEAD}${SOURCE_VERSION}_2_${TARGET_VERSION}.fwpkg cp code/sdk/output/brandy/TestOTA/upgrade/update.fwpkg $target_fwpkg_filepath fwpkg_filesize=`ls $target_fwpkg_filepath -lh|awk '{print $5}'` -- 2.17.1