scripts: fit-unpack: add hash verify
Signed-off-by: Joseph Chen <chenjh@rock-chips.com> Change-Id: I11982ee2e6fb09f5c0007334832d7decb6025756
This commit is contained in:
parent
1f21bf610b
commit
0fb435fa05
|
|
@ -52,10 +52,11 @@ function args_process()
|
||||||
|
|
||||||
function gen_images()
|
function gen_images()
|
||||||
{
|
{
|
||||||
printf "\n## Unpack $file to directory $output/\n"
|
printf "\n# Unpack $file to directory $output/\n"
|
||||||
fdtget -l $file /images > $output/unpack.txt
|
fdtget -l $file /images > $output/unpack.txt
|
||||||
cat $output/unpack.txt | while read line
|
cat $output/unpack.txt | while read line
|
||||||
do
|
do
|
||||||
|
# generate image
|
||||||
node="/images/${line}"
|
node="/images/${line}"
|
||||||
name=`fdtget -ts $file $node image`
|
name=`fdtget -ts $file $node image`
|
||||||
offs=`fdtget -ti $file $node data-position`
|
offs=`fdtget -ti $file $node data-position`
|
||||||
|
|
@ -64,7 +65,6 @@ function gen_images()
|
||||||
continue;
|
continue;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf " %-15s: %d bytes\n" ${name} $size
|
|
||||||
if [ $size -ne 0 ]; then
|
if [ $size -ne 0 ]; then
|
||||||
dd if=$file of=$output/dd.tmp bs=$offs skip=1 >/dev/null 2>&1
|
dd if=$file of=$output/dd.tmp bs=$offs skip=1 >/dev/null 2>&1
|
||||||
dd if=$output/dd.tmp of=$output/$name bs=$size count=1 >/dev/null 2>&1
|
dd if=$output/dd.tmp of=$output/$name bs=$size count=1 >/dev/null 2>&1
|
||||||
|
|
@ -72,6 +72,36 @@ function gen_images()
|
||||||
else
|
else
|
||||||
touch $output/$name
|
touch $output/$name
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# hash verify
|
||||||
|
algo=`fdtget -ts $file $node/hash@1 algo`
|
||||||
|
if [ -z $algo ]; then
|
||||||
|
printf " %-20s: %d bytes" $name $size
|
||||||
|
continue;
|
||||||
|
fi
|
||||||
|
|
||||||
|
data=`fdtget -tx $file $node/hash@1 value`
|
||||||
|
data=`echo " "$data | sed "s/ / 0x/g"`
|
||||||
|
csum=`"$algo"sum $output/$name | awk '{ print $1}'`
|
||||||
|
|
||||||
|
hash=""
|
||||||
|
for((i=1;;i++));
|
||||||
|
do
|
||||||
|
hex=`echo $data | awk -v idx=$i '{ print $idx }'`
|
||||||
|
if [ -z $hex ]; then
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
|
||||||
|
hex=`printf "%08x" $hex` # align !!
|
||||||
|
hash="$hash$hex"
|
||||||
|
done
|
||||||
|
|
||||||
|
printf " %-20s: %d bytes... %s" $name $size $algo
|
||||||
|
if [ "$csum" = "$hash" -o $size -eq 0 ]; then
|
||||||
|
echo "+"
|
||||||
|
else
|
||||||
|
echo "-"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
rm $output/unpack.txt
|
rm $output/unpack.txt
|
||||||
|
|
@ -80,3 +110,4 @@ function gen_images()
|
||||||
|
|
||||||
args_process $*
|
args_process $*
|
||||||
gen_images
|
gen_images
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue