#!/bin/sh

if [ $# -ne 1 ]; then
	echo "Usage: $0 <root-dir>"
	echo "params: $#"
	echo
	exit 1
fi

if [ ! -d $1 ];then
	echo "Usage: $0 <root-dir>"
	echo 
	exit 1
fi

filename=ubi.img


mkfs.ubifs -r $1 -m 2048  -e  124KiB -c 8107 -F -o ubifs.img
if [ $? -ne 0 ];then
	echo "mkfs.ubifs failed!!"
	exit 1
fi


ubinize -m 2048 -p 128KiB -e 8107 -s 2048 -O 2048 -o  $filename  ubinize_1GB.cfg
if [ $? -ne 0 ];then
	echo "ubinize failed!!"
	exit 1
fi


echo -e "\033[0;33;1m Filesystem were output to $filename \033[0m"
