Create AM57xx clock tree tool script
[sitara-dss-files/am57xx-dss-files.git] / am57xx-ctt.dss
1 /*
2  * Copyright (c) 2018, 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_am570x= [
35         0x4a005560,
36         0x4ae06118,
37         0x4a008920,
38         0x4ae06190,
39         0x4a0052e4,
40         0x4ae061c8,
41         0x4ae06174,
42         0x4a009848,
43         0x4ae07888,
44         0x4a005228,
45         0x4a002360,
46         0x4a0051ec,
47         0x4a009770,
48         0x4a009908,
49         0x4a005254,
50         0x4a009858,
51         0x4a00521c,
52         0x4ae061bc,
53         0x4a009750,
54         0x4a009780,
55         0x4a0097a8,
56         0x4a008778,
57         0x4a009328,
58         0x4a005234,
59         0x4a005244,
60         0x4a0052b8,
61         0x4a005130,
62         0x4a005154,
63         0x4a0098e8,
64         0x4a008e40,
65         0x4a005550,
66         0x4a0093e8,
67         0x4ae07830,
68         0x4a00516c,
69         0x4a009620,
70         0x4a005520,
71         0x4a005580,
72         0x4a008210,
73         0x4a008e28,
74         0x4ae061a0,
75         0x4a009738,
76         0x4a005248,
77         0x4a009800,
78         0x4a0052c8,
79         0x4a0052d8,
80         0x4a005140,
81         0x4a0052e8,
82         0x4a0098a8,
83         0x4a009798,
84         0x4a0051e0,
85         0x4ae06108,
86         0x4a0051f0,
87         0x4ae07840,
88         0x4ae06170,
89         0x4a0097d8,
90         0x4a005210,
91         0x4a0098f0,
92         0x4ae07838,
93         0x4a005220,
94         0x4a009868,
95         0x4a008158,
96         0x4a00519c,
97         0x4a0086a0,
98         0x4ae06138,
99         0x4ae061c4,
100         0x4a0051f4,
101         0x4ae06114,
102         0x4a008e50,
103         0x4a009760,
104         0x4a009720,
105         0x4ae061d0,
106         0x4a009878,
107         0x4a00814c,
108         0x4a008200,
109         0x4a005160,
110         0x4a0093b0,
111         0x4a005170,
112         0x4ae061d8,
113         0x4a009120,
114         0x4a008b30,
115         0x4a0052c0,
116         0x4a0051ac,
117         0x4ae061a8,
118         0x4a00815c,
119         0x4a005568,
120         0x4a0093d0,
121         0x4a009820,
122         0x4a009220,
123         0x4a002534,
124         0x4a009020,
125         0x4a0098d0,
126         0x4a0093e0,
127         0x4a009130,
128         0x4a009850,
129         0x4a005158,
130         0x4a005764,
131         0x4a009788,
132         0x4a008160,
133         0x4ae07878,
134         0x4a009890,
135         0x4a009870,
136         0x4a0097f0,
137         0x4ae06194,
138         0x4a009340,
139         0x4a009028,
140         0x4a0097c4,
141         0x4a009810,
142         0x4a0097b0,
143         0x4a0051dc,
144         0x4a008780,
145         0x4a005144,
146         0x4a008164,
147         0x4a008140,
148         0x4a0097c8,
149         0x4a008150,
150         0x4ae0610c,
151         0x4a0098c8,
152         0x4ae06198,
153         0x4ae06168,
154         0x4ae06184,
155         0x4ae06148,
156         0x4a0051a0,
157         0x4a0051b0,
158         0x4ae0619c,
159         0x4a009740,
160         0x4a00821c,
161         0x4a009808,
162         0x4a009728,
163         0x4ae061cc,
164         0x4a005558,
165         0x4ae0612c,
166         0x4ae06178,
167         0x4a009830,
168         0x4a00818c,
169         0x4a00820c,
170         0x4a008f28,
171         0x4a002544,
172         0x4a009898,
173         0x4ae06124,
174         0x4ae061b0,
175         0x4a009840,
176         0x4a009768,
177         0x4a009904,
178         0x4a00515c,
179         0x4ae061b8,
180         0x4a0052bc,
181         0x4ae061b4,
182         0x4a009778,
183         0x4a005570,
184         0x4a0097a0,
185         0x4ae06110,
186         0x4a009828,
187         0x4ae06164,
188         0x4a008b40,
189         0x4ae06160,
190         0x4ae0615c,
191         0x4ae06158,
192         0x4a0098e0,
193         0x4a009330,
194         0x4ae0614c,
195         0x4a005420,
196         0x4a0093f0,
197         0x4a008180,
198         0x4a0052b4,
199         0x4a008190,
200         0x4a00512c,
201         0x4a005100,
202         0x4a0097f8,
203         0x4a008f20,
204         0x4ae0618c,
205         0x4a0098a0,
206         0x4a0098c0,
207         0x4a009790,
208         0x4a009838,
209         0x4a009818,
210         0x4a0097b8,
211         0x4a008728,
212         0x4a0097d0,
213         0x4a008e20,
214         0x4a0098f8,
215         0x4ae07880,
216         0x4a009860,
217         0x4ae061ac,
218         0x4a0098b0,
219         0x4a0052c4,
220         0x4a00513c,
221         0x4ae06120,
222         0x4a009748,
223         0x4ae06144,
224         0x4a005578,
225         0x4a005240,
226         0x4a009718,
227         0x4a009730,
228         0x4a0052a8,
229         0x4a005120,
230         0x4a0086b0,
231         0x4ae06188,
232         0x4ae061a4,
233         0x4ae06128
234 ];
236 var ctt_registers_am571x = [
237         0x4a005560,
238         0x4ae06118,
239         0x4a008920,
240         0x4ae06190,
241         0x4a0052e4,
242         0x4ae061c8,
243         0x4ae06174,
244         0x4a009848,
245         0x4ae07888,
246         0x4a005228,
247         0x4a002360,
248         0x4a0051ec,
249         0x4a009770,
250         0x4a009908,
251         0x4ae07a04,
252         0x4a005254,
253         0x4a009858,
254         0x4a00521c,
255         0x4ae061bc,
256         0x4a009750,
257         0x4a009780,
258         0x4a0097a8,
259         0x4a008778,
260         0x4a009328,
261         0x4a005234,
262         0x4a005244,
263         0x4a0052b8,
264         0x4a009388,
265         0x4a005130,
266         0x4a005154,
267         0x4a0098e8,
268         0x4a008e40,
269         0x4a005550,
270         0x4a0093e8,
271         0x4ae07830,
272         0x4a00516c,
273         0x4a009620,
274         0x4a005520,
275         0x4a005580,
276         0x4a008210,
277         0x4a008e28,
278         0x4ae061a0,
279         0x4a009738,
280         0x4a005248,
281         0x4a009800,
282         0x4a0052c8,
283         0x4a0052d8,
284         0x4a005140,
285         0x4a0052e8,
286         0x4a0098a8,
287         0x4a009798,
288         0x4ae061c0,
289         0x4a0051e0,
290         0x4ae06108,
291         0x4a0051f0,
292         0x4ae07840,
293         0x4ae06170,
294         0x4a0097d8,
295         0x4a005210,
296         0x4a0098f0,
297         0x4ae07838,
298         0x4a005220,
299         0x4a009868,
300         0x4a008158,
301         0x4a00519c,
302         0x4a0086a0,
303         0x4ae06138,
304         0x4ae061c4,
305         0x4a0051f4,
306         0x4ae06114,
307         0x4a008e50,
308         0x4a009760,
309         0x4a009720,
310         0x4ae061d0,
311         0x4a009878,
312         0x4a00814c,
313         0x4a008200,
314         0x4a005160,
315         0x4a0093b0,
316         0x4a005170,
317         0x4ae061d8,
318         0x4a009120,
319         0x4a008b30,
320         0x4a0052c0,
321         0x4a0051ac,
322         0x4ae061a8,
323         0x4a00815c,
324         0x4a005568,
325         0x4a0093d0,
326         0x4a009820,
327         0x4a009220,
328         0x4a002534,
329         0x4a009020,
330         0x4a0098d0,
331         0x4a0093e0,
332         0x4a009130,
333         0x4a009850,
334         0x4a005158,
335         0x4a005764,
336         0x4a009788,
337         0x4a008160,
338         0x4ae07878,
339         0x4a005744,
340         0x4a009890,
341         0x4a009870,
342         0x4a0097f0,
343         0x4ae06194,
344         0x4a009340,
345         0x4a009028,
346         0x4a0097c4,
347         0x4a009810,
348         0x4a0097b0,
349         0x4a0051dc,
350         0x4a008780,
351         0x4a005144,
352         0x4a008164,
353         0x4a008140,
354         0x4a0097c8,
355         0x4a008150,
356         0x4ae0610c,
357         0x4a0098c8,
358         0x4ae06198,
359         0x4ae06168,
360         0x4ae06184,
361         0x4ae06148,
362         0x4a0051a0,
363         0x4a0051b0,
364         0x4ae0619c,
365         0x4a009740,
366         0x4a00821c,
367         0x4a009808,
368         0x4a009728,
369         0x4ae061cc,
370         0x4a005558,
371         0x4ae0612c,
372         0x4ae06178,
373         0x4a009830,
374         0x4a00818c,
375         0x4a00820c,
376         0x4a008f28,
377         0x4a002544,
378         0x4a009898,
379         0x4ae06124,
380         0x4ae061b0,
381         0x4a009840,
382         0x4a009768,
383         0x4a009904,
384         0x4a00515c,
385         0x4ae061b8,
386         0x4a0052bc,
387         0x4a0093b8,
388         0x4ae061b4,
389         0x4a009778,
390         0x4a005570,
391         0x4a0097a0,
392         0x4ae06110,
393         0x4a009828,
394         0x4ae06164,
395         0x4a008b40,
396         0x4ae06160,
397         0x4ae0615c,
398         0x4ae06158,
399         0x4a0098e0,
400         0x4a009330,
401         0x4ae0614c,
402         0x4a005420,
403         0x4a0093f0,
404         0x4a008180,
405         0x4a0052b4,
406         0x4a008190,
407         0x4a00512c,
408         0x4a005100,
409         0x4a0097f8,
410         0x4a008f20,
411         0x4ae0618c,
412         0x4a0098a0,
413         0x4a0098c0,
414         0x4a009790,
415         0x4a009838,
416         0x4a009818,
417         0x4a0097b8,
418         0x4a008728,
419         0x4a0097d0,
420         0x4a008e20,
421         0x4a0098f8,
422         0x4ae07880,
423         0x4a009860,
424         0x4ae061ac,
425         0x4a0098b0,
426         0x4a0052c4,
427         0x4a00513c,
428         0x4ae06120,
429         0x4a009748,
430         0x4ae06144,
431         0x4a005578,
432         0x4a005240,
433         0x4a009718,
434         0x4a009730,
435         0x4a0052a8,
436         0x4a005120,
437         0x4a0086b0,
438         0x4ae06188,
439         0x4ae061a4,
440         0x4ae06128
441 ];
443 var ctt_registers_am572x = [
444         0x4a005560,
445         0x4ae06118,
446         0x4a008920,
447         0x4ae06190,
448         0x4a0052e4,
449         0x4ae061c8,
450         0x4ae06174,
451         0x4a009848,
452         0x4ae07888,
453         0x4a005228,
454         0x4a002360,
455         0x4a0051ec,
456         0x4a009770,
457         0x4a009908,
458         0x4ae07a04,
459         0x4a005254,
460         0x4ae06154,
461         0x4a009858,
462         0x4a00521c,
463         0x4ae061bc,
464         0x4a009750,
465         0x4a009780,
466         0x4a0097a8,
467         0x4a008778,
468         0x4a009328,
469         0x4a005234,
470         0x4a005244,
471         0x4a0052b8,
472         0x4a009388,
473         0x4a005130,
474         0x4a005154,
475         0x4a0098e8,
476         0x4a008e40,
477         0x4a005550,
478         0x4a0093e8,
479         0x4ae07830,
480         0x4a00516c,
481         0x4a009620,
482         0x4a005520,
483         0x4a005580,
484         0x4a008210,
485         0x4a008e28,
486         0x4ae061a0,
487         0x4a009738,
488         0x4a005248,
489         0x4a009800,
490         0x4a0052c8,
491         0x4a0052d8,
492         0x4a005140,
493         0x4a0052e8,
494         0x4a0098a8,
495         0x4a005720,
496         0x4ae06180,
497         0x4a009798,
498         0x4ae061c0,
499         0x4a0051e0,
500         0x4ae06108,
501         0x4a0051f0,
502         0x4ae07840,
503         0x4ae06170,
504         0x4a009200,
505         0x4a0097d8,
506         0x4a005210,
507         0x4a0098f0,
508         0x4ae07838,
509         0x4a005220,
510         0x4a009868,
511         0x4a008158,
512         0x4a00519c,
513         0x4a0086a0,
514         0x4ae061d4,
515         0x4ae06138,
516         0x4ae061c4,
517         0x4a0051f4,
518         0x4ae06114,
519         0x4a008e50,
520         0x4a009760,
521         0x4a009720,
522         0x4ae061d0,
523         0x4a009878,
524         0x4a00814c,
525         0x4a008200,
526         0x4a005160,
527         0x4a0093b0,
528         0x4a005170,
529         0x4ae061d8,
530         0x4a009120,
531         0x4a008b30,
532         0x4a0052c0,
533         0x4a0051ac,
534         0x4ae061a8,
535         0x4a00815c,
536         0x4a005568,
537         0x4a0093d0,
538         0x4a009820,
539         0x4a009220,
540         0x4a002534,
541         0x4a009020,
542         0x4a0098d0,
543         0x4a0056e0,
544         0x4a0093e0,
545         0x4a009130,
546         0x4a009850,
547         0x4a005158,
548         0x4a005764,
549         0x4a009788,
550         0x4a008160,
551         0x4ae07878,
552         0x4a009030,
553         0x4a009890,
554         0x4a009870,
555         0x4a0097f0,
556         0x4ae06194,
557         0x4a009340,
558         0x4a0097c4,
559         0x4a009810,
560         0x4a0097b0,
561         0x4a0051dc,
562         0x4a008780,
563         0x4a005144,
564         0x4a008164,
565         0x4a008140,
566         0x4a0097c8,
567         0x4a008150,
568         0x4ae0610c,
569         0x4a0098c8,
570         0x4ae06198,
571         0x4ae06168,
572         0x4ae06184,
573         0x4ae06148,
574         0x4a0051a0,
575         0x4a0051b0,
576         0x4ae0619c,
577         0x4a0056a0,
578         0x4a009740,
579         0x4a00821c,
580         0x4a009808,
581         0x4a009728,
582         0x4a005290,
583         0x4ae061cc,
584         0x4a005558,
585         0x4ae0612c,
586         0x4ae06178,
587         0x4a005620,
588         0x4a009830,
589         0x4a00818c,
590         0x4a00820c,
591         0x4a008f28,
592         0x4a002544,
593         0x4a009898,
594         0x4ae061b0,
595         0x4a009840,
596         0x4a009768,
597         0x4a009904,
598         0x4a00515c,
599         0x4ae061b8,
600         0x4a0052bc,
601         0x4a0093b8,
602         0x4a008b38,
603         0x4ae061b4,
604         0x4a009778,
605         0x4a005570,
606         0x4a0097a0,
607         0x4a0052a4,
608         0x4a005660,
609         0x4ae06110,
610         0x4a009828,
611         0x4ae06164,
612         0x4a008b40,
613         0x4ae06160,
614         0x4ae0615c,
615         0x4ae06158,
616         0x4a009028,
617         0x4a0098e0,
618         0x4a005284,
619         0x4a005294,
620         0x4a009330,
621         0x4ae0614c,
622         0x4a005420,
623         0x4a0093f0,
624         0x4ae06150,
625         0x4a008180,
626         0x4a0052b4,
627         0x4a008190,
628         0x4a00512c,
629         0x4a005100,
630         0x4a0097f8,
631         0x4a008f20,
632         0x4ae0618c,
633         0x4a0098a0,
634         0x4ae061e0,
635         0x4a0098c0,
636         0x4a009790,
637         0x4a009838,
638         0x4a009818,
639         0x4a0097b8,
640         0x4a008728,
641         0x4a0097d0,
642         0x4a008e20,
643         0x4a0098f8,
644         0x4ae07880,
645         0x4ae0616c,
646         0x4a009860,
647         0x4ae061ac,
648         0x4a0098b0,
649         0x4a0052c4,
650         0x4a00513c,
651         0x4ae06120,
652         0x4a009748,
653         0x4ae06144,
654         0x4a005578,
655         0x4a005240,
656         0x4a009718,
657         0x4a009730,
658         0x4a0052a8,
659         0x4a005120,
660         0x4a0086b0,
661         0x4ae06188,
662         0x4ae061a4,
663         0x4ae06128
664 ];
666 var ctt_registers_am574x = [
667         0x4a005560,
668         0x4ae06118,
669         0x4a008920,
670         0x4ae06190,
671         0x4a0052e4,
672         0x4ae061c8,
673         0x4ae06174,
674         0x4a009848,
675         0x4ae07888,
676         0x4a005228,
677         0x4a002360,
678         0x4a0051ec,
679         0x4a009770,
680         0x4a009908,
681         0x4ae07a04,
682         0x4a005254,
683         0x4ae06154,
684         0x4a009858,
685         0x4a00521c,
686         0x4ae061bc,
687         0x4a009750,
688         0x4a009780,
689         0x4a0097a8,
690         0x4a008778,
691         0x4a009328,
692         0x4a005234,
693         0x4a005244,
694         0x4a0052b8,
695         0x4a009388,
696         0x4a005130,
697         0x4a005154,
698         0x4a0098e8,
699         0x4a008e40,
700         0x4a005550,
701         0x4a0093e8,
702         0x4ae07830,
703         0x4a00516c,
704         0x4a009620,
705         0x4a005520,
706         0x4a005580,
707         0x4a008210,
708         0x4a008e28,
709         0x4ae061a0,
710         0x4a009738,
711         0x4a009800,
712         0x4a0052c8,
713         0x4a0052d8,
714         0x4a005140,
715         0x4a0052e8,
716         0x4a0098a8,
717         0x4ae06180,
718         0x4a009798,
719         0x4ae061c0,
720         0x4a0051e0,
721         0x4ae06108,
722         0x4a0051f0,
723         0x4ae07840,
724         0x4ae06170,
725         0x4a009200,
726         0x4a0097d8,
727         0x4a005210,
728         0x4a0098f0,
729         0x4ae07838,
730         0x4a005220,
731         0x4a009868,
732         0x4a008158,
733         0x4a00519c,
734         0x4a0086a0,
735         0x4ae061d4,
736         0x4ae06138,
737         0x4ae061c4,
738         0x4a0051f4,
739         0x4ae06114,
740         0x4a008e50,
741         0x4a009760,
742         0x4a009720,
743         0x4ae061d0,
744         0x4a009878,
745         0x4a00814c,
746         0x4a008200,
747         0x4a005160,
748         0x4a0093b0,
749         0x4a005170,
750         0x4ae061d8,
751         0x4a009120,
752         0x4a008b30,
753         0x4a0052c0,
754         0x4a0051ac,
755         0x4ae061a8,
756         0x4a00815c,
757         0x4a005568,
758         0x4a0093d0,
759         0x4a009820,
760         0x4a009220,
761         0x4a002534,
762         0x4a0023fc,
763         0x4a009020,
764         0x4a0098d0,
765         0x4a0093e0,
766         0x4a009130,
767         0x4a009850,
768         0x4a005158,
769         0x4a005764,
770         0x4a009788,
771         0x4a008160,
772         0x4ae07878,
773         0x4a009890,
774         0x4a009870,
775         0x4a0097f0,
776         0x4ae06194,
777         0x4a009340,
778         0x4a0097c4,
779         0x4a009810,
780         0x4a0097b0,
781         0x4a0051dc,
782         0x4a008780,
783         0x4a005144,
784         0x4a008164,
785         0x4a008140,
786         0x4a0097c8,
787         0x4a008150,
788         0x4ae0610c,
789         0x4a0098c8,
790         0x4ae06198,
791         0x4ae06168,
792         0x4ae06184,
793         0x4ae06148,
794         0x4a0051a0,
795         0x4a0051b0,
796         0x4ae0619c,
797         0x4a0056a0,
798         0x4a009740,
799         0x4a00821c,
800         0x4a009808,
801         0x4a009728,
802         0x4ae061cc,
803         0x4a005558,
804         0x4ae0612c,
805         0x4ae06178,
806         0x4a005620,
807         0x4a009830,
808         0x4a00818c,
809         0x4a00820c,
810         0x4a008f28,
811         0x4a002544,
812         0x4a009898,
813         0x4ae061b0,
814         0x4a009840,
815         0x4a009768,
816         0x4a009904,
817         0x4a00515c,
818         0x4ae061b8,
819         0x4a0052bc,
820         0x4a0093b8,
821         0x4a008b38,
822         0x4ae061b4,
823         0x4a009778,
824         0x4a005570,
825         0x4a0097a0,
826         0x4a005660,
827         0x4ae06110,
828         0x4a009828,
829         0x4ae06164,
830         0x4a008b40,
831         0x4ae06160,
832         0x4ae0615c,
833         0x4ae06158,
834         0x4a009028,
835         0x4a0098e0,
836         0x4a009330,
837         0x4ae078a0,
838         0x4ae0614c,
839         0x4a005420,
840         0x4a0093f0,
841         0x4ae06150,
842         0x4a008180,
843         0x4a0052b4,
844         0x4a008190,
845         0x4a00512c,
846         0x4a005100,
847         0x4a0097f8,
848         0x4a008f20,
849         0x4ae0618c,
850         0x4a0098a0,
851         0x4a0098c0,
852         0x4a009790,
853         0x4a009838,
854         0x4a009818,
855         0x4a0097b8,
856         0x4a008728,
857         0x4a0097d0,
858         0x4a008e20,
859         0x4a0098f8,
860         0x4ae07880,
861         0x4ae0616c,
862         0x4a009860,
863         0x4ae061ac,
864         0x4a0098b0,
865         0x4a0052c4,
866         0x4a00513c,
867         0x4ae06120,
868         0x4a009748,
869         0x4ae06144,
870         0x4a005578,
871         0x4a005240,
872         0x4a009718,
873         0x4a009730,
874         0x4a0052a8,
875         0x4a005120,
876         0x4a0086b0,
877         0x4ae06188,
878         0x4ae061a4,
879         0x4ae06128
880 ];
882 debugSessionDAP = ds.openSession("*","CS_DAP_DebugSS");
883 debugSessionDAP.target.connect();
885 /* Check ID_CODE register (address 0x4AE0C204) to determine which 
886    AM57xx variant is being used */
887 try {
888         id_code = debugSessionDAP.memory.readWord(0,0x4AE0C204,false);
889 } catch(ex) {
890         print("\n Trouble reading ID_CODE.\n");
893 print("ID_CODE = 0x" + d2h(id_code));
895 // Check STD_FUSE_ID_2 register (address 0x4AE0C20C) for package type
896 try {
897         fuse_id_2 = debugSessionDAP.memory.readWord(0,0x4AE0C20C,false);
898 } catch(ex) {
899         print("\n Trouble reading STD_FUSE_ID_2.\n");
901 pkg_type = (fuse_id_2 & 0x00030000) >> 16;  // FUSE_ID_2[17:16] = pkg_type
903 switch(id_code) {
904         case 0x0B9BC02F:
905                 print("AM571x SR1.0 detected.\n");
906                 device_type = 571;
907                 break;
908         case 0x1B9BC02F:
909                 if(pkg_type == 1) {
910                         print("AM570x SR2.0 detected.\n");
911                         device_type = 570;
912                 } else if(pkg_type == 2) {
913                         print("AM571x SR2.0 detected.\n");
914                         device_type = 571;
915                 } else
916                         print("AM571x/AM570x SR2.0 unrecognized package type\n")
917                 break;
918         case 0x2B9BC02F:
919                 if(pkg_type == 1) {
920                         print("AM570x SR2.1 detected.\n");
921                         device_type = 570;
922                 } else if(pkg_type == 2) {
923                         print("AM571x SR2.1 detected.\n");
924                         device_type = 571;
925                 } else
926                         print("AM571x/AM570x SR2.1 unrecognized package type\n")
927                 break;
928         case 0x0B99002F:
929                 print("AM572x SR1.0 detected.\n");
930                 device_type = 572;
931                 break;
932         case 0x1B99002F:
933                 print("AM572x SR1.1 detected.\n");
934                 device_type = 572;
935                 break;
936         case 0x2B99002F:
937                 print("AM572x SR2.0 detected.\n");
938                 device_type = 572;
939                 break;
940         case 0x0BB5002F:
941                 print("AM574x SR1.0 detected.\n");
942                 device_type = 574;
943                 break;
944         default:
945                 print("Unable to identify which AM57xx variant.\n");
946                 debugSessionDAP.target.disconnect();
947                 throw("Terminating script.\n")
948                 break;
951 //Build a filename that includes date/time
952 var today = new Date();
953 var year4digit = today.getFullYear();
954 var month2digit = ("0" + (today.getMonth()+1)).slice(-2);
955 var day2digit = ("0" + today.getDate()).slice(-2);
956 var hour2digit = ("0" + today.getHours()).slice(-2);
957 var minutes2digit = ("0" + today.getMinutes()).slice(-2);
958 var seconds2digit = ("0" + today.getSeconds()).slice(-2);
959 var filename_date = '_' + year4digit + '-' + month2digit + '-' + day2digit + '_' + hour2digit + minutes2digit + seconds2digit; 
960 var userHomeFolder = System.getProperty("user.home");
961 var filename = userHomeFolder + '/Desktop/' + 'am57xx-ctt' + filename_date + '.rd1';
963 file = new java.io.FileWriter(filename);
965 if (device_type == 570) {
966         file.write("DeviceName AM570x_SR2.1_SR2.0\n");
967         ctt_registers = ctt_registers_am570x;
968 } else if (device_type == 571) {
969         file.write("DeviceName AM571x_SR2.0_SR1.0\n");
970         ctt_registers = ctt_registers_am571x;
971 } else if (device_type == 572) {
972         file.write("DeviceName AM572x_SR2.0_SR1.1\n");
973         ctt_registers = ctt_registers_am572x;
974 } else if (device_type == 574) {
975         file.write("DeviceName AM574x_SR1.0\n");
976         ctt_registers = ctt_registers_am574x;
977 } else {
978         throw("Error -- code shouldn't get here.")
981 // helper function to create 8-digit hex numbers in ascii format
982 function d2h(d) {return ("00000000" + (+d).toString(16)).slice(-8);}
984 // read CTT data from physical addresses
985 for(i=0; i<ctt_registers.length; i++)
987         try {
988                 value = debugSessionDAP.memory.readWord(0,ctt_registers[i],false);
989                 value_string = d2h(value);
990                 file.write('0x' + ("0000" + ctt_registers[i].toString(16)).slice(-8) + " 0x" + value_string + "\n");
991         } catch (ex) {
992                 print("\n Trouble reading address 0x" + d2h(ctt_registers[i]) + ". Skipping register.\n");
993         }
995 print("Data collection complete.");
997 file.close();
998 debugSessionDAP.target.disconnect();
999 print("Created file " + filename);