OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / tools / misc / sg720.gdb
1 #
2 #       SnapGear/SG720 target gdbinit script.
3 #
4
5
6 #
7 #       UART functions
8 #
9
10 define uart-init
11 set *((long*) 0xc800000c) = 0x83
12 set *((long*) 0xc8000000) = 0x08
13 set *((long*) 0xc8000004) = 0x00
14 set *((long*) 0xc800000c) = 0x03
15 set *((long*) 0xc8000004) = 0x40
16 end
17
18 define uart-print
19 set *((long*) 0xc8000000) = $arg0
20 end
21
22
23 #
24 #       Memory functions
25 #
26
27 define mem-init
28
29 # set for the type of DDR1 RAM on the SG720
30 monitor long 0xcc00e504 = 0x52220106
31 monitor long 0xcc00e508 = 0x25609074
32
33 # set SDRAM phys base (SDBR)
34 monitor long 0xcc00e50c) = 0
35 monitor long 0xcc00e50c
36
37 # set SDRAM boundary (SBR0 and SBR1) (pairs of 512Mb x 16)
38 monitor long 0xcc00e510 = 0x00000004
39 monitor long 0xcc00e510
40 monitor long 0xcc00e514 = 0x00000008
41 monitor long 0xcc00e514
42
43 # disable refresh cycles
44 monitor long 0xcc00e548 = 0
45
46 # send NOP command
47 monitor long 0xcc00e500 = 3
48 shell sleep 1
49
50 # send PRECHARGE-ALL command
51 monitor long 0xcc00e500 = 2
52 shell sleep 1
53
54 # send ENABLE-DLL command
55 monitor long 0xcc00e500 = 4
56 shell sleep 1
57
58 # send MODE-SET-RESET command
59 monitor long 0xcc00e500 = 1
60 shell sleep 1
61
62 # send PRECHARGE-ALL command
63 monitor long 0xcc00e500 = 2
64 shell sleep 1
65
66 # send 2 AUTO-REFRESH cycles
67 monitor long 0xcc00e500 = 6
68 monitor long 0xcc00e500 = 6
69
70 # send MODE-SET command (without DLL reset)
71 monitor long 0xcc00e500 = 0
72 shell sleep 1
73
74 # start normal operation command
75 monitor long 0xcc00e500 = 0xf
76 shell sleep 1
77
78 # set refresh value
79 monitor long 0xcc00e548 = 0x410
80 shell sleep 1
81
82 end
83
84
85
86 #
87 #       Switch memory and expansion regions
88 #
89 define mem-switch
90 monitor long 0xc4000020 = 0x00ffff7f
91 end
92
93
94 define mem-fill
95 set $num = 0
96 set $addr = $arg0
97 set $val = $arg1
98 while ($num < 0x1000)
99         set *((unsigned long *) $addr) = $val
100         set $addr = $addr + 4
101         set $num = $num + 1
102 end
103 end
104
105
106 define mem-wcycle
107 set $num = 0
108 set $addr = $arg0
109 while ($num < 0x80000)
110         #set *((unsigned long *) $addr) = 0x55555555
111         set *((unsigned long *) ($addr + 0x00002aaa)) = 0x55555555
112         set $num = $num + 1
113         #set *((unsigned long *) $addr) = 0xaaaaaaaa
114         #set *((unsigned long *) $addr) = 0xffffffff
115         set *((unsigned long *) ($addr + 0x00001555)) = 0xaaaaaaaa
116 end
117 end
118
119 define mem-rwcycle
120 set $num = 0
121 set $addr = $arg0
122 while ($num < 0x80000)
123         set *((unsigned long *) $addr) = 0x55555555
124         set $num = $num + 1
125         set $val = *((unsigned long *) $addr)
126 end
127 end
128
129 define mem-bytecycle
130 set $num = 0
131 set $range = 0
132 set $addr = $arg0
133 while ($num < 0x80000)
134         set $junk = *((unsigned char *) ($addr + $range))
135         set $num = $num + 1
136         set $range = $range + 1
137         if ($range >= 0x10)
138                 set $range = 0
139         end
140 end
141 end
142
143
144 define mem-check
145 set $num = 0
146 set $addr = $arg0
147 set $val = $arg1
148 while ($num < 0x1000)
149         set $rd = *((unsigned long *) $addr)
150         if ($rd != $val)
151                 print $addr
152         end
153         set $addr = $addr + 4
154         set $num = $num + 1
155 end
156 end
157
158
159 #
160 #       Set BIG endian mode
161 #
162 define big
163 set *((unsigned long *) 0x00000000) = 0xee110f10
164 set *((unsigned long *) 0x00000004) = 0xe3800080
165 set *((unsigned long *) 0x00000008) = 0xee010f10
166 set *((unsigned long *) 0x0000000c) = 0xee120f10
167 set *((unsigned long *) 0x00000010) = 0xe1a00000
168 set *((unsigned long *) 0x00000010) = 0xe24ff004
169 set $pc = 0x00000000
170 stepi 6
171 end
172
173 #
174 #       Enable the caches.
175 #
176 define cache
177 set *((unsigned long *) 0x00000000) = 0xee110f10
178 set *((unsigned long *) 0x00000004) = 0xe3800a01
179 set *((unsigned long *) 0x00000008) = 0xe380000c
180 set *((unsigned long *) 0x0000000c) = 0xee010f10
181 set *((unsigned long *) 0x00000010) = 0xee120f10
182 set *((unsigned long *) 0x00000014) = 0xe1a00000
183 set *((unsigned long *) 0x00000018) = 0xe24ff004
184 set *((unsigned long *) 0x0000001c) = 0xee071f15
185 set *((unsigned long *) 0x00000020) = 0xee120f10
186 set *((unsigned long *) 0x00000024) = 0xe1a00000
187 set *((unsigned long *) 0x00000028) = 0xe24ff004
188 set $pc = 0x00000000
189 stepi 0xb
190 end
191
192 #
193 #       Enable the PCI clock (which is on GPIO14)
194 #
195 define pci-clock
196 set *((unsigned long *) 0xc8004004) = 0x00003fff
197 set *((unsigned long *) 0xc8004018) = 0x000001ff
198 set *((unsigned long *) 0xc8004000) = 0x00004000
199 end
200
201 #
202 #       Configure the flash region to be writable.
203 #
204 define writable
205 monitor long 0xc4000000 = 0xbfff3c43
206 end
207
208
209 #
210 #       Set debugger into big endian mode.
211 #
212 define gdb-big
213 set endian big
214 monitor endian big
215 end
216
217 #
218 #       FLASH writing code (8bit functions)
219 #
220 define flash8-erase1
221 monitor char 0x50000000 = 0x20
222 monitor char 0x50000000 = 0xd0
223 shell sleep 1
224 monitor char 0x50000000 = 0xff
225 end
226
227 define flash8-erase2
228 monitor char 0x50020000 = 0x20
229 monitor char 0x50020000 = 0xd0
230 shell sleep 1
231 monitor char 0x50020000 = 0xff
232 end
233
234 define flash8-unlock1
235 monitor char 0x50000000 = 0x60
236 monitor char 0x50000000 = 0xd0
237 shell sleep 1
238 monitor char 0x50000000 = 0xff
239 end
240
241 define flash8-unlock2
242 monitor char 0x50020000 = 0x60
243 monitor char 0x50020000 = 0xd0
244 shell sleep 1
245 monitor char 0x50020000 = 0xff
246 end
247
248 define flash8-program
249 set *((unsigned long *) 0x00100000) = 0xe3a01205
250 set *((unsigned long *) 0x00100004) = 0xe3a02040
251 set *((unsigned long *) 0x00100008) = 0xe3a03080
252 set *((unsigned long *) 0x0010000c) = 0xe3a040ff
253 set *((unsigned long *) 0x00100010) = 0xe3a05000
254 set *((unsigned long *) 0x00100014) = 0xe3a06701
255 set *((unsigned long *) 0x00100018) = 0xe5c12000
256 set *((unsigned long *) 0x0010001c) = 0xe5d57000
257 set *((unsigned long *) 0x00100020) = 0xe5c17000
258 set *((unsigned long *) 0x00100024) = 0xe5d17000
259 set *((unsigned long *) 0x00100028) = 0xe1170003
260 set *((unsigned long *) 0x0010002c) = 0x0afffffc
261 set *((unsigned long *) 0x00100030) = 0xe5c14000
262 set *((unsigned long *) 0x00100034) = 0xe2811001
263 set *((unsigned long *) 0x00100038) = 0xe2855001
264 set *((unsigned long *) 0x0010003c) = 0xe1550006
265 set *((unsigned long *) 0x00100040) = 0x1afffff4
266 set *((unsigned long *) 0x00100044) = 0xe1a00000
267 set *((unsigned long *) 0x00100048) = 0xe1a00000
268 set *((unsigned long *) 0x0010004c) = 0xeafffffe
269 set $pc = 0x00100000
270 end
271
272 define flash8-redboot
273 mem-init
274 mem-switch
275 writable
276 flash8-unlock1
277 flash8-erase1
278 flash8-unlock2
279 flash8-erase2
280 load boot/redboot/images/redboot-swap.elf
281 flash8-program
282 c
283 end
284
285 define flash8-boot
286 mem-init
287 mem-switch
288 writable
289 flash8-unlock1
290 flash8-erase1
291 load boot/boot-swap.elf
292 mem-setmac
293 mem-setargs
294 flash8-program
295 c
296 end
297
298
299 #
300 #       Set MAC addresses in the appropriate place. Makes it easier
301 #       for redboot to work right...
302 #
303 define mem-setmac
304 set *((unsigned char *) 0x1c000) = 0x00
305 set *((unsigned char *) 0x1c001) = 0xcf
306 set *((unsigned char *) 0x1c002) = 0xd0
307 set *((unsigned char *) 0x1c003) = 0x00
308 set *((unsigned char *) 0x1c004) = 0x00
309 set *((unsigned char *) 0x1c005) = 0x00
310 set *((unsigned char *) 0x1c006) = 0x01
311 set *((unsigned char *) 0x1c007) = 0x00
312 end
313
314 define mem-setargs
315 set *((unsigned char *) 0x1c023) = 'c'
316 set *((unsigned char *) 0x1c022) = 'o'
317 set *((unsigned char *) 0x1c021) = 'n'
318 set *((unsigned char *) 0x1c020) = 's'
319 set *((unsigned char *) 0x1c027) = 'o'
320 set *((unsigned char *) 0x1c026) = 'l'
321 set *((unsigned char *) 0x1c025) = 'e'
322 set *((unsigned char *) 0x1c024) = '='
323 set *((unsigned char *) 0x1c02b) = 't'
324 set *((unsigned char *) 0x1c02a) = 't'
325 set *((unsigned char *) 0x1c029) = 'y'
326 set *((unsigned char *) 0x1c028) = 'S'
327 set *((unsigned char *) 0x1c02f) = '0'
328 set *((unsigned char *) 0x1c02e) = ','
329 set *((unsigned char *) 0x1c02d) = '1'
330 set *((unsigned char *) 0x1c02c) = '1'
331 set *((unsigned char *) 0x1c033) = '5'
332 set *((unsigned char *) 0x1c032) = '2'
333 set *((unsigned char *) 0x1c031) = '0'
334 set *((unsigned char *) 0x1c030) = '0'
335 set *((unsigned char *) 0x1c037) = 0
336 set *((unsigned char *) 0x1c036) = 0
337 set *((unsigned char *) 0x1c035) = 0
338 set *((unsigned char *) 0x1c034) = 0
339 end
340
341
342 #
343 #       Startup commands...
344 #
345 set output-radix 16
346 set input-radix 16
347
348 target remote localhost:8888
349
350 monitor reset
351
352 set print pretty
353 set print asm-demangle
354 display/i $pc
355