xf.li | aa4d92f | 2023-09-13 00:18:58 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | if [ $# -ne 4 ]; then |
| 4 | echo "$0 error" |
| 5 | echo "Usage:" |
| 6 | echo " $0 mtd_name outfile image_file ubinize_para" |
| 7 | exit -1 |
| 8 | fi |
| 9 | |
| 10 | mtdname=$1 |
| 11 | outfile=$2 |
| 12 | imgfile=$3 |
| 13 | ubinize_para=$4 |
| 14 | |
| 15 | filesize="$(stat -c%s $imgfile)" |
| 16 | |
| 17 | cfg_file_name=$mtdname.cfg |
| 18 | |
| 19 | echo "[$mtdname]" > $cfg_file_name |
| 20 | echo "mode=ubi" >> $cfg_file_name |
| 21 | echo "image=$imgfile" >> $cfg_file_name |
| 22 | echo "vol_id=0" >> $cfg_file_name |
| 23 | echo "vol_size=${filesize}" >> $cfg_file_name |
| 24 | echo "vol_type=dynamic" >> $cfg_file_name |
| 25 | echo "vol_name=$mtdname" >> $cfg_file_name |
| 26 | |
| 27 | cat $cfg_file_name |
| 28 | |
| 29 | ubinize -o $outfile $ubinize_para $cfg_file_name |
| 30 | if [ $? -ne 0 ]; then |
| 31 | echo "ubinize error" |
| 32 | exit -2 |
| 33 | else |
| 34 | echo "ubinize ok" |
| 35 | fi |
| 36 | |
| 37 | rm -v $cfg_file_name |