1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
target remote | m68k-bdm-gdbserver pipe -B -m cf5249 /dev/tblcf1

set $mbar = 0x40000001
set $mbar2 = 0x80000001
set $mbar = 0x40000001
set $mbar2 = 0x80000001


####################
# define addresses #
####################

# MBAR address space
set $rsr   = $mbar - 1 + 0x00
set $sypcr = $mbar - 1 + 0x01
set $swivr = $mbar - 1 + 0x02
set $swsr  = $mbar - 1 + 0x03
set $mpark = $mbar - 1 + 0x0C

set $ipr   = $mbar - 1 + 0x40
set $imr   = $mbar - 1 + 0x44
set $icr0  = $mbar - 1 + 0x4C
set $icr1  = $mbar - 1 + 0x4D
set $icr2  = $mbar - 1 + 0x4E
set $icr3  = $mbar - 1 + 0x4F
set $icr4  = $mbar - 1 + 0x50
set $icr5  = $mbar - 1 + 0x51
set $icr6  = $mbar - 1 + 0x52
set $icr7  = $mbar - 1 + 0x53
set $icr8  = $mbar - 1 + 0x54
set $icr9  = $mbar - 1 + 0x55
set $icr10 = $mbar - 1 + 0x56
set $icr11 = $mbar - 1 + 0x57

set $csar0 = $mbar - 1 + 0x80
set $csmr0 = $mbar - 1 + 0x84
set $cscr0 = $mbar - 1 + 0x8A
set $csar1 = $mbar - 1 + 0x8C
set $csmr1 = $mbar - 1 + 0x90
set $cscr1 = $mbar - 1 + 0x96
set $csar2 = $mbar - 1 + 0x98
set $csmr2 = $mbar - 1 + 0x9C
set $cscr2 = $mbar - 1 + 0xA2
set $csar3 = $mbar - 1 + 0xA4
set $csmr3 = $mbar - 1 + 0xA8
set $cscr3 = $mbar - 1 + 0xAC

set $dcr   = $mbar - 1 + 0x100
set $dacr0 = $mbar - 1 + 0x108
set $dmr0  = $mbar - 1 + 0x10C
set $dacr1 = $mbar - 1 + 0x110
set $dmr1  = $mbar - 1 + 0x114

set $tmr0  = $mbar - 1 + 0x140
set $trr0  = $mbar - 1 + 0x144
set $tcr0  = $mbar - 1 + 0x148
set $tcn0  = $mbar - 1 + 0x14C
set $ter0  = $mbar - 1 + 0x150

set $tmr1  = $mbar - 1 + 0x180
set $trr1  = $mbar - 1 + 0x184
set $tcr1  = $mbar - 1 + 0x188
set $tcn1  = $mbar - 1 + 0x18C
set $ter1  = $mbar - 1 + 0x190

set $umr10  = $mbar - 1 + 0x1C0
set $umr20  = $umr10
set $usr0   = $mbar - 1 + 0x1C4
set $ucsr0  = $usr0
set $ucr0   = $mbar - 1 + 0x1C8
set $urb0   = $mbar - 1 + 0x1CC
set $utb0   = $urb0
set $uipcr0 = $mbar - 1 + 0x1D0
set $uacr0  = $uipcr0
set $uisr0  = $mbar - 1 + 0x1D4
set $uimr0  = $uisr0
set $ubg10  = $mbar - 1 + 0x1D8
set $ubg20  = $mbar - 1 + 0x1DC
set $uivr0  = $mbar - 1 + 0x1F0
set $uip0   = $mbar - 1 + 0x1F4
set $uop10  = $mbar - 1 + 0x1F8
set $uop00  = $mbar - 1 + 0x1FC

set $umr11  = $mbar - 1 + 0x200
set $umr21  = $umr11
set $usr1   = $mbar - 1 + 0x204
set $ucsr1  = $usr1
set $ucr1   = $mbar - 1 + 0x208
set $urb1   = $mbar - 1 + 0x20C
set $utb1   = $urb1
set $uipcr1 = $mbar - 1 + 0x210
set $uacr1  = $uipcr1
set $uisr1  = $mbar - 1 + 0x214
set $uimr1  = $uisr1
set $ubg11  = $mbar - 1 + 0x218
set $ubg21  = $mbar - 1 + 0x21C
set $uivr1  = $mbar - 1 + 0x230
set $uip1   = $mbar - 1 + 0x234
set $uop11  = $mbar - 1 + 0x238
set $uop01  = $mbar - 1 + 0x23C

set $madr   = $mbar - 1 + 0x280
set $mfdr   = $mbar - 1 + 0x284
set $mbcr   = $mbar - 1 + 0x288
set $mbsr   = $mbar - 1 + 0x28C
set $mbdr   = $mbar - 1 + 0x290

set $sar0   = $mbar - 1 + 0x300
set $dar0   = $mbar - 1 + 0x304
set $dcr0   = $mbar - 1 + 0x308
set $bcr0   = $mbar - 1 + 0x30C
set $dsr0   = $mbar - 1 + 0x310
set $divr0  = $mbar - 1 + 0x314

set $sar1   = $mbar - 1 + 0x340
set $dar1   = $mbar - 1 + 0x344
set $dcr1   = $mbar - 1 + 0x348
set $bcr1   = $mbar - 1 + 0x34C
set $dsr1   = $mbar - 1 + 0x350
set $divr1  = $mbar - 1 + 0x354

set $sar2   = $mbar - 1 + 0x380
set $dar2   = $mbar - 1 + 0x384
set $dcr2   = $mbar - 1 + 0x388
set $bcr2   = $mbar - 1 + 0x38C
set $dsr2   = $mbar - 1 + 0x390
set $divr2  = $mbar - 1 + 0x394

set $sar3   = $mbar - 1 + 0x3C0
set $dar3   = $mbar - 1 + 0x3C4
set $dcr3   = $mbar - 1 + 0x3C8
set $bcr3   = $mbar - 1 + 0x3CC
set $dsr3   = $mbar - 1 + 0x3D0
set $divr3  = $mbar - 1 + 0x3D4

set $qspiqmr   = $mbar - 1 + 0x400
set $qspiqdlyr = $mbar - 1 + 0x404
set $qspiqwr   = $mbar - 1 + 0x408
set $qspiqir   = $mbar - 1 + 0x40C
set $qspiqar   = $mbar - 1 + 0x410
set $qspiqdr   = $mbar - 1 + 0x414

# MBAR2 address space
set $gpioread        = $mbar2 - 1 + 0x00
set $gpioout         = $mbar2 - 1 + 0x04
set $gpioenable      = $mbar2 - 1 + 0x08
set $gpiofunction    = $mbar2 - 1 + 0x0C
set $iis1config       = $mbar2 - 1 + 0x10
set $iis2config       = $mbar2 - 1 + 0x14
set $iis3config       = $mbar2 - 1 + 0x18
set $iis4config       = $mbar2 - 1 + 0x1C
set $ebu1config       = $mbar2 - 1 + 0x20
set $ebu1rcvcchannel1 = $mbar2 - 1 + 0x24
set $ebutxcchannel1   = $mbar2 - 1 + 0x28
set $ebutxcchannel2   = $mbar2 - 1 + 0x2C
set $dataincontrol    = $mbar2 - 1 + 0x30
set $pdir1l          = $mbar2 - 1 + 0x34
set $pdor1l          = $pdir1l
set $pdir3l          = $mbar2 - 1 + 0x44
set $pdor1r          = $pdir3l
set $pdir1r          = $mbar2 - 1 + 0x54
set $pdor2l          = $pdir1r
set $pdir3r          = $mbar2 - 1 + 0x64
set $pdor2r          = $pdir3r
set $pdir2            = $mbar2 - 1 + 0x74
set $pdor3            = $pdir2
set $uchanneltransmit = $mbar2 - 1 + 0x84
set $u1channelreceive = $mbar2 - 1 + 0x88
set $q1channelreceive = $mbar2 - 1 + 0x8C
set $cdtextcontrol    = $mbar2 - 1 + 0x92
set $interrupten      = $mbar2 - 1 + 0x94
set $interruptclear   = $mbar2 - 1 + 0x98
set $interruptstat    = $interruptclear
set $dmaconfig        = $mbar2 - 1 + 0x9F
set $phaseconfig      = $mbar2 - 1 + 0xA3
set $xtrim            = $mbar2 - 1 + 0xA6
set $freqmeas         = $mbar2 - 1 + 0xA8

set $gpio1read        = $mbar2 - 1 + 0xB0
set $gpio1out         = $mbar2 - 1 + 0xB4
set $gpio1enable      = $mbar2 - 1 + 0xB8
set $gpio1function    = $mbar2 - 1 + 0xBC

set $gpiointstat    = $mbar2 - 1 + 0xC0
set $gpiointclear   = $gpiointstat
set $gpiointenable  = $mbar2 - 1 + 0xC4

set $blockcontrol     = $mbar2 - 1 + 0xCA
set $audioglob        = $mbar2 - 1 + 0xCE
set $ebu2config       = $mbar2 - 1 + 0xD0
set $ebu2rcvcchannel1 = $mbar2 - 1 + 0xD4
set $u2channelreceive = $mbar2 - 1 + 0xD8
set $q2channelreceive = $mbar2 - 1 + 0xDC

set $interruptstat3   = $mbar2 - 1 + 0xE0
set $interruptclear3  = $interruptstat3
set $interrupten3     = $mbar2 - 1 + 0xE4

set $intpri1          = $mbar2 - 1 + 0x140
set $intpri2          = $mbar2 - 1 + 0x144
set $intpri3          = $mbar2 - 1 + 0x148
set $intpri4          = $mbar2 - 1 + 0x14C
set $intpri5          = $mbar2 - 1 + 0x150
set $intpri6          = $mbar2 - 1 + 0x154
set $intpri7          = $mbar2 - 1 + 0x158
set $intpri8          = $mbar2 - 1 + 0x15C

set $spurvec          = $mbar2 - 1 + 0x167
set $intbase          = $mbar2 - 1 + 0x16B

set $pllcontrol       = $mbar2 - 1 + 0x180

set $dmaroute         = $mbar2 - 1 + 0x188
set $ideconfig1       = $mbar2 - 1 + 0x18C
set $ideconfig2       = $mbar2 - 1 + 0x190
set $iperroradr       = $mbar2 - 1 + 0x194
set $extraint         = $mbar2 - 1 + 0x198

set $adconfig         = $mbar2 - 1 + 0x402
set $advalue          = $mbar2 - 1 + 0x406

set $madr2            = $mbar2 - 1 + 0x440
set $mfdr2            = $mbar2 - 1 + 0x444
set $mbcr2            = $mbar2 - 1 + 0x448
set $mbsr2            = $mbar2 - 1 + 0x44C
set $mbdr2            = $mbar2 - 1 + 0x450

set $flashmediaconfig = $mbar2 - 1 + 0x460
set $flashmediacmd1   = $mbar2 - 1 + 0x464
set $flashmediacmd2   = $mbar2 - 1 + 0x468
set $flashmediadata1  = $mbar2 - 1 + 0x46C
set $flashmediadata2  = $mbar2 - 1 + 0x470
set $flashmediastatus = $mbar2 - 1 + 0x474
set $flashmediainten  = $mbar2 - 1 + 0x478
set $flashmediaintstat= $mbar2 - 1 + 0x47C
set $flashmediaintclear = $flashmediaintstat

#rambar0 rambar1
monitor bdm-ctl-set 0xc05 0x10000e01
monitor bdm-ctl-set 0xc04 0x10010001

#load files
load /home/wodz/rockbox-git/build/bootloader.elf
symbol-file /home/wodz/rockbox-git/build/bootloader.elf

# disable interrupts
set $sr = 0x2700
# clear rockbox cookie
set {unsigned int*}0x10017ffc = 0

# set stack pointer
set $sp = *0x10000000
set $pc = *0x10000004

# print some info
echo
printf "READY to debug rockbox bootloader\n"
printf "SP = %08x\n", $sp
printf "PC = %08x\n", $pc