diff options
Diffstat (limited to 'meta/packages/zaurus-updater/spitz/updater.sh')
-rwxr-xr-x | meta/packages/zaurus-updater/spitz/updater.sh | 280 |
1 files changed, 0 insertions, 280 deletions
diff --git a/meta/packages/zaurus-updater/spitz/updater.sh b/meta/packages/zaurus-updater/spitz/updater.sh deleted file mode 100755 index a748334cc7..0000000000 --- a/meta/packages/zaurus-updater/spitz/updater.sh +++ /dev/null | |||
@@ -1,280 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # | ||
4 | # Noodles' simpler update script. SL-C3000 only for the moment. | ||
5 | # | ||
6 | |||
7 | DATAPATH=$1 | ||
8 | TMPPATH=/tmp/update | ||
9 | TMPDATA=$TMPPATH/tmpdata.bin | ||
10 | TMPHEAD=$TMPPATH/tmphead.bin | ||
11 | |||
12 | WFLG_KERNEL=0 | ||
13 | WFLG_INITRD=0 | ||
14 | WFLG_HDD=0 | ||
15 | |||
16 | RO_MTD_LINE=`cat /proc/mtd | grep "root" | tail -n 1` | ||
17 | if [ "$RO_MTD_LINE" = "" ]; then | ||
18 | RO_MTD_LINE=`cat /proc/mtd | grep "\<NAND\>.*\<2\>" | tail -n 1` | ||
19 | fi | ||
20 | RO_MTD_NO=`echo $RO_MTD_LINE | cut -d: -f1 | cut -dd -f2` | ||
21 | RO_MTD_SIZE_HEX=`echo $RO_MTD_LINE | cut -d" " -f2` | ||
22 | RO_MTD=/dev/mtd$RO_MTD_NO | ||
23 | RO_MTDBLK=/dev/mtdblock$RO_MTD_NO | ||
24 | RO_MTD_SIZE=`dc 0x$RO_MTD_SIZE_HEX 1024 /` | ||
25 | |||
26 | RW_MTD_LINE=`cat /proc/mtd | grep "home" | tail -n 1` | ||
27 | if [ "$RW_MTD_LINE" = "" ]; then | ||
28 | RW_MTD_LINE=`cat /proc/mtd | grep "\<NAND\>.*\<2\>" | tail -n 1` | ||
29 | fi | ||
30 | RW_MTD_NO=`echo $RW_MTD_LINE | cut -d: -f1 | cut -dd -f2` | ||
31 | RW_MTD_SIZE_HEX=`echo $RW_MTD_LINE | cut -d" " -f2` | ||
32 | RW_MTD=/dev/mtd$RW_MTD_NO | ||
33 | RW_MTDBLK=/dev/mtdblock$RW_MTD_NO | ||
34 | RW_MTD_SIZE=`dc 0x$RW_MTD_SIZE_HEX 1024 /` | ||
35 | |||
36 | LOGOCAL_MTD=/dev/mtd1 | ||
37 | |||
38 | VERBLOCK=0x48000 | ||
39 | MVRBLOCK=0x70000 | ||
40 | |||
41 | RESULT=0 | ||
42 | |||
43 | Cleanup(){ | ||
44 | rm -f $VTMPNAME > /dev/null 2>&1 | ||
45 | rm -f $MTMPNAME > /dev/null 2>&1 | ||
46 | rm $CTRLPATH/* > /dev/null 2>&1 | ||
47 | exit $1 | ||
48 | } | ||
49 | trap 'Cleanup 1' 1 15 | ||
50 | trap '' 2 3 | ||
51 | |||
52 | get_dev_pcmcia() | ||
53 | { | ||
54 | while read SOCKET CLASS DRIVER INSTANCE DEVS MAJOR MINOR; | ||
55 | do | ||
56 | echo $DEVS | ||
57 | done | ||
58 | } | ||
59 | get_dev_pcmcia_slot() | ||
60 | { | ||
61 | grep "^$1" /var/lib/pcmcia/stab | get_dev_pcmcia | ||
62 | } | ||
63 | sleep 1 | ||
64 | IDE1=`get_dev_pcmcia_slot 1` | ||
65 | if [ "$IDE1" = "" ]; then | ||
66 | echo "Error!! There is no HDD. Now retrying..." | ||
67 | while [ "$IDE1" = "" ]; do | ||
68 | IDE1=`get_dev_pcmcia_slot 1` | ||
69 | done | ||
70 | echo "Found HDD!!" | ||
71 | fi | ||
72 | |||
73 | #LINUXFMT=ext2 | ||
74 | LINUXFMT=ext3 | ||
75 | MKE2FSOPT= | ||
76 | if [ "$LINUXFMT" = "ext3" ]; then | ||
77 | MKE2FSOPT=-j | ||
78 | fi | ||
79 | |||
80 | |||
81 | ### Check model ### | ||
82 | /sbin/writerominfo | ||
83 | MODEL=`cat /proc/deviceinfo/product` | ||
84 | if [ "$MODEL" != "SL-C3000" ] && [ "$MODEL" != "SL-C3100" ] && [ "$MODEL" != "SL-C3200" ] | ||
85 | then | ||
86 | echo 'MODEL:'$MODEL | ||
87 | echo 'ERROR:Invalid model!' | ||
88 | echo 'Please reset' | ||
89 | while true | ||
90 | do | ||
91 | done | ||
92 | fi | ||
93 | |||
94 | ### Check that we have a valid tar | ||
95 | for TARNAME in gnu-tar GNU-TAR | ||
96 | do | ||
97 | if [ -e $DATAPATH/$TARNAME ] | ||
98 | then | ||
99 | TARBIN=$DATAPATH/$TARNAME | ||
100 | fi | ||
101 | done | ||
102 | |||
103 | if [ ! -e $TARBIN ]; then | ||
104 | echo 'Please place a valid copy of tar as "gnu-tar" on your card' | ||
105 | echo 'Please reset' | ||
106 | while true | ||
107 | do | ||
108 | done | ||
109 | fi | ||
110 | |||
111 | mkdir -p $TMPPATH > /dev/null 2>&1 | ||
112 | |||
113 | cd $DATAPATH/ | ||
114 | |||
115 | # | ||
116 | # First do the kernel. | ||
117 | # | ||
118 | for TARGETFILE in zImage.bin zimage.bin ZIMAGE.BIN | ||
119 | do | ||
120 | if [ -e $TARGETFILE -a $WFLG_KERNEL = 0 ] | ||
121 | then | ||
122 | # Get the size of the kernel. | ||
123 | DATASIZE=`wc -c $TARGETFILE` | ||
124 | DATASIZE=`echo $DATASIZE | cut -d' ' -f1` | ||
125 | |||
126 | echo 'Updating kernel.' | ||
127 | echo $TARGETFILE':'$DATASIZE' bytes' | ||
128 | /sbin/nandlogical $LOGOCAL_MTD WRITE 0xe0000 $DATASIZE \ | ||
129 | $TARGETFILE > /dev/null 2>&1 | ||
130 | |||
131 | WFLG_KERNEL=1 | ||
132 | |||
133 | fi | ||
134 | done | ||
135 | |||
136 | # | ||
137 | # Now do the initrd. | ||
138 | # | ||
139 | for TARGETFILE in initrd.bin INITRD.BIN | ||
140 | do | ||
141 | if [ -e $TARGETFILE -a $WFLG_INITRD = 0 ] | ||
142 | then | ||
143 | rm -f $TMPPATH/*.bin > /dev/null 2>&1 | ||
144 | DATASIZE=`wc -c $TARGETFILE` | ||
145 | DATASIZE=`echo $DATASIZE | cut -d' ' -f1` | ||
146 | |||
147 | WFLG_INITRD=1 | ||
148 | echo 'RO file system' | ||
149 | MODULEID=6 | ||
150 | MODULESIZE=0x500000 | ||
151 | ADDR=0 | ||
152 | TARGET_MTD=$RO_MTD | ||
153 | DATAPOS=16 | ||
154 | ONESIZE=1048576 | ||
155 | /sbin/bcut -s 16 -o $TMPHEAD $TARGETFILE | ||
156 | |||
157 | echo -n 'Flash erasing...' | ||
158 | /sbin/eraseall $TARGET_MTD 2> /dev/null > /dev/null | ||
159 | echo 'done' | ||
160 | |||
161 | echo '' | ||
162 | echo '0% 100%' | ||
163 | PROGSTEP=`expr $DATASIZE / $ONESIZE + 1` | ||
164 | PROGSTEP=`expr 28 / $PROGSTEP` | ||
165 | if [ $PROGSTEP = 0 ] | ||
166 | then | ||
167 | PROGSTEP=1 | ||
168 | fi | ||
169 | |||
170 | #00 means header information | ||
171 | VTMPNAME=$TMPPATH'/vtmp'`date '+%s'`'.tmp' | ||
172 | MTMPNAME=$TMPPATH'/mtmp'`date '+%s'`'.tmp' | ||
173 | /sbin/nandlogical $LOGOCAL_MTD READ $VERBLOCK 0x4000 $VTMPNAME > /dev/null 2>&1 | ||
174 | /sbin/nandlogical $LOGOCAL_MTD READ $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1 | ||
175 | |||
176 | #echo 'found header' | ||
177 | /sbin/verchg -v $VTMPNAME $TMPHEAD $MODULEID $MODULESIZE > /dev/null 2>&1 | ||
178 | /sbin/verchg -m $MTMPNAME $TMPHEAD $MODULEID $MODULESIZE > /dev/null 2>&1 | ||
179 | |||
180 | #loop | ||
181 | while [ $DATAPOS -lt $DATASIZE ] | ||
182 | do | ||
183 | #data create | ||
184 | bcut -a $DATAPOS -s $ONESIZE -o $TMPDATA $TARGETFILE | ||
185 | TMPSIZE=`wc -c $TMPDATA` | ||
186 | TMPSIZE=`echo $TMPSIZE | cut -d' ' -f1` | ||
187 | DATAPOS=`expr $DATAPOS + $TMPSIZE` | ||
188 | |||
189 | #handle data file | ||
190 | #echo 'ADDR='$ADDR | ||
191 | #echo 'SIZE='$TMPSIZE | ||
192 | next_addr=`/sbin/nandcp -a $ADDR $TMPDATA $TARGET_MTD 2>/dev/null | fgrep "mtd address" | cut -d- -f2 | cut -d\( -f1` | ||
193 | if [ "$next_addr" = "" ]; then | ||
194 | echo "ERROR:flash write" | ||
195 | rm $TMPDATA > /dev/null 2>&1 | ||
196 | RESULT=3 | ||
197 | break; | ||
198 | fi | ||
199 | ADDR=$next_addr | ||
200 | |||
201 | rm $TMPDATA > /dev/null 2>&1 | ||
202 | |||
203 | #progress | ||
204 | SPNUM=0 | ||
205 | while [ $SPNUM -lt $PROGSTEP ] | ||
206 | do | ||
207 | echo -n '.' | ||
208 | SPNUM=`expr $SPNUM + 1` | ||
209 | done | ||
210 | done | ||
211 | |||
212 | echo '' | ||
213 | |||
214 | #finish | ||
215 | rm -f $TMPPATH/*.bin > /dev/null 2>&1 | ||
216 | |||
217 | if [ $RESULT = 0 ] | ||
218 | then | ||
219 | /sbin/nandlogical $LOGOCAL_MTD WRITE $VERBLOCK 0x4000 $VTMPNAME > /dev/null 2>&1 | ||
220 | /sbin/nandlogical $LOGOCAL_MTD WRITE $MVRBLOCK 0x4000 $MTMPNAME > /dev/null 2>&1 | ||
221 | |||
222 | rm -f $VTMPNAME > /dev/null 2>&1 | ||
223 | rm -f $MTMPNAME > /dev/null 2>&1 | ||
224 | echo 'Success!' | ||
225 | else | ||
226 | echo 'Error!' | ||
227 | exit $RESULT | ||
228 | fi | ||
229 | fi | ||
230 | done | ||
231 | |||
232 | ## HDD image | ||
233 | for TARGETFILE in hdimage1.tgz HDIMAGE1.TGZ | ||
234 | do | ||
235 | if [ -e $TARGETFILE ]; then | ||
236 | if [ $WFLG_HDD != 0 ] | ||
237 | then | ||
238 | continue | ||
239 | fi | ||
240 | WFLG_HDD=1 | ||
241 | echo '' | ||
242 | echo 'HDD RO file system' | ||
243 | if [ ! -f /hdd1/NotAvailable ]; then | ||
244 | umount /hdd1 | ||
245 | fi | ||
246 | echo 'Now formatting...' | ||
247 | mke2fs $MKE2FSOPT /dev/${IDE1}1 2> /dev/null > /dev/null | ||
248 | e2fsck -p /dev/${IDE1}1 > /dev/null | ||
249 | if [ "$?" != "0" ]; then | ||
250 | echo "Error!" | ||
251 | exit "$?" | ||
252 | fi | ||
253 | |||
254 | mount -t $LINUXFMT -o noatime /dev/${IDE1}1 /hdd1 | ||
255 | if [ "$?" != "0" ]; then | ||
256 | echo "Error!" | ||
257 | exit "$?" | ||
258 | fi | ||
259 | |||
260 | cd /hdd1 | ||
261 | echo 'Now extracting...' | ||
262 | gzip -dc $DATAPATH/$TARGETFILE | $TARBIN xf - | ||
263 | if [ "$?" != "0" ]; then | ||
264 | echo "Error!" | ||
265 | exit "$?" | ||
266 | fi | ||
267 | |||
268 | echo 'Success!' | ||
269 | |||
270 | #This can be useful for debugging | ||
271 | #/bin/sh -i | ||
272 | |||
273 | # remount as RO | ||
274 | cd / | ||
275 | umount /hdd1 | ||
276 | mount -t $LINUXFMT -o ro,noatime /dev/${IDE1}1 /hdd1 | ||
277 | fi | ||
278 | done | ||
279 | |||
280 | exit 0 | ||