-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFlash.dev
More file actions
236 lines (224 loc) · 7.52 KB
/
Flash.dev
File metadata and controls
236 lines (224 loc) · 7.52 KB
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
// File: Flash.dev
// '//' is a comment until the end of the line, not allowed in cycles yet!
// try '(gdb) set mpcbdm_verbose 0x40' for flash configuration parsing output
// then '(gdb) mp flash conf 0x40000000 2 AM29LV160DB' for 2 16 bit devices
// this .device section defines a available device name
.device AM29LV160DB
{
.size 2M //size in bytes for one device, K and M suffixes supported
.width 16 //width in bits for one device
.sector AM29LV160DB //name of following .sector section to be used with this device
.idoffset 12 //shift first entry of .sector n bits to left for ID ADR
.algorithm AMD4 //name of following .algorithm section to be used with this device
}
.device AM29LV800BT
{
.size 1M //size in bytes for one device, K and M suffixes supported
.width 16 //width in bits for one device
.sector AM29LV800BT //name of following .sector section to be used with this device
.idoffset 12 //shift first entry of .sector n bits to left for ID ADR
.algorithm AMD4 //name of following .algorithm section to be used with this device
}
.device MX29LV800TMC
{
.size 1M //size in bytes for one device, K and M suffixes supported
.width 16 //width in bits for one device
.sector AM29LV800BT //name of following .sector section to be used with this device
.idoffset 12 //shift first entry of .sector n bits to left for ID ADR
.algorithm TMC //name of following .algorithm section to be used with this device
}
// The .sector section is referenced from the above .device section
// and describes the internal device sector structure
// ID , start , stop
.sector AM29LV160DB
{
0x00,0x00000,0x01fff,
0x02,0x02000,0x02fff,
0x03,0x03000,0x03fff,
0x04,0x04000,0x07fff,
0x08,0x08000,0x0ffff,
0x10,0x10000,0x17fff,
0x18,0x18000,0x1ffff,
0x20,0x20000,0x27fff,
0x28,0x28000,0x2ffff,
0x30,0x30000,0x37fff,
0x38,0x38000,0x3ffff,
0x40,0x40000,0x47fff,
0x48,0x48000,0x4ffff,
0x50,0x50000,0x57fff,
0x58,0x58000,0x5ffff,
0x60,0x60000,0x67fff,
0x68,0x68000,0x6ffff,
0x70,0x70000,0x77fff,
0x78,0x78000,0x7ffff,
0x80,0x80000,0x87fff,
0x88,0x88000,0x8ffff,
0x90,0x90000,0x97fff,
0x98,0x98000,0x9ffff,
0xa0,0xa0000,0xa7fff,
0xa8,0xa8000,0xaffff,
0xb0,0xb0000,0xb7fff,
0xb8,0xb8000,0xbffff,
0xc0,0xc0000,0xc7fff,
0xc8,0xc8000,0xcffff,
0xd0,0xd0000,0xd7fff,
0xd8,0xd8000,0xdffff,
0xe0,0xe0000,0xe7fff,
0xe8,0xe8000,0xeffff,
0xf0,0xf0000,0xf7fff,
0xf8,0xf8000,0xfffff
}
.sector AM29LV800BT
{
0x00,0x00000,0x07fff,
0x08,0x08000,0x0ffff,
0x10,0x10000,0x17fff,
0x18,0x18000,0x1ffff,
0x20,0x20000,0x27fff,
0x28,0x28000,0x2ffff,
0x30,0x30000,0x37fff,
0x38,0x38000,0x3ffff,
0x40,0x40000,0x47fff,
0x48,0x48000,0x4ffff,
0x50,0x50000,0x57fff,
0x58,0x58000,0x5ffff,
0x60,0x60000,0x67fff,
0x68,0x68000,0x6ffff,
0x70,0x70000,0x77fff,
0X74,0x78000,0x7bfff,
0x75,0x7c000,0x7cfff,
0x76,0x7d000,0x7dfff,
0x7a,0x7e000,0x7ffff
}
// The .algorithm section is referenced from the above .device section
// and defines the programming method for the device.
// So far there are five sequences defined: .reset for getting the device back into
// read array mode, .ident for testing device presense, .write to program one word
// .erase for one sector erasing, .clear for chip wide erasing.
// .cfast defines register preloading for the fast target sided flashing routines
// .fast references the machine code to be used
// each sequence can be composed out of one or more cycles.
// There are five cycle types (operations) so far :
// Write (w) Read (r) Compare (r) Toggle (t) Poll (p) .
// Each cycle takes an ADR and a data word tupel: 'w0x0:0xf0'
// ADR can be immediate (e.g. 0x0) or actual ADR %A, both will be automaticaly adjusted
// for device offset and width
// Data can be immediate (e.g. 0x) or actual data word %D,
// both will be expanded to data bus width.
// Read generates a warning only if results differ, while Compare will exit with
// failure status.
// Toggle reads from address, ANDs the result with the given mask and waits
// until the result stabilizes, as Poll waits for a zero result.
.algorithm AMD4
{
.reset w0x0:0xf0
.ident w0x555:0x00aa, w0x2aa:0x0055, w0x555:0x90,
c0x000:0x0001, c0x001:0x2249, w0x000:0xf0
.write w0x555:0xaa, w0x2aa:0x55, w0x555:0xa0, w%A:%D, t%A:0x0040, r%A:%D
.erase w0x555:0xaa, w0x2aa:0x55, w0x555:0x80,
w0x555:0xaa, w0x2aa:0x55, w%I:0x30, t%A:0x0040, r%A:0xffff
.clear w0x555:0xaa, w0x2aa:0x55, w0x555:0x80,
w0x555:0xaa, w0x2aa:0x55, w0x555:0x10, t%A:0x0040, r%A:0xffff
// .cfast w0x555:0xaa, w0x2aa:0x55, w0x555:0xa0, w%A:%D
.cfast w0x555:0xaa, w0x2aa:0x55, w0x555:0xa0
// preload r1 r2 r3 r4 r5 r6
.fast AMD4 // use .fast<bus_width> AMD4 section for fast flashing
}
.algorithm TMC
{
.reset w0x0:0xf0
.ident w0x555:0x00aa, w0x2aa:0x0055, w0x555:0x90,
c0x000:0x00c2, c0x001:0x22da, w0x000:0xf0
.write w0x555:0xaa, w0x2aa:0x55, w0x555:0xa0, w%A:%D, t%A:0x0040, r%A:%D
.erase w0x555:0xaa, w0x2aa:0x55, w0x555:0x80,
w0x555:0xaa, w0x2aa:0x55, w%I:0x30, t%A:0x0040, r%A:0xffff
.clear w0x555:0xaa, w0x2aa:0x55, w0x555:0x80,
w0x555:0xaa, w0x2aa:0x55, w0x555:0x10, t%A:0x0040, r%A:0xffff
// .cfast w0x555:0xaa, w0x2aa:0x55, w0x555:0xa0, w%A:%D
.cfast w0x555:0xaa, w0x2aa:0x55, w0x555:0xa0
// preload r1 r2 r3 r4 r5 r6
.fast AMD4 // use .fast<bus_width> AMD4 section for fast flashing
}
// the .fast sections contain target machine code to do a CTR based
// flash program loop. r28 points to the new data buffer -4 , r29 points
// to the write address -4, r1..rn get preloaded with .cfast values.
// SEI is used as return from target sub routine
// (some kind of distributed computing ;-)
// 32 bit flash ppc subroutine
.fast32 AMD4
{
// <flash32>:
0x877c0004, // lwzu r27,4(r28)
0x875d0004, // lwzu r26,4(r29)
0x90410000, // stw r2,0(r1)
0x90830000, // stw r4,0(r3)
0x90c50000, // stw r6,0(r5)
0x937d0000, // stw r27,0(r29)
//<toggle32>:
0x7f59d378, // mr r25,r26
0x7c0006ac, // eieio
0x835d0000, // lwz r26,0(r29)
0x7c1bd040, // cmplw r27,r26
0x41820018, // beq <cont32>
0x7f59ca79, // xor. r25,r26,r25
0x4082ffe8, // bne <toggle32>
0x835d0000, // lwz r26,0(r29)
0x7c1bd040, // cmplw r27,r26
0x40820008, // bne <exit32>
//<cont32>:
0x4200ffc0, // bdnz <flash32>
//<exit32>:
0x00000000 // .long 0x0
}
/* 16 bit flash ppc subroutine */
.fast16 AMD4
{
//<flash16>:
0xa77c0002, // lhzu r27,2(r28)
0xa75d0002, // lhzu r26,2(r29)
0xb0410000, // sth r2,0(r1)
0xb0830000, // sth r4,0(r3)
0xb0c50000, // sth r6,0(r5)
0xb37d0000, // sth r27,0(r29)
//<toggle16>:
0x7f59d378, // mr r25,r26
0x7c0006ac, // eieio
0xa35d0000, // lhz r26,0(r29)
0x7c1bd040, // cmplw r27,r26
0x41820018, // beq <cont16>
0x7f59ca79, // xor. r25,r26,r25
0x4082ffe8, // bne <toggle16>
0xa35d0000, // lhz r26,0(r29)
0x7c1bd040, // cmplw r27,r26
0x40820008, // bne <exit16>
//<cont16>:
0x4200ffc0, // bdnz <flash16>
//<exit16>:
0x00000000 // .long 0x0
}
/* 8 bit flash ppc subroutine */
.fast8 AMD4
{
//<flash8>:
0x8f7c0001, // lbzu r27,1(r28)
0x8f5d0001, // lbzu r26,1(r29)
0x98410000, // stb r2,0(r1)
0x98830000, // stb r4,0(r3)
0x98c50000, // stb r6,0(r5)
0x9b7d0000, // stb r27,0(r29)
//<toggle8>:
0x7f59d378, // mr r25,r26
0x7c0006ac, // eieio
0x8b5d0000, // lbz r26,0(r29)
0x7c1bd040, // cmplw r27,r26
0x4182ff88, // beq <cont32>
0x7f59ca79, // xor. r25,r26,r25
0x4082ffe8, // bne <toggle8>
0x8b5d0000, // lbz r26,0(r29)
0x7c1bd040, // cmplw r27,r26
0x40820008, // bne <exit8>
//<cont8>:
0x4200ffc0, // bdnz <flash8>
//<exit8>:
0x00000000 // .long 0x0
}