remove redundant registers
[sitara-dss-files/am57xx-dss-files.git] / padconf / am57xx-padconf.dss
1 /*
2  * Copyright (c) 2019, 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  */
35 var padconf_registers_am571x_am570x = [
36         0x4A003400,
37         0x4A003404,
38         0x4A003408,
39         0x4A00340C,
40         0x4A003410,
41         0x4A003414,
42         0x4A003418,
43         0x4A00341C,
44         0x4A003420,
45         0x4A003424,
46         0x4A003428,
47         0x4A00342C,
48         0x4A003430,
49         0x4A003434,
50         0x4A003438,
51         0x4A00343C,
52         0x4A003440,
53         0x4A003444,
54         0x4A003448,
55         0x4A00344C,
56         0x4A003450,
57         0x4A003454,
58         0x4A003458,
59         0x4A00345C,
60         0x4A003460,
61         0x4A003464,
62         0x4A003468,
63         0x4A00346C,
64         0x4A003470,
65         0x4A003474,
66         0x4A003478,
67         0x4A00347C,
68         0x4A003480,
69         0x4A003484,
70         0x4A003488,
71         0x4A00348C,
72         0x4A003490,
73         0x4A003494,
74         0x4A003498,
75         0x4A00349C,
76         0x4A0034A0,
77         0x4A0034A4,
78         0x4A0034A8,
79         0x4A0034AC,
80         0x4A0034B0,
81         0x4A0034B4,
82         0x4A0034B8,
83         0x4A0034BC,
84         0x4A0034C0,
85         0x4A0034C4,
86         0x4A0034C8,
87         0x4A0034CC,
88         0x4A0034D0,
89         0x4A0034D4,
90         0x4A0034D8,
91         0x4A003554,
92         0x4A003558,
93         0x4A00355C,
94         0x4A003560,
95         0x4A003564,
96         0x4A003568,
97         0x4A00356C,
98         0x4A003570,
99         0x4A003574,
100         0x4A003578,
101         0x4A00357C,
102         0x4A003580,
103         0x4A003584,
104         0x4A003588,
105         0x4A00358C,
106         0x4A003590,
107         0x4A003594,
108         0x4A003598,
109         0x4A00359C,
110         0x4A0035A0,
111         0x4A0035A4,
112         0x4A0035A8,
113         0x4A0035AC,
114         0x4A0035B0,
115         0x4A0035B4,
116         0x4A0035B8,
117         0x4A0035BC,
118         0x4A0035C0,
119         0x4A0035C4,
120         0x4A0035C8,
121         0x4A0035CC,
122         0x4A0035D0,
123         0x4A0035D4,
124         0x4A0035D8,
125         0x4A0035DC,
126         0x4A0035E0,
127         0x4A0035E4,
128         0x4A0035E8,
129         0x4A0035EC,
130         0x4A0035F0,
131         0x4A0035F4,
132         0x4A0035F8,
133         0x4A0035FC,
134         0x4A003600,
135         0x4A003604,
136         0x4A003608,
137         0x4A00360C,
138         0x4A003610,
139         0x4A003614,
140         0x4A003618,
141         0x4A00361C,
142         0x4A003620,
143         0x4A003624,
144         0x4A003628,
145         0x4A00362C,
146         0x4A003630,
147         0x4A003634,
148         0x4A003638,
149         0x4A00363C,
150         0x4A003640,
151         0x4A003644,
152         0x4A003648,
153         0x4A00364C,
154         0x4A003650,
155         0x4A003654,
156         0x4A003658,
157         0x4A00365C,
158         0x4A003660,
159         0x4A003664,
160         0x4A003668,
161         0x4A00366C,
162         0x4A003670,
163         0x4A003674,
164         0x4A003678,
165         0x4A00367C,
166         0x4A003680,
167         0x4A003684,
168         0x4A003688,
169         0x4A00368C,
170         0x4A003690,
171         0x4A003694,
172         0x4A003698,
173         0x4A00369C,
174         0x4A0036A0,
175         0x4A0036A4,
176         0x4A0036A8,
177         0x4A0036AC,
178         0x4A0036B0,
179         0x4A0036B4,
180         0x4A0036B8,
181         0x4A0036BC,
182         0x4A0036C0,
183         0x4A0036C4,
184         0x4A0036C8,
185         0x4A0036CC,
186         0x4A0036D0,
187         0x4A0036D4,
188         0x4A0036D8,
189         0x4A0036DC,
190         0x4A0036E0,
191         0x4A0036E4,
192         0x4A0036E8,
193         0x4A0036EC,
194         0x4A0036F0,
195         0x4A0036F4,
196         0x4A0036F8,
197         0x4A0036FC,
198         0x4A003700,
199         0x4A003704,
200         0x4A003708,
201         0x4A00370C,
202         0x4A003710,
203         0x4A003714,
204         0x4A003718,
205         0x4A00371C,
206         0x4A003720,
207         0x4A003724,
208         0x4A003728,
209         0x4A00372C,
210         0x4A003730,
211         0x4A003734,
212         0x4A003738,
213         0x4A00373C,
214         0x4A003740,
215         0x4A003744,
216         0x4A003748,
217         0x4A00374C,
218         0x4A003750,
219         0x4A003754,
220         0x4A003758,
221         0x4A00375C,
222         0x4A003760,
223         0x4A003764,
224         0x4A003768,
225         0x4A00376C,
226         0x4A003770,
227         0x4A003774,
228         0x4A003778,
229         0x4A00377C,
230         0x4A003780,
231         0x4A003784,
232         0x4A003788,
233         0x4A00378C,
234         0x4A003790,
235         0x4A003794,
236         0x4A003798,
237         0x4A00379C,
238         0x4A0037A0,
239         0x4A0037A4,
240         0x4A0037A8,
241         0x4A0037AC,
242         0x4A0037B0,
243         0x4A0037B4,
244         0x4A0037B8,
245         0x4A0037BC,
246         0x4A0037C0,
247         0x4A0037C4,
248         0x4A0037C8,
249         0x4A0037CC,
250         0x4A0037D0,
251         0x4A0037D4,
252         0x4A0037E0,
253         0x4A0037E4,
254         0x4A0037E8,
255         0x4A0037EC,
256         0x4A0037F0,
257         0x4A0037F4,
258         0x4A0037F8,
259         0x4A0037FC,
260         0x4A003800,
261         0x4A003804,
262         0x4A003808,
263         0x4A00380C,
264         0x4A003818,
265         0x4A003824,
266         0x4A003828,
267         0x4A00382C,
268         0x4A003830,
269         0x4A003834,
270         0x4A003838,
271         0x4A00383C,
272         0x4A003840,
273         0x4A003844,
274         0x4A003848,
275         0x4A00384C,
276         0x4A00385C,
277         0x4A003860,
278         0x4A003864
279 ];
281 var padconf_registers_am574x_am572x = [
282         0x4A003400,
283         0x4A003404,
284         0x4A003408,
285         0x4A00340C,
286         0x4A003410,
287         0x4A003414,
288         0x4A003418,
289         0x4A00341C,
290         0x4A003420,
291         0x4A003424,
292         0x4A003428,
293         0x4A00342C,
294         0x4A003430,
295         0x4A003434,
296         0x4A003438,
297         0x4A00343C,
298         0x4A003440,
299         0x4A003444,
300         0x4A003448,
301         0x4A00344C,
302         0x4A003450,
303         0x4A003454,
304         0x4A003458,
305         0x4A00345C,
306         0x4A003460,
307         0x4A003464,
308         0x4A003468,
309         0x4A00346C,
310         0x4A003470,
311         0x4A003474,
312         0x4A003478,
313         0x4A00347C,
314         0x4A003480,
315         0x4A003484,
316         0x4A003488,
317         0x4A00348C,
318         0x4A003490,
319         0x4A003494,
320         0x4A003498,
321         0x4A00349C,
322         0x4A0034A0,
323         0x4A0034A4,
324         0x4A0034A8,
325         0x4A0034AC,
326         0x4A0034B0,
327         0x4A0034B4,
328         0x4A0034B8,
329         0x4A0034BC,
330         0x4A0034C0,
331         0x4A0034C4,
332         0x4A0034C8,
333         0x4A0034CC,
334         0x4A0034D0,
335         0x4A0034D4,
336         0x4A0034D8,
337         0x4A0034DC,
338         0x4A0034E0,
339         0x4A0034E4,
340         0x4A0034E8,
341         0x4A0034EC,
342         0x4A0034F0,
343         0x4A0034F4,
344         0x4A0034F8,
345         0x4A0034FC,
346         0x4A003500,
347         0x4A003504,
348         0x4A003508,
349         0x4A00350C,
350         0x4A003510,
351         0x4A003514,
352         0x4A003518,
353         0x4A00351C,
354         0x4A003520,
355         0x4A003524,
356         0x4A003528,
357         0x4A00352C,
358         0x4A003530,
359         0x4A003534,
360         0x4A003538,
361         0x4A00353C,
362         0x4A003540,
363         0x4A003544,
364         0x4A003548,
365         0x4A00354C,
366         0x4A003550,
367         0x4A003554,
368         0x4A003558,
369         0x4A00355C,
370         0x4A003560,
371         0x4A003564,
372         0x4A003568,
373         0x4A00356C,
374         0x4A003570,
375         0x4A003574,
376         0x4A003578,
377         0x4A00357C,
378         0x4A003580,
379         0x4A003584,
380         0x4A003588,
381         0x4A00358C,
382         0x4A003590,
383         0x4A003594,
384         0x4A003598,
385         0x4A00359C,
386         0x4A0035A0,
387         0x4A0035A4,
388         0x4A0035A8,
389         0x4A0035AC,
390         0x4A0035B0,
391         0x4A0035B4,
392         0x4A0035B8,
393         0x4A0035BC,
394         0x4A0035C0,
395         0x4A0035C4,
396         0x4A0035C8,
397         0x4A0035CC,
398         0x4A0035D0,
399         0x4A0035D4,
400         0x4A0035D8,
401         0x4A0035DC,
402         0x4A0035E0,
403         0x4A0035E4,
404         0x4A0035E8,
405         0x4A0035EC,
406         0x4A0035F0,
407         0x4A0035F4,
408         0x4A0035F8,
409         0x4A0035FC,
410         0x4A003600,
411         0x4A003604,
412         0x4A003608,
413         0x4A00360C,
414         0x4A003610,
415         0x4A003614,
416         0x4A003618,
417         0x4A00361C,
418         0x4A003620,
419         0x4A003624,
420         0x4A003628,
421         0x4A00362C,
422         0x4A003630,
423         0x4A003634,
424         0x4A003638,
425         0x4A00363C,
426         0x4A003640,
427         0x4A003644,
428         0x4A003648,
429         0x4A00364C,
430         0x4A003650,
431         0x4A003654,
432         0x4A003658,
433         0x4A00365C,
434         0x4A003660,
435         0x4A003664,
436         0x4A003668,
437         0x4A00366C,
438         0x4A003670,
439         0x4A003674,
440         0x4A003678,
441         0x4A00367C,
442         0x4A003680,
443         0x4A003684,
444         0x4A003688,
445         0x4A00368C,
446         0x4A003690,
447         0x4A003694,
448         0x4A003698,
449         0x4A00369C,
450         0x4A0036A0,
451         0x4A0036A4,
452         0x4A0036A8,
453         0x4A0036AC,
454         0x4A0036B0,
455         0x4A0036B4,
456         0x4A0036B8,
457         0x4A0036BC,
458         0x4A0036C0,
459         0x4A0036C4,
460         0x4A0036C8,
461         0x4A0036CC,
462         0x4A0036D0,
463         0x4A0036D4,
464         0x4A0036D8,
465         0x4A0036DC,
466         0x4A0036E0,
467         0x4A0036E4,
468         0x4A0036E8,
469         0x4A0036EC,
470         0x4A0036F0,
471         0x4A0036F4,
472         0x4A0036F8,
473         0x4A0036FC,
474         0x4A003700,
475         0x4A003704,
476         0x4A003708,
477         0x4A00370C,
478         0x4A003710,
479         0x4A003714,
480         0x4A003718,
481         0x4A00371C,
482         0x4A003720,
483         0x4A003724,
484         0x4A003728,
485         0x4A00372C,
486         0x4A003730,
487         0x4A003734,
488         0x4A003738,
489         0x4A00373C,
490         0x4A003740,
491         0x4A003744,
492         0x4A003748,
493         0x4A00374C,
494         0x4A003750,
495         0x4A003754,
496         0x4A003758,
497         0x4A00375C,
498         0x4A003760,
499         0x4A003764,
500         0x4A003768,
501         0x4A00376C,
502         0x4A003770,
503         0x4A003774,
504         0x4A003778,
505         0x4A00377C,
506         0x4A003780,
507         0x4A003784,
508         0x4A003788,
509         0x4A00378C,
510         0x4A003790,
511         0x4A003794,
512         0x4A003798,
513         0x4A00379C,
514         0x4A0037A0,
515         0x4A0037A4,
516         0x4A0037A8,
517         0x4A0037AC,
518         0x4A0037B0,
519         0x4A0037B4,
520         0x4A0037B8,
521         0x4A0037BC,
522         0x4A0037C0,
523         0x4A0037C4,
524         0x4A0037C8,
525         0x4A0037CC,
526         0x4A0037D0,
527         0x4A0037D4,
528         0x4A0037E0,
529         0x4A0037E4,
530         0x4A0037E8,
531         0x4A0037EC,
532         0x4A0037F0,
533         0x4A0037F4,
534         0x4A0037F8,
535         0x4A0037FC,
536         0x4A003800,
537         0x4A003804,
538         0x4A003808,
539         0x4A00380C,
540         0x4A003818,
541         0x4A00381C,
542         0x4A003820,
543         0x4A003824,
544         0x4A003828,
545         0x4A00382C,
546         0x4A003830,
547         0x4A003834,
548         0x4A003838,
549         0x4A00383C,
550         0x4A003840,
551         0x4A003844,
552         0x4A003848,
553         0x4A00384C,
554         0x4A00385C,
555         0x4A003860,
556         0x4A003864
557 ];
559 debugSessionDAP = ds.openSession("*","CS_DAP_DebugSS");
560 debugSessionDAP.target.connect();
562 /* Check ID_CODE register (address 0x4AE0C204) to determine which 
563    AM57xx variant is being used */
564 try {
565         id_code = debugSessionDAP.memory.readWord(0,0x4AE0C204,false);
566 } catch(ex) {
567         print("\n Trouble reading ID_CODE.\n");
570 print("ID_CODE = 0x" + d2h(id_code));
572 // Check STD_FUSE_ID_2 register (address 0x4AE0C20C) for package type
573 try {
574         fuse_id_2 = debugSessionDAP.memory.readWord(0,0x4AE0C20C,false);
575 } catch(ex) {
576         print("\n Trouble reading STD_FUSE_ID_2.\n");
578 pkg_type = (fuse_id_2 & 0x00030000) >> 16;  // FUSE_ID_2[17:16] = pkg_type
580 switch(id_code) {
581         case 0x0B9BC02F:
582                 print("AM571x SR1.0 detected.\n");
583                 device_type = 571;
584                 break;
585         case 0x1B9BC02F:
586                 if(pkg_type == 1) {
587                         print("AM570x SR2.0 detected.\n");
588                         device_type = 570;
589                 } else if(pkg_type == 2) {
590                         print("AM571x SR2.0 detected.\n");
591                         device_type = 571;
592                 } else
593                         print("AM571x/AM570x SR2.0 unrecognized package type\n")
594                 break;
595         case 0x2B9BC02F:
596                 if(pkg_type == 1) {
597                         print("AM570x SR2.1 detected.\n");
598                         device_type = 570;
599                 } else if(pkg_type == 2) {
600                         print("AM571x SR2.1 detected.\n");
601                         device_type = 571;
602                 } else
603                         print("AM571x/AM570x SR2.1 unrecognized package type\n")
604                 break;
605         case 0x0B99002F:
606                 print("AM572x SR1.0 detected.\n");
607                 device_type = 572;
608                 break;
609         case 0x1B99002F:
610                 print("AM572x SR1.1 detected.\n");
611                 device_type = 572;
612                 break;
613         case 0x2B99002F:
614                 print("AM572x SR2.0 detected.\n");
615                 device_type = 572;
616                 break;
617         case 0x0BB5002F:
618                 print("AM574x SR1.0 detected.\n");
619                 device_type = 574;
620                 break;
621         default:
622                 print("Unable to identify which AM57xx variant.\n");
623                 debugSessionDAP.target.disconnect();
624                 throw("Terminating script.\n")
625                 break;
628 //Build a filename that includes date/time
629 var today = new Date();
630 var year4digit = today.getFullYear();
631 var month2digit = ("0" + (today.getMonth()+1)).slice(-2);
632 var day2digit = ("0" + today.getDate()).slice(-2);
633 var hour2digit = ("0" + today.getHours()).slice(-2);
634 var minutes2digit = ("0" + today.getMinutes()).slice(-2);
635 var seconds2digit = ("0" + today.getSeconds()).slice(-2);
636 var filename_date = '_' + year4digit + '-' + month2digit + '-' + day2digit + '_' + hour2digit + minutes2digit + seconds2digit; 
637 var userHomeFolder = System.getProperty("user.home");
638 var filename = userHomeFolder + '/Desktop/' + 'am57xx-padconf' + filename_date + '.rd1';
640 file = new java.io.FileWriter(filename);
642 if (device_type == 570) {
643         file.write("PadConf AM570x_SR2.1_SR2.0\n");
644         padconf_registers = padconf_registers_am571x_am570x;
645 } else if (device_type == 571) {
646         file.write("PadConf AM571x_SR2.0_SR1.0\n");
647         padconf_registers = padconf_registers_am571x_am570x;
648 } else if (device_type == 572) {
649         file.write("PadConf AM572x_SR2.0_SR1.1\n");
650         padconf_registers = padconf_registers_am574x_am572x;
651 } else if (device_type == 574) {
652         file.write("PadConf AM574x_SR1.0\n");
653         padconf_registers = padconf_registers_am574x_am572x;
654 } else {
655         throw("Error -- code shouldn't get here.")
658 // helper function to create 8-digit hex numbers in ascii format
659 function d2h(d) {return ("00000000" + (+d).toString(16)).slice(-8);}
661 // read CTT data from physical addresses
662 for(i=0; i<padconf_registers.length; i++)
664         try {
665                 value = debugSessionDAP.memory.readWord(0,padconf_registers[i],false);
666                 value_string = d2h(value);
667                 file.write('0x' + ("0000" + padconf_registers[i].toString(16)).slice(-8) + " 0x" + value_string + "\n");
668         } catch (ex) {
669                 print("\n Trouble reading address 0x" + d2h(padconf_registers[i]) + ". Skipping register.\n");
670         }
672 print("Data collection complete.");
674 file.close();
675 debugSessionDAP.target.disconnect();
676 print("Created file " + filename);