OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / tools / misc / sg8100.gdb
1 #
2 #       SnapGear SG8100 (IXP425) target support
3 #
4
5 #
6 #       UART functions
7 #
8
9 define uart-init
10 set *((long*) 0xc800000c) = 0x83
11 set *((long*) 0xc8000000) = 0x08
12 set *((long*) 0xc8000004) = 0x00
13 set *((long*) 0xc800000c) = 0x03
14 set *((long*) 0xc8000004) = 0x40
15 end
16
17 define uart-print
18 set *((long*) 0xc8000000) = $arg0
19 end
20
21
22 #
23 #       Memory functions
24 #
25
26 define mem-init
27 # set for 32MB (3CAS, 3RAS)
28 #set *((long*) 0xcc000000) = 0x18
29 set *((long*) 0xcc000000) = 0x18
30
31 # disable refresh
32 set *((long*) 0xcc000004) = 0
33
34 # send NOP command
35 set *((long*) 0xcc000008) = 0x03
36 shell sleep 1
37
38 # set refresh count
39 set *((long*) 0xcc000004) = 0x384
40 shell sleep 1
41
42 # send PRECHARGE-ALL command
43 set *((long*) 0xcc000008) = 0x02
44 shell sleep 1
45
46 # send AUTO-REFRESH command
47 set $num = 8
48 while ($num > 0)
49         set *((long*) 0xcc000008) = 0x04
50         shell sleep 1
51         set $num = $num - 1
52 end
53
54 # send MODE (CAS3) command
55 set *((long*) 0xcc000008) = 0x01
56 shell sleep 1
57
58 # send NORMAL-OPERATION command
59 set *((long*) 0xcc000008) = 0x06
60 shell sleep 1
61
62 end
63
64
65
66 #
67 #       Switch memory and expansion regions
68 #
69 define mem-switch
70 set *((unsigned long *) 0x10000000) = 0xe3a01331
71 set *((unsigned long *) 0x10000004) = 0xe3811020
72 set *((unsigned long *) 0x10000008) = 0xe5912000
73 set *((unsigned long *) 0x1000000c) = 0xe3c22102
74 set *((unsigned long *) 0x10000010) = 0xe5812000
75 set $pc = 0x10000000
76 stepi 5
77 end
78
79
80 define mem-fill
81 set $num = 0
82 set $addr = $arg0
83 set $val = $arg1
84 while ($num < 0x1000)
85         set *((unsigned long *) $addr) = $val
86         set $addr = $addr + 4
87         set $num = $num + 1
88 end
89 end
90
91
92 define mem-check
93 set $num = 0
94 set $addr = $arg0
95 set $val = $arg1
96 while ($num < 0x1000)
97         set $rd = *((unsigned long *) $addr)
98         if ($rd != $val)
99                 print $addr
100         end
101         set $addr = $addr + 4
102         set $num = $num + 1
103 end
104 end
105
106 define  mem-compare
107 set $addr0 = $arg0
108 set $addr1 = $arg1
109 set $size = $arg2
110 set $addr0end = $addr0 + $size
111 while ($addr0 < $addr0end)
112         set $val0 = *((unsigned int *) $addr0)
113         set $val1 = *((unsigned int *) $addr1)
114         if ($val0 != $val1)
115                 print $addr0
116         end
117         set $addr0 = $addr0 + 4
118         set $addr1 = $addr1 + 4
119 end
120 end
121
122 #
123 #       Set BIG endian mode
124 #
125 define big
126 set *((unsigned long *) 0x10000000) = 0xee110f10
127 set *((unsigned long *) 0x10000004) = 0xe3800080
128 set *((unsigned long *) 0x10000008) = 0xee010f10
129 set *((unsigned long *) 0x1000000c) = 0xee120f10
130 set *((unsigned long *) 0x10000010) = 0xe1a00000
131 set *((unsigned long *) 0x10000010) = 0xe24ff004
132 set $pc = 0x10000000
133 stepi 6
134 end
135
136 #
137 #       Enable the caches.
138 #
139 define cache
140 set *((unsigned long *) 0x10000000) = 0xee110f10
141 set *((unsigned long *) 0x10000004) = 0xe3800a01
142 set *((unsigned long *) 0x10000008) = 0xe380000c
143 set *((unsigned long *) 0x1000000c) = 0xee010f10
144 set *((unsigned long *) 0x10000010) = 0xee120f10
145 set *((unsigned long *) 0x10000014) = 0xe1a00000
146 set *((unsigned long *) 0x10000018) = 0xe24ff004
147 set *((unsigned long *) 0x1000001c) = 0xee071f15
148 set *((unsigned long *) 0x10000020) = 0xee120f10
149 set *((unsigned long *) 0x10000024) = 0xe1a00000
150 set *((unsigned long *) 0x10000028) = 0xe24ff004
151 set $pc = 0x10000000
152 stepi 0xb
153 end
154
155 #
156 #       Enable the PCI clock (which is on GPIO14)
157 #
158 define pci-clock
159 set *((unsigned long *) 0xc8004004) = 0x00003fff
160 set *((unsigned long *) 0xc8004018) = 0x000001ff
161 set *((unsigned long *) 0xc8004000) = 0x00004000
162 end
163
164 #
165 #       Configure the flash region to be writable.
166 #
167 define writable
168 set *((unsigned long *) 0x10000000) = 0xe3a01331
169 set *((unsigned long *) 0x10000004) = 0xe5912000
170 set *((unsigned long *) 0x10000008) = 0xe3822002
171 set *((unsigned long *) 0x1000000c) = 0xe5812000
172 set $pc = 0x10000000
173 stepi 4
174 end
175
176
177 #
178 #       FLASH writing code (16bit functions)
179 #       This current scripting is setup for P30 Strata flash.
180 #
181
182 define flash-erase0
183 monitor short 0x50000000 = 0x20
184 monitor short 0x50000000 = 0xd0
185 shell sleep 1
186 monitor short 0x50000000 = 0xff
187
188 monitor short 0x50008000 = 0x20
189 monitor short 0x50008000 = 0xd0
190 shell sleep 1
191 monitor short 0x50008000 = 0xff
192
193 monitor short 0x50010000 = 0x20
194 monitor short 0x50010000 = 0xd0
195 shell sleep 1
196 monitor short 0x50010000 = 0xff
197
198 monitor short 0x50018000 = 0x20
199 monitor short 0x50018000 = 0xd0
200 shell sleep 1
201 monitor short 0x50018000 = 0xff
202 end
203
204 define flash-unlock0
205 monitor short 0x50000000 = 0x60
206 monitor short 0x50000000 = 0xd0
207 shell sleep 1
208 monitor short 0x50000000 = 0xff
209
210 monitor short 0x50008000 = 0x60
211 monitor short 0x50008000 = 0xd0
212 shell sleep 1
213 monitor short 0x50008000 = 0xff
214
215 monitor short 0x50010000 = 0x60
216 monitor short 0x50010000 = 0xd0
217 shell sleep 1
218 monitor short 0x50010000 = 0xff
219
220 monitor short 0x50018000 = 0x60
221 monitor short 0x50018000 = 0xd0
222 shell sleep 1
223 monitor short 0x50018000 = 0xff
224 end
225
226 define flash-erase1
227 monitor short 0x50020000 = 0x20
228 monitor short 0x50020000 = 0xd0
229 shell sleep 1
230 monitor short 0x50020000 = 0xff
231 end
232
233 define flash-unlock1
234 monitor short 0x50020000 = 0x60
235 monitor short 0x50020000 = 0xd0
236 shell sleep 1
237 monitor short 0x50020000 = 0xff
238 end
239
240 define flash-id
241 set *((unsigned long *) 0x10000000) = 0xe3a01205
242 set *((unsigned long *) 0x10000004) = 0xe3a02090
243 set *((unsigned long *) 0x10000008) = 0xe3822a09
244 set *((unsigned long *) 0x1000000c) = 0xe1c120b0
245 set $pc = 0x10000000
246 stepi 4
247 end
248
249 define flash-program
250 set *((unsigned long *) 0x10100000) = 0xe3a01205
251 set *((unsigned long *) 0x10100004) = 0xe3a02040
252 set *((unsigned long *) 0x10100008) = 0xe3822901
253 set *((unsigned long *) 0x1010000c) = 0xe3a03080
254 set *((unsigned long *) 0x10100010) = 0xe3a040ff
255 set *((unsigned long *) 0x10100014) = 0xe3844cff
256 set *((unsigned long *) 0x10100018) = 0xe3a05000
257 set *((unsigned long *) 0x1010001c) = 0xe3a06701
258 set *((unsigned long *) 0x10100020) = 0xe1c120b0
259 set *((unsigned long *) 0x10100024) = 0xe1d570b0
260 set *((unsigned long *) 0x10100028) = 0xe1c170b0
261 set *((unsigned long *) 0x1010002c) = 0xe1d170b0
262 set *((unsigned long *) 0x10100030) = 0xe1170003
263 set *((unsigned long *) 0x10100034) = 0x0afffffc
264 set *((unsigned long *) 0x10100038) = 0xe1c140b0
265 set *((unsigned long *) 0x1010003c) = 0xe2811002
266 set *((unsigned long *) 0x10100040) = 0xe2855002
267 set *((unsigned long *) 0x10100044) = 0xe1550006
268 set *((unsigned long *) 0x10100048) = 0x1afffff4
269 set *((unsigned long *) 0x1010004c) = 0xe1a00000
270 set *((unsigned long *) 0x10100050) = 0xe1a00000
271 set *((unsigned long *) 0x10100054) = 0xeafffffe
272 set $pc = 0x10100000
273 end
274
275 define flash-redboot
276 mem-init
277 mem-switch
278 writable
279 flash-unlock0
280 flash-erase0
281 flash-unlock1
282 flash-erase1
283 load boot/redboot/images/redboot-swap.elf
284 flash-program
285 c
286 end
287
288 define flash-boot
289 mem-init
290 mem-switch
291 writable
292 flash-unlock0
293 flash-erase0
294 load boot/boot-swap.elf
295 mem-setmac
296 flash-program
297 c
298 end
299
300 #
301 #       FLASH writing code (8bit functions)
302 #
303 define flash8-erase1
304 set *((unsigned long *) 0x10000000) = 0xe3a01205
305 set *((unsigned long *) 0x10000004) = 0xe3a02020
306 set *((unsigned long *) 0x10000008) = 0xe5c12000
307 set *((unsigned long *) 0x1000000c) = 0xe3a020d0
308 set *((unsigned long *) 0x10000010) = 0xe5c12000
309 set $pc = 0x10000000
310 stepi 5
311 shell sleep 2
312 set *((unsigned long *) 0x10000000) = 0xe3a020ff
313 set *((unsigned long *) 0x10000004) = 0xe5c12000
314 set $pc = 0x10000000
315 stepi 2
316 end
317
318 define flash8-erase2
319 set *((unsigned long *) 0x10000000) = 0xe3a01205
320 set *((unsigned long *) 0x10000004) = 0xe3811802
321 set *((unsigned long *) 0x10000008) = 0xe3a02020
322 set *((unsigned long *) 0x1000000c) = 0xe5c12000
323 set *((unsigned long *) 0x10000010) = 0xe3a020d0
324 set *((unsigned long *) 0x10000014) = 0xe5c12000
325 set $pc = 0x10000000
326 stepi 6
327 shell sleep 2
328 set *((unsigned long *) 0x10000000) = 0xe3a020ff
329 set *((unsigned long *) 0x10000004) = 0xe5c12000
330 set $pc = 0x10000000
331 stepi 2
332 end
333
334 define flash8-unlock1
335 set *((unsigned long *) 0x10000000) = 0xe3a01205
336 set *((unsigned long *) 0x10000004) = 0xe3a02060
337 set *((unsigned long *) 0x10000008) = 0xe5c12000
338 set *((unsigned long *) 0x1000000c) = 0xe3a020d0
339 set *((unsigned long *) 0x10000010) = 0xe5c12000
340 set *((unsigned long *) 0x10000014) = 0xe3a020ff
341 set *((unsigned long *) 0x10000018) = 0xe5c12000
342 set $pc = 0x10000000
343 stepi 7
344 end
345
346 define flash8-unlock2
347 set *((unsigned long *) 0x10000000) = 0xe3a01205
348 set *((unsigned long *) 0x10000004) = 0xe3811802
349 set *((unsigned long *) 0x10000008) = 0xe3a02060
350 set *((unsigned long *) 0x1000000c) = 0xe5c12000
351 set *((unsigned long *) 0x10000010) = 0xe3a020d0
352 set *((unsigned long *) 0x10000014) = 0xe5c12000
353 set *((unsigned long *) 0x10000018) = 0xe3a020ff
354 set *((unsigned long *) 0x1000001c) = 0xe5c12000
355 set $pc = 0x10000000
356 stepi 8
357 end
358
359 define flash8-program
360 set *((unsigned long *) 0x10100000) = 0xe3a01205
361 set *((unsigned long *) 0x10100004) = 0xe3a02040
362 set *((unsigned long *) 0x10100008) = 0xe3a03080
363 set *((unsigned long *) 0x1010000c) = 0xe3a040ff
364 set *((unsigned long *) 0x10100010) = 0xe3a05000
365 set *((unsigned long *) 0x10100014) = 0xe3a06701
366 set *((unsigned long *) 0x10100018) = 0xe5c12000
367 set *((unsigned long *) 0x1010001c) = 0xe5d57000
368 set *((unsigned long *) 0x10100020) = 0xe5c17000
369 set *((unsigned long *) 0x10100024) = 0xe5d17000
370 set *((unsigned long *) 0x10100028) = 0xe1170003
371 set *((unsigned long *) 0x1010002c) = 0x0afffffc
372 set *((unsigned long *) 0x10100030) = 0xe5c14000
373 set *((unsigned long *) 0x10100034) = 0xe2811001
374 set *((unsigned long *) 0x10100038) = 0xe2855001
375 set *((unsigned long *) 0x1010003c) = 0xe1550006
376 set *((unsigned long *) 0x10100040) = 0x1afffff4
377 set *((unsigned long *) 0x10100044) = 0xe1a00000
378 set *((unsigned long *) 0x10100048) = 0xe1a00000
379 set *((unsigned long *) 0x1010004c) = 0xeafffffe
380 set $pc = 0x10100000
381 end
382
383 define flash8-redboot
384 mem-init
385 mem-switch
386 writable
387 flash8-unlock1
388 flash8-erase1
389 flash8-unlock2
390 flash8-erase2
391 load boot/redboot/images/redboot-swap.elf
392 flash8-program
393 c
394 end
395
396 define flash8-boot
397 mem-init
398 mem-switch
399 writable
400 #flash8-unlock1
401 flash8-erase1
402 #flash8-unlock2
403 flash8-erase2
404 load boot/boot-swap.elf
405 mem-setmac
406 flash8-program
407 c
408 end
409
410
411 #
412 #       Set MAC addresses in the appropriate place. Makes it easier
413 #       for redboot to work right...
414 #
415 define mem-setmac
416 set *((unsigned char *) 0x1c000) = 0x00
417 set *((unsigned char *) 0x1c001) = 0xcf
418 set *((unsigned char *) 0x1c002) = 0xd0
419 set *((unsigned char *) 0x1c003) = 0x00
420 set *((unsigned char *) 0x1c004) = 0x00
421 set *((unsigned char *) 0x1c005) = 0x00
422 set *((unsigned char *) 0x1c006) = 0x01
423 set *((unsigned char *) 0x1c007) = 0x00
424 end
425
426 #
427 #       Set debugger into big endian mode.
428 #
429 define gdb-big
430 set endian big
431 monitor endian big
432 end
433
434
435 #
436 #       Startup commands...
437 #
438 set output-radix 16
439 set input-radix 16
440
441 target remote localhost:8888
442
443 #set endian big
444 #monitor endian big
445
446 set print pretty
447 set print asm-demangle
448 #display/i $pc
449