forked from gcwnow/ingenic-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ingenic-boot
executable file
·115 lines (97 loc) · 1.98 KB
/
ingenic-boot
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
export TOPPATH=$(cd "$(dirname "$0")"; pwd)
export LD_LIBRARY_PATH=$TOPPATH/lib
README="$TOPPATH/README"
ARGS=`getopt -a -o h -l probe,config:,mbr:,boot:,system:,data:,check,help -- "$@"`
[ $? -ne 0 ] && cat "$README" && exit
#set -- "${ARGS}"
eval set -- "${ARGS}"
exit="yes"
while true
do
case "$1" in
--probe)
probe="yes"
exit="no"
;;
--config)
config="$2"
exit="no"
;;
--mbr)
mbr="$2@0x00000000"
exit="no"
;;
--boot)
boot="$2@0x00000200"
exit="no"
;;
--system)
system="$2@0x00004000"
exit="no"
;;
--data)
data="$2@0x19000000"
exit="no"
;;
--check)
check="yes"
exit="no"
;;
-h|--help)
exit="no"
cat "$README" && exit
;;
--)
shift
break
;;
esac
shift
done
[ "$exit" == "yes" ] && cat "$README" && exit
if [ "$probe" == "yes" ]; then
echo "probe only"
$TOPPATH/bin/basic_cmd_tool probe
exit
fi
if [ -z "$config" ]; then
configfile=$(readlink fw/current.cfg)
config=${configfile%.cfg}
fi
echo "Using board configuration: ${config}"
if [ "$check" == "yes" ]; then
[ -n "$mbr" ] && mbr="$mbr#1"
[ -n "$boot" ] && boot="$boot#1"
[ -n "$system" ] && system="$system#1"
[ -n "$data" ] && data="$data#1"
else
[ -n "$mbr" ] && mbr="$mbr#0"
[ -n "$boot" ] && boot="$boot#0"
[ -n "$system" ] && system="$system#0"
[ -n "$data" ] && data="$data#0"
fi
$TOPPATH/tool/patch_fw.sh ${config} || exit
$TOPPATH/tool/down_fw.sh ${config} || exit
echo
$TOPPATH/bin/stage2_cmd_tool config="$TOPPATH/fw/hand-${config}.bin" || exit
$TOPPATH/bin/stage2_cmd_tool sdinit || exit
if [ -n "$mbr" ]; then
echo
$TOPPATH/bin/stage2_cmd_tool sdif="$mbr" || exit
fi
if [ -n "$boot" ]; then
echo
$TOPPATH/bin/stage2_cmd_tool sdif="$boot" || exit
fi
if [ -n "$system" ]; then
echo
$TOPPATH/bin/stage2_cmd_tool sdif="$system" || exit
fi
if [ -n "$data" ]; then
echo
$TOPPATH/bin/stage2_cmd_tool sdif="$data" || exit
fi
$TOPPATH/bin/stage2_cmd_tool reboot || exit
echo
echo "Done."