From f0821f52b1311f6d146a0893274607cccfe9b35f Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Sun, 10 Jul 2022 00:26:37 -0700 Subject: [PATCH] =?UTF-8?q?1.=20=E5=A2=9E=E5=8A=A0=E9=83=A8=E5=88=86OTA?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E3=80=822.=20=E5=A2=9E=E5=8A=A0=E9=83=A8?= =?UTF-8?q?=E5=88=86fitboot=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flashtool/flashtool/burn.pyo | Bin 0 -> 8058 bytes src/bsp/lk/app/fitboot/fitboot.c | 47 +----- src/bsp/lk/include/printf.h | 1 + tool/build_otazip.sh | 141 ++++++++++++++++++ 4 files changed, 145 insertions(+), 44 deletions(-) create mode 100644 meta/meta-mediatek/recipes-devtools/flashtool/flashtool/burn.pyo create mode 100755 tool/build_otazip.sh diff --git a/meta/meta-mediatek/recipes-devtools/flashtool/flashtool/burn.pyo b/meta/meta-mediatek/recipes-devtools/flashtool/flashtool/burn.pyo new file mode 100644 index 0000000000000000000000000000000000000000..625f64520c7557fab680e3a89352452430db519f GIT binary patch literal 8058 zcmcIp&2tn*R}ga3_hOJMJfkAKoIG5#17h;>#uLvLrE)^p4vN7RLt?Oa zSZr2yM&u2c8`1u#_D98v?2O6IxR`#fuS|#;5IZ8z3*!D=OtI6C|3mDsm=kgfdqtaK z2D=ltJu@VBlndf9k3_>tv=?{=N9lw+?-?AG5(P>$)+LHgiy7~3md;J2r$CA)hIy>Cc z9j2u+%^ils^E`|Frlp5wPHDoQ%ck#yu=xA-6g>u$MsDd5fTD;rn<8Al9NQP}Nmc)l@!J)x7e0 zk&I5N*56f_S&+(gfpYA15>;*}%jy(RH?d0T#a{D#E;oVO<={$1YO z@8Azx^@8j{ipG6d?G0IYHYF9nzE2*Shq8mqeaWLAF7Ew(eobM#_q%*FC1w#gyUu+c zq3Lm>VC1&M|C#TI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* zNqzs9N72N77PIgCV&^PYp3=WBys6B%_YL}dZ#aUThBM@IKzA8I62kIp47^TyCo%(= zFJ=caQ`vDOljI;v>Oq{q+i|}ka8UGyv*c(@$9b<$Gk(wfaE4TQ H$|CcBeo0oc literal 0 HcmV?d00001 diff --git a/src/bsp/lk/app/fitboot/fitboot.c b/src/bsp/lk/app/fitboot/fitboot.c index 7cfc25478..dab2a52d9 100755 --- a/src/bsp/lk/app/fitboot/fitboot.c +++ b/src/bsp/lk/app/fitboot/fitboot.c @@ -72,12 +72,11 @@ struct boot_flag unsigned int usea; unsigned int useb; unsigned int current; - unsigned int secver; }; extern int errno; -u32 set_currently_boot_flag(int last_flag, u32 current_flag, u32 def_ver,const char *part_name) +u32 set_currently_boot_flag(int last_flag, u32 current_flag, const char *part_name) { int ret = 0; long len = 0; @@ -107,9 +106,6 @@ u32 set_currently_boot_flag(int last_flag, u32 current_flag, u32 def_ver,const c set_flag.current = current_flag; set_flag.usea = -1; set_flag.useb = -1; - if(def_ver>0){ - set_flag.secver = def_ver; - } memset(buf, 0, writesize); memcpy(buf, (void*)&set_flag, sizeof(boot_flag)); @@ -122,7 +118,7 @@ u32 set_currently_boot_flag(int last_flag, u32 current_flag, u32 def_ver,const c ret = -1; goto err; } - dprintf(CRITICAL, "set flag: lastboot = %d, use A = %d, use B = %d, current = %d secver = %d\n", set_flag.lastboot, set_flag.usea, set_flag.useb, set_flag.current,set_flag.secver); + dprintf(CRITICAL, "set flag: lastboot = %d, use A = %d, use B = %d, current = %d\n", set_flag.lastboot, set_flag.usea, set_flag.useb, set_flag.current); if (buf) { free(buf); buf = NULL; @@ -136,47 +132,11 @@ err: return ret; } -u32 updata_secver(boot_flag set_flag) -{ - int ret = 0; - long len = 0; - u32 writesize = 2048; - int index = -1; - unsigned long long ptn = 0; - unsigned long long size = 0; - char *buf; - buf = malloc(writesize); - memset(buf, 0, writesize); - memcpy(buf, (void*)&set_flag, sizeof(boot_flag)); - /* read partition */ - struct bdev *nand_MISC = bio_open_by_label("MISC"); - /* write buf to offset 0, which size is 2048 */ - len = bio_write(nand_MISC, (char*)buf, 0, (u32)writesize); - if (len <= 0) { - dprintf(CRITICAL, "nand write fail, return : %d, error: \n",len, strerror(errno)); - dprintf(CRITICAL, "buf: %s\n", buf); - ret = -1; - goto err; - } - dprintf(CRITICAL, "update set flag: lastboot = %d, use A = %d, use B = %d, current = %d secver = %d\n", set_flag.lastboot, set_flag.usea, set_flag.useb, set_flag.current,set_flag.secver); - if (buf) { - free(buf); - buf = NULL; - } - return 0; -err: - if (buf) { - free(buf); - buf = NULL; - } - return ret; -} u32 check_boot_partition(const char *part_name) { int ret = 0; boot_flag flag; u32 boot = 0; - u32 defver = 0; struct bdev *nand_MISC = bio_open_by_label("MISC"); int len = -1; @@ -226,13 +186,12 @@ u32 check_boot_partition(const char *part_name) } else { dprintf(CRITICAL, "boot flag is not match, use default boot partition\n"); boot = 0; - defver = 101001; } if ((flag.current != boot) || (flag.usea == UPG_SUCCEED) || (flag.useb == UPG_SUCCEED)) { ret = bio_erase(nand_MISC, 0, 0x20000); //erase one block printf("bio erase ret %d\n", ret); - ret = set_currently_boot_flag(flag.lastboot, boot,defver , part_name); + ret = set_currently_boot_flag(flag.lastboot, boot, part_name); if(ret!=0) dprintf(CRITICAL, "set flags fail. LINE: %d\n", __LINE__); } diff --git a/src/bsp/lk/include/printf.h b/src/bsp/lk/include/printf.h index 367d3a03d..bae918cdb 100644 --- a/src/bsp/lk/include/printf.h +++ b/src/bsp/lk/include/printf.h @@ -29,6 +29,7 @@ __BEGIN_CDECLS +#define DISABLE_DEBUG_OUTPUT 1 #if !DISABLE_DEBUG_OUTPUT #define printf(x...) _printf(x) #else diff --git a/tool/build_otazip.sh b/tool/build_otazip.sh new file mode 100755 index 000000000..b03191481 --- /dev/null +++ b/tool/build_otazip.sh @@ -0,0 +1,141 @@ +#!/bin/bash + +set -e + +dir=`pwd` +version=$1 +filepath=$2 +PROJECT_NAME=$3 +PROJECT_BIZID=$4 + +if [ $# -lt 2 ] +then + echo "please ./mkzip.sh version filepath" + exit -1 +fi + +if [ ! -f $filepath ] +then + echo "not found $filepath" + exit -1 +fi + +rm -rf ./output/ota +mkdir -p ./output/ota +mkdir -p ./output/ota/updatezip/image +mkdir -p ./output/ota/updatezip/split + +dir=$dir/output/ota + +unzip $filepath -d ./output/ota/updatezip/image +filepath_tz="$dir/updatezip/image/tz.img" +filepath_boot="$dir/updatezip/image/boot.img" +filepath_rootfs="$dir/updatezip/image/rootfs.ubi" + +if [ ! -f "$filepath_tz" ] +then + echo "not found $filepath_tz" + exit -1 +fi +if [ ! -f "$filepath_boot" ] +then + echo "not found $filepath_boot" + exit -1 +fi +if [ ! -f "$filepath_rootfs" ] +then + echo "not found $filepath_rootfs" + exit -1 +fi + +cd $dir +rm -rf files +mkdir files +echo version=$version >> $dir/files/info + +split -b 1M -d $filepath_tz $dir/updatezip/split/tz.img_ +split -b 1M -d $filepath_boot $dir/updatezip/split/boot.img_ +split -b 1M -d $filepath_rootfs $dir/updatezip/split/rootfs.ubi_ + + +cd $dir +files_tz=`ls $dir/updatezip/split/tz.img_*` +files_boot=`ls $dir/updatezip/split/boot.img_*` +files_rootfs=`ls $dir/updatezip/split/rootfs.ubi_*` + +totalfiles_tz=0 +totalfiles_boot=0 +totalfiles_rootfs=0 + + +for f in $files_tz +do + (( ++totalfiles_tz )) +done + +for f in $files_boot +do + (( ++totalfiles_boot )) +done + +for f in $files_rootfs +do + (( ++totalfiles_rootfs )) +done + +echo "wait for calculate md5..." +cd $dir/updatezip/split/ +for i in $(seq 0 `expr $totalfiles_tz - 1`) +do + if [ $i -lt 10 ];then + fileindex=0$i + else + fileindex=$i + fi + + md5filename=`md5sum tz.img_$fileindex | awk '{ print $1 }'` + md5filename="tz.img-$fileindex-$md5filename" + echo "file=$md5filename" >> $dir/files/info + mv tz.img_$fileindex $dir/files/$md5filename + (( ++i )) +done + +for i in $(seq 0 `expr $totalfiles_boot - 1`) +do + if [ $i -lt 10 ];then + fileindex=0$i + else + fileindex=$i + fi + + md5filename=`md5sum boot.img_$fileindex | awk '{ print $1 }'` + md5filename="boot.img-$fileindex-$md5filename" + echo "file=$md5filename" >> $dir/files/info + mv boot.img_$fileindex $dir/files/$md5filename + (( ++i )) +done + +for i in $(seq 0 `expr $totalfiles_rootfs - 1`) +do + if [ $i -lt 10 ];then + fileindex=0$i + else + fileindex=$i + fi + + md5filename=`md5sum rootfs.ubi_$fileindex | awk '{ print $1 }'` + md5filename="rootfs.ubi-$fileindex-$md5filename" + echo "file=$md5filename" >> $dir/files/info + mv rootfs.ubi_$fileindex $dir/files/$md5filename + (( ++i )) +done + +cd $dir +rm ./updatezip -rf +mv ./files/info . +zip -r "Firmware_"$PROJECT_NAME"_OTA_"$version"_"$PROJECT_BIZID".zip" ./* +rm ./files -rf +rm info +cd ../.. + +echo "work done"