diff options
Diffstat (limited to 'meta/packages/zaurus-updater/tosa/updater.sh')
-rw-r--r-- | meta/packages/zaurus-updater/tosa/updater.sh | 241 |
1 files changed, 0 insertions, 241 deletions
diff --git a/meta/packages/zaurus-updater/tosa/updater.sh b/meta/packages/zaurus-updater/tosa/updater.sh deleted file mode 100644 index 6d30aba231..0000000000 --- a/meta/packages/zaurus-updater/tosa/updater.sh +++ /dev/null | |||
@@ -1,241 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | |||
4 | DATAPATH=$1 | ||
5 | TMPPATH=/tmp/update | ||
6 | TMPDATA=$TMPPATH/tmpdata.bin | ||
7 | TMPHEAD=$TMPPATH/tmphead.bin | ||
8 | |||
9 | |||
10 | RO_MTD_LINE=`cat /proc/mtd | grep "root" | tail -n 1` | ||
11 | if [ "$RO_MTD_LINE" = "" ]; then | ||
12 | RO_MTD_LINE=`cat /proc/mtd | grep "\<NAND\>.*\<2\>" | tail -n 1` | ||
13 | fi | ||
14 | RO_MTD_NO=`echo $RO_MTD_LINE | cut -d: -f1 | cut -dd -f2` | ||
15 | RO_MTD_SIZE_HEX=`echo $RO_MTD_LINE | cut -d" " -f2` | ||
16 | RO_MTD=/dev/mtd$RO_MTD_NO | ||
17 | RO_MTDBLK=/dev/mtdblock$RO_MTD_NO | ||
18 | RO_MTD_SIZE=`dc 0x$RO_MTD_SIZE_HEX 1024 /` | ||
19 | |||
20 | RW_MTD_LINE=`cat /proc/mtd | grep "home" | tail -n 1` | ||
21 | if [ "$RW_MTD_LINE" = "" ]; then | ||
22 | RW_MTD_LINE=`cat /proc/mtd | grep "\<NAND\>.*\<2\>" | tail -n 1` | ||
23 | fi | ||
24 | RW_MTD_NO=`echo $RW_MTD_LINE | cut -d: -f1 | cut -dd -f2` | ||
25 | RW_MTD_SIZE_HEX=`echo $RW_MTD_LINE | cut -d" " -f2` | ||
26 | RW_MTD=/dev/mtd$RW_MTD_NO | ||
27 | RW_MTDBLK=/dev/mtdblock$RW_MTD_NO | ||
28 | RW_MTD_SIZE=`dc 0x$RW_MTD_SIZE_HEX 1024 /` | ||
29 | |||
30 | LOGOCAL_MTD=/dev/mtd1 | ||
31 | |||
32 | VERBLOCK=0x48000 | ||
33 | MVRBLOCK=0x70000 | ||
34 | |||
35 | RESULT=0 | ||
36 | |||
37 | Cleanup(){ | ||
38 | rm -f $VTMPNAME > /dev/null 2>&1 | ||
39 | rm -f $MTMPNAME > /dev/null 2>&1 | ||
40 | rm $CTRLPATH/* > /dev/null 2>&1 | ||
41 | rm $DATAPATH/* > /dev/null 2>&1 | ||
42 | exit $1 | ||
43 | } | ||
44 | trap 'Cleanup 1' 1 15 | ||
45 | trap '' 2 3 | ||
46 | |||
47 | |||
48 | ### Check model ### | ||
49 | /sbin/writerominfo | ||
50 | MODEL=`cat /proc/deviceinfo/product` | ||
51 | if [ "$MODEL" != "SL-6000" ] > /dev/null 2>&1 | ||
52 | then | ||
53 | echo 'MODEL:'$MODEL | ||
54 | echo 'ERROR:Invalid model!' | ||
55 | echo 'Please reset' | ||
56 | while true | ||
57 | do | ||
58 | done | ||
59 | fi | ||
60 | |||
61 | mkdir -p $TMPPATH > /dev/null 2>&1 | ||
62 | |||
63 | cd $DATAPATH/ | ||
64 | |||
65 | if [ -e consolescroll ] | ||
66 | then | ||
67 | ./consolescroll | ||
68 | fi | ||
69 | |||
70 | for TARGETFILE in zImage zImage.bin zimage.bin ZIMAGE ZIMAGE.BIN initrd.bin INITRD.BIN mversion.bin MVERSION.BIN | ||
71 | do | ||
72 | if [ -e $TARGETFILE ] | ||
73 | then | ||
74 | rm -f $TMPPATH/*.bin > /dev/null 2>&1 | ||
75 | DATASIZE=`wc -c $TARGETFILE` | ||
76 | DATASIZE=`echo $DATASIZE | cut -d' ' -f1` | ||
77 | |||
78 | #echo $TARGETFILE':'$DATASIZE'bytes' | ||
79 | TARGETTYPE=Invalid | ||
80 | case "$TARGETFILE" in | ||
81 | zImage) TARGETTYPE=Kernel;; | ||
82 | zimage.bin) TARGETTYPE=Kernel;; | ||
83 | ZIMAGE) TARGETTYPE=Kernel;; | ||
84 | initrd.bin) TARGETTYPE=RoFs;; | ||
85 | INITRD.BIN) TARGETTYPE=RoFs;; | ||
86 | mversion.bin) TARGETTYPE=MasterVer;; | ||
87 | MVERSION.BIN) TARGETTYPE=MasterVer;; | ||
88 | *) | ||
89 | continue | ||
90 | ;; | ||
91 | esac | ||
92 | case "$TARGETTYPE" in | ||
93 | Kernel) | ||
94 | echo 'kernel' | ||
95 | ISLOGICAL=1 | ||
96 | MODULEID=5 | ||
97 | MODULESIZE=0x13C000 | ||
98 | ADDR=`dc 0xE0000` | ||
99 | ISFORMATTED=1 | ||
100 | DATAPOS=0 | ||
101 | ONESIZE=524288 | ||
102 | HDTOP=`expr $DATASIZE - 16` | ||
103 | /sbin/bcut -a $HDTOP -s 16 -o $TMPHEAD $TARGETFILE | ||
104 | ;; | ||
105 | RoFs) | ||
106 | echo 'RO file system' | ||
107 | ISLOGICAL=0 | ||
108 | MODULEID=6 | ||
109 | MODULESIZE=0x1E00000 | ||
110 | ADDR=0 | ||
111 | ISFORMATTED=0 | ||
112 | TARGET_MTD=$RO_MTD | ||
113 | DATAPOS=16 | ||
114 | ONESIZE=1048576 | ||
115 | /sbin/bcut -s 16 -o $TMPHEAD $TARGETFILE | ||
116 | ;; | ||
117 | MasterVer) | ||
118 | echo 'Maser version' | ||
119 | MTMPNAME=$TMPPATH'/mtmp'`date '+%s'`'.tmp' | ||
120 | /sbin/nandlogical $LOGOCAL_MTD READ $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1 | ||
121 | /sbin/verchg -m $MTMPNAME $TARGETFILE 0 0 > /dev/null 2>&1 | ||
122 | /sbin/nandlogical $LOGOCAL_MTD WRITE $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1 | ||
123 | rm -f $MTMPNAME > /dev/null 2>&1 | ||
124 | echo 'Success!' | ||
125 | continue | ||
126 | ;; | ||
127 | *) | ||
128 | continue; | ||
129 | ;; | ||
130 | esac | ||
131 | |||
132 | #check version | ||
133 | /sbin/bcut -s 6 -o $TMPDATA $TMPHEAD | ||
134 | if [ `cat $TMPDATA` != "SHARP!" ] > /dev/null 2>&1 | ||
135 | then | ||
136 | #no version info... | ||
137 | rm -f $TMPHEAD > /dev/null 2>&1 | ||
138 | DATAPOS=0 | ||
139 | fi | ||
140 | |||
141 | #format? | ||
142 | if [ $ISFORMATTED = 0 ] | ||
143 | then | ||
144 | echo -n 'Flash erasing...' | ||
145 | /sbin/eraseall $TARGET_MTD 2> /dev/null > /dev/null | ||
146 | #/sbin/eraseall $TARGET_MTD 2 | ||
147 | echo 'done' | ||
148 | ISFORMATTED=1 | ||
149 | fi | ||
150 | |||
151 | echo '' | ||
152 | echo '0% 100%' | ||
153 | PROGSTEP=`expr $DATASIZE / $ONESIZE + 1` | ||
154 | PROGSTEP=`expr 28 / $PROGSTEP` | ||
155 | if [ $PROGSTEP = 0 ] | ||
156 | then | ||
157 | PROGSTEP=1 | ||
158 | fi | ||
159 | |||
160 | #header information | ||
161 | if [ -e $TMPHEAD ] | ||
162 | then | ||
163 | VTMPNAME=$TMPPATH'/vtmp'`date '+%s'`'.tmp' | ||
164 | MTMPNAME=$TMPPATH'/mtmp'`date '+%s'`'.tmp' | ||
165 | /sbin/nandlogical $LOGOCAL_MTD READ $VERBLOCK 0x4000 $VTMPNAME > /dev/null 2>&1 | ||
166 | /sbin/nandlogical $LOGOCAL_MTD READ $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1 | ||
167 | |||
168 | #echo 'found header' | ||
169 | /sbin/verchg -v $VTMPNAME $TMPHEAD $MODULEID $MODULESIZE > /dev/null 2>&1 | ||
170 | /sbin/verchg -m $MTMPNAME $TMPHEAD $MODULEID $MODULESIZE > /dev/null 2>&1 | ||
171 | fi | ||
172 | |||
173 | #loop | ||
174 | while [ $DATAPOS -lt $DATASIZE ] | ||
175 | do | ||
176 | #data create | ||
177 | bcut -a $DATAPOS -s $ONESIZE -o $TMPDATA $TARGETFILE | ||
178 | TMPSIZE=`wc -c $TMPDATA` | ||
179 | TMPSIZE=`echo $TMPSIZE | cut -d' ' -f1` | ||
180 | DATAPOS=`expr $DATAPOS + $TMPSIZE` | ||
181 | |||
182 | #handle data file | ||
183 | #echo 'ADDR='$ADDR | ||
184 | #echo 'SIZE='$TMPSIZE | ||
185 | if [ $ISLOGICAL = 0 ] | ||
186 | then | ||
187 | next_addr=`/sbin/nandcp -a $ADDR $TMPDATA $TARGET_MTD 2>/dev/null | fgrep "mtd address" | cut -d- -f2 | cut -d\( -f1` | ||
188 | if [ "$next_addr" = "" ]; then | ||
189 | echo "ERROR:flash write" | ||
190 | rm $TMPDATA > /dev/null 2>&1 | ||
191 | RESULT=3 | ||
192 | break; | ||
193 | fi | ||
194 | ADDR=$next_addr | ||
195 | else | ||
196 | /sbin/nandlogical $LOGOCAL_MTD WRITE $ADDR $DATASIZE $TMPDATA > /dev/null 2>&1 | ||
197 | ADDR=`expr $ADDR + $TMPSIZE` | ||
198 | fi | ||
199 | |||
200 | rm $TMPDATA > /dev/null 2>&1 | ||
201 | |||
202 | #progress | ||
203 | SPNUM=0 | ||
204 | while [ $SPNUM -lt $PROGSTEP ] | ||
205 | do | ||
206 | echo -n '.' | ||
207 | SPNUM=`expr $SPNUM + 1` | ||
208 | done | ||
209 | done | ||
210 | |||
211 | echo '' | ||
212 | |||
213 | #finish | ||
214 | rm -f $TMPPATH/*.bin > /dev/null 2>&1 | ||
215 | |||
216 | if [ $RESULT = 0 ] | ||
217 | then | ||
218 | if [ -e $VTMPNAME ] | ||
219 | then | ||
220 | /sbin/nandlogical $LOGOCAL_MTD WRITE $VERBLOCK 0x4000 $VTMPNAME > /dev/null 2>&1 | ||
221 | rm -f $VTMPNAME > /dev/null 2>&1 | ||
222 | fi | ||
223 | if [ -e $MTMPNAME ] | ||
224 | then | ||
225 | /sbin/nandlogical $LOGOCAL_MTD WRITE $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1 | ||
226 | rm -f $MTMPNAME > /dev/null 2>&1 | ||
227 | fi | ||
228 | echo 'Success!' | ||
229 | else | ||
230 | echo 'Error!' | ||
231 | # exit $RESULT | ||
232 | fi | ||
233 | fi | ||
234 | done | ||
235 | |||
236 | #exit 0 | ||
237 | |||
238 | echo 'Please reset' | ||
239 | while true | ||
240 | do | ||
241 | done | ||