2 # GDB init script to support the Kendin/Micrel KS8695 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.
16 set *((long*) 0x03ffe00c) = 0x03000000
20 set *((long*) 0x03ffe004) = $arg0
28 printf "Ready to download over serial line...\n"
37 printf "Ready to download over serial line...\n"
42 set *((unsigned long *) 0x03ffe600) = 0x00000006
43 set *((unsigned long *) 0x03ffe604) = 0x00000000
44 set *((unsigned long *) 0x03ffe608) = 0x00000006
54 # Map flash0 and flash1 banks contiguously from 0x02000000
55 set *((unsigned long *) 0x03ff4010) = 0x8fe00040
56 set *((unsigned long *) 0x03ff4014) = 0x9fe40040
57 set *((unsigned long *) 0x03ff4020) = 0x30000005
62 # Set bank0 to map RAM to 0x00000000, 16bit, 9 columns, 4banks
63 #set *((unsigned long *) 0x03ff4030) = 0x3fc0010c
64 set *((unsigned long *) 0x03ff4030) = 0x3fc0000e
65 set *((unsigned long *) 0x03ff4034) = 0
67 # Set global RAS/CAS timings
68 set *((unsigned long *) 0x03ff4038) = 0x0000000a
70 # Send NOP command (via SDRAM buffer control register)
71 set *((unsigned long *) 0x03ff403c) = 0x00030000
74 # Send PRECHARGE-ALL command (via SDRAM buffer control register)
75 set *((unsigned long *) 0x03ff403c) = 0x00010000
78 # Fast refreash cycles (at least 2 needed)
79 set *((unsigned long *) 0x03ff4040) = 0x00000020
81 set *((unsigned long *) 0x03ff4040) = 0x00000168
83 # Send MODE command (via buffer control register)
84 set *((unsigned long *) 0x03ff403c) = 0x00020033
92 # Some simple memory tests.
99 set *((unsigned long *) $addr) = $val
100 set $addr = $addr + 4
110 while ($num < 0x1000)
111 set $rd = *((unsigned long *) $addr)
115 set $addr = $addr + 4
122 set $total = 0x100000
125 while ($num < $total)
126 set *((unsigned long *) $addr) = $val
127 set $addr = $addr + 4
134 while ($num < $total)
135 set $rd = *((unsigned long *) $addr)
139 set $addr = $addr + 4
151 set $val1 = *((unsigned long *) $src1)
152 set $val2 = *((unsigned long *) $src2)
154 printf "ERROR: [%x]=%x [%x]=%x\n", $src1, $val1, $src2, $val2
156 set $src1 = $src1 + 4
157 set $src2 = $src2 + 4
164 # FLASH handling code.
167 printf "ERASE: addr=%x", $arg0
168 set *((unsigned char *) $arg0) = 0x20
169 set *((unsigned char *) $arg0) = 0xd0
171 set *((unsigned char *) $arg0) = 0xff
176 printf "UNLOCK: addr=%x", $arg0
177 set *((unsigned char *) $arg0) = 0x60
178 set *((unsigned char *) $arg0) = 0xd0
180 set *((unsigned char *) $arg0) = 0xff
184 define flash-eraseall
186 while ($addr < 0x400000)
187 flash-erase 0x02000000+$addr
188 set $addr = $addr + 0x20000
193 define flash-eraseimage
195 while ($addr < 0x400000)
196 flash-erase 0x02000000+$addr
197 set $addr = $addr + 0x20000
202 define flash-eraseboot
203 flash-erase 0x02000000
207 define flash-program-byte
208 set *((unsigned char *) $arg0) = 0x40
209 set *((unsigned char *) $arg0) = $arg1
212 set $val = *((unsigned char *) $arg0)
213 set $delay = $delay + 1
215 set *((unsigned char *) $arg0) = 0xff
223 set $dst = 0x02000000
224 while ($count < $num)
225 set $byte = *((unsigned char *) $src)
226 flash-program-byte $dst $byte
229 if (($count & 0x3ff) == 0)
230 printf "PROGRAMING FLASH: 0x%08x-0x%08x\n", $count, ($count+0x400)
232 set $count = $count + 1
238 # Load and program the boot code into flash.
243 flash-erase 0x02000000
244 load boot/boot-gdb.elf
246 set *((unsigned long *) 0) = 0xea000006
251 define flash-bootload
254 flash-erase 0x02000000
259 define flash-bootprogram
265 # flash-burn <flash-addr> <ram-start> <count>
272 set $r6 = $arg1 + $arg2
278 # Load and program a kernel image...
280 define flash-kernelload
283 flash-erase 0x02020000
284 flash-erase 0x02040000
285 flash-erase 0x02060000
286 flash-erase 0x02080000
287 flash-erase 0x020a0000
291 define flash-kernelprogram
299 # Startup commands...
304 target remote localhost:8888
307 #set print asm-demangle