#!/bin/bash
####将所有数据更新为生产上用作烧录器使用的程序
####Usage:
#####cat /proc/mtd
####dev: size erasesize name
####mtd0: 000c0000 00020000 "cfe"
####mtd1: 000e0000 00020000 "splash"
####mtd2: 00800000 00020000 "kernel_fs"
####mtd3: 01400000 00020000 "loader"
####mtd4: 02c00000 00020000 "jwtdata"
####mtd5: 01000000 00020000 "otherdata"
####mtd6: 02100000 00020000 "bakdata"
####mtd7: 00060000 00020000 "stbinfo"
####mtd8: 00060000 00020000 "nvram"
####mtd9: 00060000 00020000 "macadr"
####mtd10: 00100000 00020000 "thirdsw"
####mtd11: 00340000 00020000 "reserved"
targetprj=kv_7581b0_update
targetdir=new_kv_update/kv_7581b0_update
if [ -e ${targetprj} ];then
echo -e "targetdir: ${targetdir}"
else
echo "Please copy the Target Dir(Like kv_update) to Here!"
exit
fi
rm -fr ${targetdir}
echo -e "Create target dir OK!\n"
mkdir -p ${targetdir}
ls -l ${targetprj} | awk '{print $5,$9}' > file_len
echo "131082 stbinfo" >> file_len
cat file_len
del_str="kv_ ubifs-"
replace_str=""
while read -a a;do
echo "--- line $((++n)) ---"
for ((i = 0; i < ${#a[@]}; i++)); do
echo "a[$i]=${a[i]}"
done
for i in ${del_str}
do
a[1]="${a[1]//$i/${replace_str}}"
done
simple_name=`echo "${a[1]}" | cut -b 0-3`
echo "${simple_name}"
mtdstr=`cat /proc/mtd | grep ${simple_name} | awk -F\: '{print $1}'`
echo "mtdstr:$mtdstr"
cat /proc/mtd | grep ${a[1]} | awk '{print $1}'
nanddump2 -q -l ${a[0]} -f ${targetdir}/burn_${a[1]} /dev/${mtdstr}
done < file_len