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