1. 增加部分OTA功能。2. 增加部分fitboot功能
This commit is contained in:
parent
ee97f7cf5f
commit
f0821f52b1
Binary file not shown.
|
@ -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__);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
__BEGIN_CDECLS
|
||||
|
||||
#define DISABLE_DEBUG_OUTPUT 1
|
||||
#if !DISABLE_DEBUG_OUTPUT
|
||||
#define printf(x...) _printf(x)
|
||||
#else
|
||||
|
|
|
@ -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"
|
Loading…
Reference in New Issue