1 /*
2 * Copyright (c) 2017, Texas Instruments Incorporated
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
34 var ctt_registers = [
35 0x44df0000,
36 0x44df0004,
37 0x44df0008,
38 0x44df000c,
39 0x44df0010,
40 0x44df0300,
41 0x44df0304,
42 0x44df0314,
43 0x44df0324,
44 0x44df0400,
45 0x44df0404,
46 0x44df0410,
47 0x44df0414,
48 0x44df0424,
49 0x44df0548,
50 0x44df0648,
51 0x44df0700,
52 0x44df0704,
53 0x44df0724,
54 0x44df0800,
55 0x44df0804,
56 0x44df0810,
57 0x44df0814,
58 0x44df0824,
59 0x44df082c,
60 0x44df0834,
61 0x44df083c,
62 0x44df0844,
63 0x44df084c,
64 0x44df0854,
65 0x44df085c,
66 0x44df0864,
67 0x44df086c,
68 0x44df0874,
69 0x44df087c,
70 0x44df0884,
71 0x44df088c,
72 0x44df0894,
73 0x44df089c,
74 0x44df08a4,
75 0x44df08ac,
76 0x44df0a24,
77 0x44df0a2c,
78 0x44df0a34,
79 0x44df0a3c,
80 0x44df0a44,
81 0x44df0a4c,
82 0x44df0a5c,
83 0x44df0a64,
84 0x44df0a6c,
85 0x44df0b24,
86 0x44df0c24,
87 0x44df0c2c,
88 0x44df0c34,
89 0x44df0c3c,
90 0x44df0c44,
91 0x44df0c4c,
92 0x44df0c54,
93 0x44df0c5c,
94 0x44df0c64,
95 0x44df0c6c,
96 0x44df0c74,
97 0x44df0c7c,
98 0x44df0c84,
99 0x44df0c8c,
100 0x44df0c94,
101 0x44df0c9c,
102 0x44df0ca4,
103 0x44df0cac,
104 0x44df0cb4,
105 0x44df0cbc,
106 0x44df0cc4,
107 0x44df0ccc,
108 0x44df0cd4,
109 0x44df0ce4,
110 0x44df0cec,
111 0x44df0cf4,
112 0x44df0d04,
113 0x44df0d0c,
114 0x44df0d14,
115 0x44df0d1c,
116 0x44df0d24,
117 0x44df0d2c,
118 0x44df0d34,
119 0x44df0d3c,
120 0x44df0d44,
121 0x44df0d4c,
122 0x44df0d54,
123 0x44df0d5c,
124 0x44df0d64,
125 0x44df0d6c,
126 0x44df0d74,
127 0x44df0d7c,
128 0x44df0d84,
129 0x44df0d8c,
130 0x44df0d94,
131 0x44df0d9c,
132 0x44df0da4,
133 0x44df0dac,
134 0x44df0db4,
135 0x44df0dbc,
136 0x44df0dc4,
137 0x44df0f24,
138 0x44df0f2c,
139 0x44df0f34,
140 0x44df0f3c,
141 0x44df1024,
142 0x44df1224,
143 0x44df1324,
144 0x44df1424,
145 0x44df2020,
146 0x44df2024,
147 0x44df2034,
148 0x44df2134,
149 0x44df2234,
150 0x44df223c,
151 0x44df2244,
152 0x44df2334,
153 0x44df233c,
154 0x44df2344,
155 0x44df234c,
156 0x44df2354,
157 0x44df235c,
158 0x44df2364,
159 0x44df236c,
160 0x44df237c,
161 0x44df2800,
162 0x44df2820,
163 0x44df2900,
164 0x44df2920,
165 0x44df2a00,
166 0x44df2a20,
167 0x44df2a28,
168 0x44df2a30,
169 0x44df2a38,
170 0x44df2a40,
171 0x44df2a48,
172 0x44df2b00,
173 0x44df2b20,
174 0x44df2b28,
175 0x44df2b30,
176 0x44df2b38,
177 0x44df2b40,
178 0x44df2b48,
179 0x44df2b50,
180 0x44df2b58,
181 0x44df2b60,
182 0x44df2b68,
183 0x44df2d20,
184 0x44df2d24,
185 0x44df2d2c,
186 0x44df2d38,
187 0x44df2d3c,
188 0x44df2d40,
189 0x44df2d48,
190 0x44df2d4c,
191 0x44df2d60,
192 0x44df2d64,
193 0x44df2d6c,
194 0x44df2d70,
195 0x44df2d88,
196 0x44df2d8c,
197 0x44df2da0,
198 0x44df2da4,
199 0x44df2dac,
200 0x44df2db0,
201 0x44df2db8,
202 0x44df2dc8,
203 0x44df2dcc,
204 0x44df2de0,
205 0x44df2de4,
206 0x44df2dec,
207 0x44df2df0,
208 0x44df2e04,
209 0x44df2e08,
210 0x44df2e0c,
211 0x44df2e14,
212 0x44df2e20,
213 0x44df2e24,
214 0x44df2e2c,
215 0x44df2e30,
216 0x44df2e48,
217 0x44df2e4c,
218 0x44df2e60,
219 0x44df2e64,
220 0x44df2e6c,
221 0x44df2e70,
222 0x44df2e84,
223 0x44df2e88,
224 0x44df2e8c,
225 0x44df2fa0,
226 0x44df2fa4,
227 0x44df4000,
228 0x44df4004,
229 0x44df4008,
230 0x44df400c,
231 0x44df4010,
232 0x44df4014,
233 0x44df4018,
234 0x44df401c,
235 0x44df4020,
236 0x44df4024,
237 0x44df4028,
238 0x44df4030,
239 0x44df4100,
240 0x44df4104,
241 0x44df4108,
242 0x44df4200,
243 0x44df4204,
244 0x44df4208,
245 0x44df420c,
246 0x44df4210,
247 0x44df4214,
248 0x44df4218,
249 0x44df421c,
250 0x44df4220,
251 0x44df4224,
252 0x44df4228,
253 0x44df422c,
254 0x44df4230,
255 0x44df4234,
256 0x44df4238,
257 0x44df423c,
258 0x44df4240,
259 0x44df4244,
260 0x44df4248,
261 0x44df424c,
262 0x44df4250,
263 0x44df4254,
264 0x44df4258,
265 0x44df425c,
266 0x44df4260,
267 0x44df8300,
268 0x44df8320,
269 0x44df8400,
270 0x44df8420,
271 0x44df8500,
272 0x44df8520,
273 0x44df8600,
274 0x44df8620,
275 0x44df8700,
276 0x44df8720,
277 0x44df8800,
278 0x44df8820,
279 0x44df8828,
280 0x44df8830,
281 0x44df8838,
282 0x44df8840,
283 0x44df8848,
284 0x44df8850,
285 0x44df8858,
286 0x44df8860,
287 0x44df8868,
288 0x44df8870,
289 0x44df8878,
290 0x44df8880,
291 0x44df8888,
292 0x44df8890,
293 0x44df8898,
294 0x44df88a0,
295 0x44df88a8,
296 0x44df8a00,
297 0x44df8a20,
298 0x44df8a28,
299 0x44df8a30,
300 0x44df8a38,
301 0x44df8a40,
302 0x44df8a48,
303 0x44df8a58,
304 0x44df8a60,
305 0x44df8a68,
306 0x44df8b00,
307 0x44df8b20,
308 0x44df8c00,
309 0x44df8c20,
310 0x44df8c28,
311 0x44df8c30,
312 0x44df8c38,
313 0x44df8c40,
314 0x44df8c48,
315 0x44df8c50,
316 0x44df8c58,
317 0x44df8c60,
318 0x44df8c68,
319 0x44df8c70,
320 0x44df8c78,
321 0x44df8c80,
322 0x44df8c88,
323 0x44df8c90,
324 0x44df8c98,
325 0x44df8ca0,
326 0x44df8ca8,
327 0x44df8cb0,
328 0x44df8cb8,
329 0x44df8cc0,
330 0x44df8cc8,
331 0x44df8cd0,
332 0x44df8ce0,
333 0x44df8ce8,
334 0x44df8cf0,
335 0x44df8d00,
336 0x44df8d08,
337 0x44df8d10,
338 0x44df8d18,
339 0x44df8d20,
340 0x44df8d28,
341 0x44df8d30,
342 0x44df8d38,
343 0x44df8d40,
344 0x44df8d48,
345 0x44df8d50,
346 0x44df8d58,
347 0x44df8d60,
348 0x44df8d68,
349 0x44df8d70,
350 0x44df8d78,
351 0x44df8d80,
352 0x44df8d88,
353 0x44df8d90,
354 0x44df8d98,
355 0x44df8da0,
356 0x44df8da8,
357 0x44df8db0,
358 0x44df8db8,
359 0x44df8dc0,
360 0x44df8f00,
361 0x44df8f20,
362 0x44df8f28,
363 0x44df8f30,
364 0x44df8f38,
365 0x44df9000,
366 0x44df9020,
367 0x44df9200,
368 0x44df9220,
369 0x44df9300,
370 0x44df9320,
371 0x44df9400,
372 0x44df9420,
373 0x44e10040,
374 0x44e101bc,
375 0x44e10444,
376 0x44e3e054];
378 debugSessionDAP = ds.openSession("*","CS_DAP_M3");
379 debugSessionDAP.target.connect();
381 // Check connection by reading a location known to be non-zero (PRCM_CM_WKUP_DBGSS_CLKCTRL)
382 value = debugSessionDAP.memory.readWord(0,0x44df2820,false);
383 if (value == 0) {
384 // Use DebugSS instead
385 debugSessionDAP.target.disconnect();
386 debugSessionDAP = ds.openSession("*","CS_DAP_DebugSS");
387 debugSessionDAP.target.connect();
388 value = debugSessionDAP.memory.readWord(0,0x44df2820,false);
389 if (value == 0) {
390 print("ERROR: Trouble reading sane values from memory.");
391 print("PRCM_CM_WKUP_DBGSS_CLKCTRL = 0x" + d2h(value));
392 }
393 }
396 //Build a filename that includes date/time
397 var today = new Date();
398 var year4digit = today.getFullYear();
399 var month2digit = ("0" + (today.getMonth()+1)).slice(-2);
400 var day2digit = ("0" + today.getDate()).slice(-2);
401 var hour2digit = ("0" + today.getHours()).slice(-2);
402 var minutes2digit = ("0" + today.getMinutes()).slice(-2);
403 var seconds2digit = ("0" + today.getSeconds()).slice(-2);
404 var filename_date = '_' + year4digit + '-' + month2digit + '-' + day2digit + '_' + hour2digit + minutes2digit + seconds2digit;
405 var userHomeFolder = System.getProperty("user.home");
406 var filename = userHomeFolder + '/Desktop/' + 'am43xx-ctt' + filename_date + '.rd1';
408 file = new java.io.FileWriter(filename);
409 file.write("DeviceName AM43xx_SR1.x\n");
411 // helper function to create 8-digit hex numbers in ascii format
412 function d2h(d) {return ("00000000" + (+d).toString(16)).slice(-8);}
414 // read CTT data from physical addresses
415 for(i=0; i<ctt_registers.length; i++)
416 {
417 try {
418 value = debugSessionDAP.memory.readWord(0,ctt_registers[i],false);
419 value_string = d2h(value);
420 file.write('0x' + ("0000" + ctt_registers[i].toString(16)).slice(-8) + " 0x" + value_string + "\n");
421 } catch (ex) {
422 print("\n Trouble reading address 0x" + d2h(ctt_registers[i]) + ". Skipping register.\n");
423 if (ctt_registers[i] == 0x44e3e054) print(" -> Expected if rtc_porz is grounded.\n");
424 }
425 }
426 print("Data collection complete.");
428 file.close();
429 debugSessionDAP.target.disconnect();
430 print("Created file " + filename);