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