forked from dsixda/Android-Kitchen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_yaffs_sizes
More file actions
executable file
·89 lines (68 loc) · 2.02 KB
/
check_yaffs_sizes
File metadata and controls
executable file
·89 lines (68 loc) · 2.02 KB
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
85
86
87
############################################################################
#
# Copyright (c) 2011 - dsixda ([email protected])
#
# Android Kitchen is 100% free. This script file is intended for personal
# and/or educational use only. It may not be duplicated for monetary
# benefit or any other purpose without the permission of the developer.
#
############################################################################
#
# This script has two optional parameters:
#
# $1 = folder where the image is located
# $2 = image name (e.g. data.img or system.img) - required if $1 defined
#
# If not specified, then script assumes system.img in working folder
#
base_dir=`pwd`
if [ "$1" == "" ]
then
cd WORKING_*
if [ ! -e system/system.img ]
then
echo "Error: system.img not found in working folder"
cd ..
exit 1
fi
cd system
image_file=system.img
else
if [ "$2" == "" ]
then
echo "Error: Image file not specified"
exit 1
fi
cd $1
image_file=$2
fi
#
# Check for chunk size and then calculate spare size
#
hex_chunk=`od -x -A x $image_file | grep -m 1 "1000 [ ]*0000 [ ]*0001 [ ]*0000 [ ]*0000 [ ]*0000 [ ]*ffff [ ]*0000" | sed -e 's/ .*//'`
cd $base_dir
if [ "$hex_chunk" != "" ]
then
dec_chunk=`printf "%d" 0x$hex_chunk`
echo "Chunk size is $dec_chunk bytes in $image_file"
# Spare size
dec_spare=$(($dec_chunk/32))
echo "Spare size calculated to be $dec_spare bytes"
str=`sed '20q;d' tools/unyaffs_files/unyaffs.c`
if [ "$str" != "#define CHUNK_SIZE $dec_chunk" ]
then
echo "Setting chunk size = $dec_chunk in unyaffs.c, line 20"
sed -i -e '20s/.*/#define CHUNK_SIZE '$dec_chunk'/' tools/unyaffs_files/unyaffs.c
fi
str=`sed '21q;d' tools/unyaffs_files/unyaffs.c`
if [ "$str" != "#define SPARE_SIZE $dec_spare" ]
then
echo "Setting spare size = $dec_spare in unyaffs.c, line 21"
sed -i -e '21s/.*/#define SPARE_SIZE '$dec_spare'/' tools/unyaffs_files/unyaffs.c
fi
exit 0
else
echo "Error: Cannot detect chunk size in $image_file"
cd ../..
exit 1
fi