2 # GDB init script to support the Cirrus Logic EP9312 ARM
5 # (C) Copyright 2003-2004, Greg Ungerer <gerg@snapgear.com>
7 # Designed to be used with the Macraigor RAVEN wiggler for
8 # ARM based 20ping JTAG setups. I use their OCdemon Linux
9 # driver and arm-elf-gdb with it.
20 # This is set to 115200,8,n,1
21 set *((unsigned long *) 0x808c0010) = 0x07000000
22 set *((unsigned long *) 0x808c000c) = 0x00000000
23 set *((unsigned long *) 0x808c0008) = 0x60000000
24 set *((unsigned long *) 0x808c0014) = 0x01000000
28 set *((unsigned long *) 0x808c0000) = $arg0
32 set *((unsigned long *) 0x808c0014) = 0x81000000
37 # 8 fifo-enable 1 none
38 # fifo set *((unsigned char *) 0x808d0008) = 0x70
39 # BR = 0007 = 14.7456MHz / (16 * 115200) - 1
40 set *((unsigned char *) 0x808d0010) = 0x00
41 set *((unsigned char *) 0x808d000c) = 0x00
42 set *((unsigned char *) 0x808d0008) = 0x00
43 set *((unsigned char *) 0x808d0010) = 0x07
44 set *((unsigned char *) 0x808d000c) = 0x00
45 set *((unsigned char *) 0x808d0008) = 0x60
46 set *((unsigned char *) 0x808d0014) = 0x01
50 set *((unsigned char *) 0x808d0000) = $arg0
54 set *((unsigned char *) 0x808d0014) = 0x81
59 set $tmp = * (unsigned long *) 0x80930004
60 set * (unsigned long *) 0x80930004 = ($tmp | 0x20000000)
61 # This is set to 115200,8,n,1
62 set *((unsigned long *) 0x808e0010) = 0x07000000
63 set *((unsigned long *) 0x808e000c) = 0x00000000
64 set *((unsigned long *) 0x808e0008) = 0x60000000
65 set *((unsigned long *) 0x808e0014) = 0x01000000
69 set *((unsigned long *) 0x808e0000) = $arg0
73 set *((unsigned long *) 0x808e0014) = 0x81000000
78 set *((unsigned long *) 0xc0000000) = 0xe3a01102
79 set *((unsigned long *) 0xc0000004) = 0xe381188d
80 set *((unsigned long *) 0xc0000008) = 0xe3a02007
81 set *((unsigned long *) 0xc000000c) = 0xe5812010
82 set *((unsigned long *) 0xc0000010) = 0xe3a02000
83 set *((unsigned long *) 0xc0000014) = 0xe581200c
84 set *((unsigned long *) 0xc0000018) = 0xe3a02060
85 set *((unsigned long *) 0xc000001c) = 0xe5812008
86 set *((unsigned long *) 0xc0000020) = 0xe3a02001
87 set *((unsigned long *) 0xc0000024) = 0xe581200c
88 set *((unsigned long *) 0xc0000028) = 0xe3a04000
89 set *((unsigned long *) 0xc000002c) = 0xe3a05103
90 set *((unsigned long *) 0xc0000030) = 0xe3855a01
91 # set *((unsigned long *) 0xc0000030) = 0xe38558ff
92 set *((unsigned long *) 0xc0000034) = 0xe3a03010
93 set *((unsigned long *) 0xc0000038) = 0xe5912018
94 set *((unsigned long *) 0xc000003c) = 0xe1120003
95 set *((unsigned long *) 0xc0000040) = 0x1afffffc
96 set *((unsigned long *) 0xc0000044) = 0xe5912000
97 set *((unsigned long *) 0xc0000048) = 0xe5c52000
98 set *((unsigned long *) 0xc000004c) = 0xe2855001
99 set *((unsigned long *) 0xc0000050) = 0xe2844001
100 set *((unsigned long *) 0xc0000054) = 0xeafffff7
106 printf "Ready to download over serial line...\n"
112 set *((unsigned long *) 0x03ffe600) = 0x00000006
113 set *((unsigned long *) 0x03ffe604) = 0x00000000
114 set *((unsigned long *) 0x03ffe608) = 0x00000006
121 # Set SDCS0 to be 16MB (2*64Mbit devices parallel on 32bit data bus)
122 # This sets it for RAS=2, CAS=3, 4 banks
123 set *((unsigned long *) 0x80060010) = 0x00210028
126 # Set global config to initiate NOPs
127 set *((unsigned long *) 0x80060004) = 0x80000003
130 # Send PRECHARGE-ALL command
131 set *((unsigned long *) 0x80060004) = 0x80000001
133 # Enable refresh engine to generate some fast refreshes
134 set *((unsigned long *) 0x80060008) = 0x00000010
137 # Switch refresh engine back to normal
138 set *((unsigned long *) 0x80060008) = 0x00000023
141 set *((unsigned long *) 0x80060004) = 0x80000002
142 set $junk = *((unsigned long *) 0xc0008800)
143 set $junk = *((unsigned long *) 0xc0408800)
144 set $junk = *((unsigned long *) 0xc0808800)
145 set $junk = *((unsigned long *) 0xc0c08800)
147 # Set the real value into the global configuration register
148 set *((unsigned long *) 0x80060004) = 0x80000000
155 set *((unsigned char *) 0x809300C0 ) = 0xaa
159 # Set the internal PLL clocks
164 # set $pc = 0xc0000000
166 # set * (unsigned long *) 0x80930020 = 0
171 set * (unsigned long *) 0x80930020 = 0
177 # load tools/bin/clk2
178 # set $pc = 0xc0000000
180 # set * (unsigned long *) 0x80930024 = 0x300dc317
182 # Fout = 192000000.00
185 set * (unsigned long *) 0x80930024 = 0x300dc317
191 load tools/bin/devcfg
195 # unlock the Syscon lock
197 # set * (unsigned long *) 0x809300c0 = 0x000000aa
202 # set * (unsigned long *) 0x80930080 = 0x00140000
207 # Some simple memory tests.
213 while ($num < 0x1000)
214 set *((unsigned long *) $addr) = $val
215 set $addr = $addr + 4
225 while ($num < 0x1000)
226 set $rd = *((unsigned long *) $addr)
230 set $addr = $addr + 4
237 #set $total = 0x100000
241 while ($num < $total)
242 set *((unsigned long *) $addr) = $val
243 set $addr = $addr + 4
250 while ($num < $total)
251 set $rd = *((unsigned long *) $addr)
255 set $addr = $addr + 4
267 set $val1 = *((unsigned long *) $src1)
268 set $val2 = *((unsigned long *) $src2)
270 printf "ERROR: [%x]=%x [%x]=%x\n", $src1, $val1, $src2, $val2
272 set $src1 = $src1 + 4
273 set $src2 = $src2 + 4
280 # FLASH handling code.
283 set * (((unsigned short *) $arg0) + 0x00) = 0xf0
284 set * (((unsigned short *) $arg0) + 0x55) = 0x98
285 p /x * (((unsigned short *) $arg0) + 0x10)
286 p /x * (((unsigned short *) $arg0) + 0x11)
287 p /x * (((unsigned short *) $arg0) + 0x12)
291 set * ((unsigned short *) $arg0 + 0x00) = 0x00f0
292 set * ((unsigned short *) $arg0 + 0xaa) = 0x0098
293 p /x * ((unsigned short *) $arg0 + 0x20)
297 printf "ERASE: addr=%x", $arg0
298 set *((unsigned char *) $arg0) = 0x20
299 set *((unsigned char *) $arg0) = 0xd0
301 set *((unsigned char *) $arg0) = 0xff
306 define flash-eraseall
308 while ($addr < 0x400000)
309 flash-erase 0x00000000+$addr
310 set $addr = $addr + 0x20000
315 define flash-eraseimage
317 while ($addr < 0x400000)
318 flash-erase 0x00000000+$addr
319 set $addr = $addr + 0x20000
324 define flash-eraseboot
325 flash-erase 0x00000000
329 define flash-program-byte
330 set *((unsigned char *) $arg0) = 0x40
331 set *((unsigned char *) $arg0) = $arg1
334 set $val = *((unsigned char *) $arg0)
335 set $delay = $delay + 1
337 set *((unsigned char *) $arg0) = 0xff
344 set $src = 0xc0000000
345 set $dst = 0x00000000
346 while ($count < $num)
347 set $byte = *((unsigned char *) $src)
348 flash-program-byte $dst $byte
351 if (($count & 0x3ff) == 0)
352 printf "PROGRAMING FLASH: 0x%08x-0x%08x\n", $count, ($count+0x400)
354 set $count = $count + 1
359 define flash-burncode
360 set *((unsigned long *) 0xc0000000) = 0xe3a01000
361 set *((unsigned long *) 0xc0000004) = 0xe3a05103
362 set *((unsigned long *) 0xc0000008) = 0xe3855a01
363 set *((unsigned long *) 0xc000000c) = 0xe3856902
364 set *((unsigned long *) 0xc0000010) = 0xe3a02040
365 set *((unsigned long *) 0xc0000014) = 0xe3822901
366 set *((unsigned long *) 0xc0000018) = 0xe3a03080
367 set *((unsigned long *) 0xc000001c) = 0xe3a040ff
368 set *((unsigned long *) 0xc0000020) = 0xe3844cff
369 set *((unsigned long *) 0xc0000024) = 0xe1c120b0
370 set *((unsigned long *) 0xc0000028) = 0xe1d570b0
371 set *((unsigned long *) 0xc000002c) = 0xe1c170b0
372 set *((unsigned long *) 0xc0000030) = 0xe1d170b0
373 set *((unsigned long *) 0xc0000034) = 0xe1170003
374 set *((unsigned long *) 0xc0000038) = 0x0afffffc
375 set *((unsigned long *) 0xc000003c) = 0xe1c140b0
376 set *((unsigned long *) 0xc0000040) = 0xe2811002
377 set *((unsigned long *) 0xc0000044) = 0xe2855002
378 set *((unsigned long *) 0xc0000048) = 0xe1550006
379 set *((unsigned long *) 0xc000004c) = 0x1afffff4
380 set *((unsigned long *) 0xc0000050) = 0xe1a00000
381 set *((unsigned long *) 0xc0000054) = 0xe1a00000
382 set *((unsigned long *) 0xc0000058) = 0xeafffffe
386 set * ((unsigned long *) 0x80940000) = 0x0000aaaa
388 # set * ((unsigned long *) 0x80930080) = 0x80000000
389 # set * ((unsigned long *) 0x80930080) = 0x00000000
393 # Load and program the boot code into flash.
418 flash-erase 0x00000000
426 # FIXME: this just does not seem to work right...
428 load boot/boot-ram.elf
429 flash-erase 0x00000000
437 # Startup commands...
442 target remote localhost:8888
445 #set print asm-demangle