-
Notifications
You must be signed in to change notification settings - Fork 0
/
mk_ubi_image
executable file
·84 lines (71 loc) · 2.19 KB
/
mk_ubi_image
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
SCRIPTDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source $SCRIPTDIR/chip_nand_scripts_common
require ubinize "Please install mtd-utils"
require img2simg "Please install fastboot-utils"
# build the UBI image
prepare_ubi() {
local ubi="$1"
local ubifs="$2"
local ubicfg="$3"
local nandtype="$4"
local maxlebcount="$5"
local eraseblocksize="$6"
local pagesize="$7"
local subpagesize="$8"
local sparseubi="${ubi}.sparse"
local mlcopts=""
if [ -z $subpagesize ]; then
subpagesize=$pagesize
fi
if [ "$nandtype" = "mlc" ]; then
lebsize=$((eraseblocksize/2-$pagesize*2))
mlcopts="-M dist3"
elif [ $subpagesize -lt $pagesize ]; then
lebsize=$((eraseblocksize-pagesize))
else
lebsize=$((eraseblocksize-pagesize*2))
fi
echo "WARNING: not applying MLC fixed nand size work around..."
echo ubinize -o $ubi -p $eraseblocksize -m $pagesize -s $subpagesize $mlcopts $ubicfg
ubinize -o $ubi -p $eraseblocksize -m $pagesize -s $subpagesize $mlcopts $ubicfg
img2simg $ubi $sparseubi $eraseblocksize
}
usage() {
echo -e "\n\
usage: $(basename $0) [options] INPUTFILE\n\
\n
options:\n\
-N FILENAME - read nand configuration from FILENAME\n\
-c FILENAME - read ubinize configuration from FILENAME\n\
-d OUTPUTDIR - write file to OUTPUTDIR (default: .)\n\
-o OUTPUTFILE - write to OUTPUTFILE (default: $outputdir/chip-$NAND_EBSIZE-$NAND_PSIZE.ubi)n\
-h, --help - show this help\n\
\n"
exit 1
}
while getopts ":N:d:o:c:" o; do
case "${o}" in
N)
read_nand_config "${OPTARG}"
;;
o)
outputfile=${OPTARG}
;;
d)
outputdir=${OPTARG}
;;
c)
ubinize_cfg=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
ubinize_cfg="${ubinize_cfg:?ERROR: no ubinize configuration specified}"
outputdir="${outputdir:-.}"
outputfile="${outputfile:-$outputdir/chip-$NAND_EBSIZE-$NAND_PSIZE.ubi}"
inputfile="$1"
prepare_ubi "${outputfile}" "${inputfile}" "${ubinize_cfg}" $NAND_TYPE $NAND_MAXLEB_COUNT $NAND_ERASE_BLOCK_SIZE $NAND_PAGE_SIZE $NAND_SUBPAGE_SIZE