lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | if [ x"$PAGESIZE" = x"" ]; then |
| 4 | PAGESIZE=0x800 |
| 5 | fi |
| 6 | |
| 7 | if [ x"$ERASEBLOCK" = x"" ]; then |
| 8 | ERASEBLOCK=0x20000 |
| 9 | fi |
| 10 | |
| 11 | cfg_file_name=$1.cfg |
| 12 | img_file_name=$1.imgbak |
| 13 | vol_size=$[$2*942-512] |
| 14 | |
| 15 | rm -fv $img_file_name $cfg_file_name |
| 16 | |
| 17 | echo "[ubifs]" > $cfg_file_name |
| 18 | echo "mode=ubi" >> $cfg_file_name |
| 19 | echo "image=${img_file_name}" >> $cfg_file_name |
| 20 | echo "vol_id=0" >> $cfg_file_name |
| 21 | echo "vol_size=${vol_size}KiB" >> $cfg_file_name |
| 22 | echo "vol_type=dynamic" >> $cfg_file_name |
| 23 | echo "vol_name=${1}" >> $cfg_file_name |
| 24 | echo "vol_flags=autoresize" >> $cfg_file_name |
| 25 | |
| 26 | mkfs.ubifs -r $3 -m $PAGESIZE -e $[$ERASEBLOCK - $PAGESIZE] -c $[$2*8 -1] -x zlib -o $img_file_name |
| 27 | if [ $? -ne 0 ]; then |
| 28 | echo "mkfs.ubifs error" |
| 29 | exit -1 |
| 30 | else |
| 31 | echo "mkfs.ubifs ok" |
| 32 | fi |
| 33 | |
| 34 | ubinize -o $4 -m $PAGESIZE -p $ERASEBLOCK -s 512 $cfg_file_name |
| 35 | if [ $? -ne 0 ]; then |
| 36 | echo "ubinize error" |
| 37 | exit -2 |
| 38 | else |
| 39 | echo "ubinize ok" |
| 40 | fi |
| 41 | |
| 42 | rm -fv $img_file_name $cfg_file_name |
| 43 | |
| 44 | exit 0 |