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 function d2h(d) {return ("00000000" + (d).toString(16)).slice(-8);}
36 var newline = "\n";
38 function printRegisterValue(ds, name, addr)
39 {
40 value = debugSessionDAP.memory.readWord(0,addr,false);
41 value_string = d2h(value);
42 file.write(name + " = 0x" + value_string + newline);
43 return value; // return the register value for interrogation
44 }
46 // Helper function for decoding trace vector 1 (gets called for current vector and cold reset vector)
47 function decode_tracing_vector_1(value)
48 {
49 if (value & (1<< 0)) {file.write(" * Bit 0: [Boot] Passed the public reset vector" + newline);}
50 if (value & (1<< 1)) {file.write(" * Bit 1: [Boot] Entered main function" + newline);}
51 if (value & (1<< 2)) {file.write(" * Bit 2: [Boot] Running after the cold reset" + newline);}
52 if (value & (1<< 3)) {file.write(" * Bit 3: [Boot] Main booting routine entered" + newline);}
53 if (value & (1<< 4)) {file.write(" * Bit 4: [Memory boot] Memory booting started" + newline);}
54 if (value & (1<< 5)) {file.write(" * Bit 5: [Peripheral boot] Peripheral booting started" + newline);}
55 if (value & (1<< 6)) {file.write(" * Bit 6: [Boot] Booting loop reached last device" + newline);}
56 if (value & (1<< 7)) {file.write(" * Bit 7: [Boot] GP header found" + newline);}
57 if (value & (1<< 8)) {file.write(" * Bit 8: [Peripheral boot] Booting message Skip peripheral booting received" + newline);}
58 if (value & (1<< 9)) {file.write(" * Bit 9: [Peripheral boot] Booting message Change device received" + newline);}
59 if (value & (1<<10)) {file.write(" * Bit 10: [Peripheral boot] Booting message Peripheral booting received" + newline);}
60 if (value & (1<<11)) {file.write(" * Bit 11: [Peripheral boot] Booting message Get ASIC ID received" + newline);}
61 if (value & (1<<12)) {file.write(" * Bit 12: [Peripheral boot] Device initialized" + newline);}
62 if (value & (1<<13)) {file.write(" * Bit 13: [Peripheral boot] ASIC ID sent" + newline);}
63 if (value & (1<<14)) {file.write(" * Bit 14: [Peripheral boot] Image received" + newline);}
64 if (value & (1<<15)) {file.write(" * Bit 15: [Peripheral boot] Peripheral booting failed" + newline);}
65 if (value & (1<<16)) {file.write(" * Bit 16: [Peripheral boot] Booting message not received (time-out)" + newline);}
66 if (value & (1<<17)) {file.write(" * Bit 17: [Peripheral boot] Image size not received (time-out)" + newline);}
67 if (value & (1<<18)) {file.write(" * Bit 18: [Peripheral boot] Image not received (time-out)" + newline);}
68 if (value & (1<<19)) {file.write(" * Bit 19: Reserved" + newline);}
69 if (value & (1<<20)) {file.write(" * Bit 20: [Boot] Configuration header found" + newline);}
70 if (value & (1<<21)) {file.write(" * Bit 21: [Boot] CHSETTINGS item processed" + newline);}
71 if (value & (1<<22)) {file.write(" * Bit 22: [Boot] Reserved" + newline);}
72 if (value & (1<<23)) {file.write(" * Bit 23: [Boot] CHFLASH item processed" + newline);}
73 if (value & (1<<24)) {file.write(" * Bit 24: [Boot] CHMMCSD item processed (clock)" + newline);}
74 if (value & (1<<25)) {file.write(" * Bit 25: [Boot] CHMMCSD item processed (bus width)" + newline);}
75 if (value & (1<<26)) {file.write(" * Bit 26: [Boot] CHMMCSD item processed (eMMC DDR mode)" + newline);}
76 if (value & (1<<27)) {file.write(" * Bit 27: Reserved" + newline);}
77 if (value & (1<<28)) {file.write(" * Bit 28: [Boot] SWCFG general detected" + newline);}
78 if (value & (1<<29)) {file.write(" * Bit 29: [Boot] SWCFG clocks detected" + newline);}
79 if (value & (1<<30)) {file.write(" * Bit 30: [Boot] SWCFG time-out detected" + newline);}
80 if (value & (1<<31)) {file.write(" * Bit 31: Reserved" + newline);}
81 }
83 // Helper function for decoding trace vector 2 (gets called for current vector and cold reset vector)
84 function decode_tracing_vector_2(value)
85 {
86 if (value & (1<< 0)) {file.write(" * Bit 0: [Configuration Header] CHSATA item processed" + newline);}
87 if (value & (1<< 1)) {file.write(" * Bit 1: Reserved" + newline);}
88 if (value & (1<< 2)) {file.write(" * Bit 2: Reserved" + newline);}
89 if (value & (1<< 3)) {file.write(" * Bit 3: Reserved" + newline);}
90 if (value & (1<< 4)) {file.write(" * Bit 4: [USB] USB connected" + newline);}
91 if (value & (1<< 5)) {file.write(" * Bit 5: [USB] USB configured" + newline);}
92 if (value & (1<< 6)) {file.write(" * Bit 6: Reserved" + newline);}
93 if (value & (1<< 7)) {file.write(" * Bit 7: Reserved" + newline);}
94 if (value & (1<< 8)) {file.write(" * Bit 8: [Configuration Header] CHQSPI item processed (clock speed)" + newline);}
95 if (value & (1<< 9)) {file.write(" * Bit 9: [Configuration Header] CHQSPI item processed (Read command)" + newline);}
96 if (value & (1<<10)) {file.write(" * Bit 10: Reserved" + newline);}
97 if (value & (1<<11)) {file.write(" * Bit 11: Reserved" + newline);}
98 if (value & (1<<12)) {file.write(" * Bit 12: [Memory boot] Memory booting trial (first block)" + newline);}
99 if (value & (1<<13)) {file.write(" * Bit 13: [Memory boot] Memory booting trial (second block)" + newline);}
100 if (value & (1<<14)) {file.write(" * Bit 14: [Memory boot] Memory booting trial (third block)" + newline);}
101 if (value & (1<<15)) {file.write(" * Bit 15: [Memory boot] Memory booting trial (fourth block)" + newline);}
102 if (value & (1<<16)) {file.write(" * Bit 16: Reserved" + newline);}
103 if (value & (1<<17)) {file.write(" * Bit 17: Reserved" + newline);}
104 if (value & (1<<18)) {file.write(" * Bit 18: Reserved" + newline);}
105 if (value & (1<<19)) {file.write(" * Bit 19: Reserved" + newline);}
106 if (value & (1<<20)) {file.write(" * Bit 20: Reserved" + newline);}
107 if (value & (1<<21)) {file.write(" * Bit 21: Reserved" + newline);}
108 if (value & (1<<22)) {file.write(" * Bit 22: Reserved" + newline);}
109 if (value & (1<<23)) {file.write(" * Bit 23: Reserved" + newline);}
110 if (value & (1<<24)) {file.write(" * Bit 24: Reserved" + newline);}
111 if (value & (1<<25)) {file.write(" * Bit 25: Reserved" + newline);}
112 if (value & (1<<26)) {file.write(" * Bit 26: Reserved" + newline);}
113 if (value & (1<<27)) {file.write(" * Bit 27: Reserved" + newline);}
114 if (value & (1<<28)) {file.write(" * Bit 28: Reserved" + newline);}
115 if (value & (1<<29)) {file.write(" * Bit 29: Reserved" + newline);}
116 if (value & (1<<30)) {file.write(" * Bit 30: [Boot] Jumping to Initial Software" + newline);}
117 if (value & (1<<31)) {file.write(" * Bit 31: Reserved" + newline);}
118 }
120 // Helper function for decoding trace vector 3 (gets called for current vector and cold reset vector)
121 function decode_tracing_vector_3(value)
122 {
123 if (value & (1<< 0)) {file.write(" * Bit 0: Reserved" + newline);}
124 if (value & (1<< 1)) {file.write(" * Bit 1: [Memory boot] Memory booting device XIP" + newline);}
125 if (value & (1<< 2)) {file.write(" * Bit 2: [Memory boot] Memory booting device XIPWAIT" + newline);}
126 if (value & (1<< 3)) {file.write(" * Bit 3: [Memory boot] Memory booting device NAND" + newline);}
127 if (value & (1<< 4)) {file.write(" * Bit 4: Reserved" + newline);}
128 if (value & (1<< 5)) {file.write(" * Bit 5: [Memory boot] Memory booting device SD" + newline);}
129 if (value & (1<< 6)) {file.write(" * Bit 6: [Memory boot] Memory booting device eMMC (from boot partition)" + newline);}
130 if (value & (1<< 7)) {file.write(" * Bit 7: [Memory boot] Memory booting device MMC2: eMMC (from user area)" + newline);}
131 if (value & (1<< 8)) {file.write(" * Bit 8: Reserved" + newline);}
132 if (value & (1<< 9)) {file.write(" * Bit 9: [Memory boot] Memory booting device SATA" + newline);}
133 if (value & (1<<10)) {file.write(" * Bit 10: [Memory boot] Memory booting device QSPI_1" + newline);}
134 if (value & (1<<11)) {file.write(" * Bit 11: [Memory boot] Memory booting device QSPI_4" + newline);}
135 if (value & (1<<12)) {file.write(" * Bit 12: Reserved" + newline);}
136 if (value & (1<<13)) {file.write(" * Bit 13: Reserved" + newline);}
137 if (value & (1<<14)) {file.write(" * Bit 14: Reserved" + newline);}
138 if (value & (1<<15)) {file.write(" * Bit 15: Reserved" + newline);}
139 if (value & (1<<16)) {file.write(" * Bit 16: Reserved" + newline);}
140 if (value & (1<<17)) {file.write(" * Bit 17: Reserved" + newline);}
141 if (value & (1<<18)) {file.write(" * Bit 18: Reserved" + newline);}
142 if (value & (1<<19)) {file.write(" * Bit 19: [Peripheral boot] Peripheral booting device UART3" + newline);}
143 if (value & (1<<20)) {file.write(" * Bit 20: Reserved" + newline);}
144 if (value & (1<<21)) {file.write(" * Bit 21: [Peripheral boot] Peripheral booting device USB" + newline);}
145 if (value & (1<<22)) {file.write(" * Bit 22: Reserved" + newline);}
146 if (value & (1<<23)) {file.write(" * Bit 23: Reserved" + newline);}
147 if (value & (1<<24)) {file.write(" * Bit 24: Reserved" + newline);}
148 if (value & (1<<25)) {file.write(" * Bit 25: Reserved" + newline);}
149 if (value & (1<<26)) {file.write(" * Bit 26: Reserved" + newline);}
150 if (value & (1<<27)) {file.write(" * Bit 27: Reserved" + newline);}
151 if (value & (1<<28)) {file.write(" * Bit 28: [Boot] Reserved" + newline);}
152 if (value & (1<<29)) {file.write(" * Bit 29: [Boot] Reserved" + newline);}
153 if (value & (1<<30)) {file.write(" * Bit 30: Reserved" + newline);}
154 if (value & (1<<31)) {file.write(" * Bit 31: Reserved" + newline);}
155 }
157 // Helper function for decoding trace vector 4 (gets called for current vector and cold reset vector)
158 function decode_tracing_vector_4(value)
159 {
160 if (value & (1<< 0)) {file.write(" * Bit 0: Reserved" + newline);}
161 if (value & (1<< 1)) {file.write(" * Bit 1: Reserved" + newline);}
162 if (value & (1<< 2)) {file.write(" * Bit 2: Reserved" + newline);}
163 if (value & (1<< 3)) {file.write(" * Bit 3: Reserved" + newline);}
164 if (value & (1<< 4)) {file.write(" * Bit 4: Reserved" + newline);}
165 if (value & (1<< 5)) {file.write(" * Bit 5: Reserved" + newline);}
166 if (value & (1<< 6)) {file.write(" * Bit 6: Reserved" + newline);}
167 if (value & (1<< 7)) {file.write(" * Bit 7: Reserved" + newline);}
168 if (value & (1<< 8)) {file.write(" * Bit 8: Reserved" + newline);}
169 if (value & (1<< 9)) {file.write(" * Bit 9: Reserved" + newline);}
170 if (value & (1<<10)) {file.write(" * Bit 10: Reserved" + newline);}
171 if (value & (1<<11)) {file.write(" * Bit 11: Reserved" + newline);}
172 if (value & (1<<12)) {file.write(" * Bit 12: Reserved" + newline);}
173 if (value & (1<<13)) {file.write(" * Bit 13: Reserved" + newline);}
174 if (value & (1<<14)) {file.write(" * Bit 14: Reserved" + newline);}
175 if (value & (1<<15)) {file.write(" * Bit 15: Reserved" + newline);}
176 if (value & (1<<16)) {file.write(" * Bit 16: Reserved" + newline);}
177 if (value & (1<<17)) {file.write(" * Bit 17: Reserved" + newline);}
178 if (value & (1<<18)) {file.write(" * Bit 18: Reserved" + newline);}
179 if (value & (1<<19)) {file.write(" * Bit 19: Reserved" + newline);}
180 if (value & (1<<20)) {file.write(" * Bit 20: Reserved" + newline);}
181 if (value & (1<<21)) {file.write(" * Bit 21: Reserved" + newline);}
182 if (value & (1<<22)) {file.write(" * Bit 22: Reserved" + newline);}
183 if (value & (1<<23)) {file.write(" * Bit 23: Reserved" + newline);}
184 if (value & (1<<24)) {file.write(" * Bit 24: [MMC/SD] SD card detected PBIAS configuration is 1.8V" + newline);}
185 if (value & (1<<25)) {file.write(" * Bit 25: Reserved" + newline);}
186 if (value & (1<<26)) {file.write(" * Bit 26: Reserved" + newline);}
187 if (value & (1<<27)) {file.write(" * Bit 27: Reserved" + newline);}
188 if (value & (1<<28)) {file.write(" * Bit 28: [SATA] SATA is configured" + newline);}
189 if (value & (1<<29)) {file.write(" * Bit 29: [SATA] SATA retried" + newline);}
190 if (value & (1<<30)) {file.write(" * Bit 30: [SATA] SATA failed" + newline);}
191 if (value & (1<<31)) {file.write(" * Bit 31: Reserved" + newline);}
192 }
194 // Help function for decoding PRM_RSTST register as well as the copy of PRM_RSTST saved with tracing vectors
195 function decode_prm_rstst(value)
196 {
197 if (reg_val & 1<<0 ) {file.write(" * Bit 0 : GLOBAL_COLD_RST" + newline);}
198 if (reg_val & 1<<1 ) {file.write(" * Bit 1 : GLOBAL_WARM_RST" + newline);}
199 if (reg_val & 1<<2 ) {file.write(" * Bit 2 : MPU_SECURITY_VIOL_RST" + newline);}
200 if (reg_val & 1<<3 ) {file.write(" * Bit 3 : MPU_WDT_RST: WD_TIMER2 and MPU subsystem watchdog reset event" + newline);}
201 if (reg_val & 1<<4 ) {file.write(" * Bit 4 : SECURE_WDT_RST" + newline);}
202 if (reg_val & 1<<5 ) {file.write(" * Bit 5 : EXTERNAL_WARM_RST" + newline);}
203 if (reg_val & 1<<6 ) {file.write(" * Bit 6 : VDD_MPU_VOLT_MGR_RST" + newline);}
204 if (reg_val & 1<<7 ) {file.write(" * Bit 7 : VDD_MM_VOLT_MGR_RST" + newline);}
205 if (reg_val & 1<<8 ) {file.write(" * Bit 8 : VDD_CORE_VOLT_MGR_RST" + newline);}
206 if (reg_val & 1<<9 ) {file.write(" * Bit 9 : ICEPICK_RST" + newline);}
207 if (reg_val & 1<<10 ) {file.write(" * Bit 10 : C2C_RST" + newline);}
208 if (reg_val & 1<<11 ) {file.write(" * Bit 11 : TSHUT_MPU_RST" + newline);}
209 if (reg_val & 1<<12 ) {file.write(" * Bit 12 : TSHUT_MM_RST" + newline);}
210 if (reg_val & 1<<13 ) {file.write(" * Bit 13 : TSHUT_CORE_RST" + newline);}
211 if (reg_val & 1<<14 ) {file.write(" * Bit 14 : LLI_RST" + newline);}
212 if (reg_val & 1<<15 ) {file.write(" * Bit 15 : TSHUT_DSPEVE_RST" + newline);}
213 if (reg_val & 1<<16 ) {file.write(" * Bit 16 : TSHUT_IVA_RST" + newline);}
214 }
216 // Build a filename that includes date/time
217 var today = new Date();
218 var year4digit = today.getFullYear();
219 var month2digit = ("0" + (today.getMonth()+1)).slice(-2);
220 var day2digit = ("0" + today.getDate()).slice(-2);
221 var hour2digit = ("0" + today.getHours()).slice(-2);
222 var minutes2digit = ("0" + today.getMinutes()).slice(-2);
223 var seconds2digit = ("0" + today.getSeconds()).slice(-2);
224 var filename_date = '_' + year4digit + '-' + month2digit + '-' + day2digit + '_' + hour2digit + minutes2digit + seconds2digit;
225 var userHomeFolder = System.getProperty("user.home");
226 var filename = userHomeFolder + '/Desktop/' + 'am57xx-boot' + filename_date + '.txt';
228 file = new java.io.FileWriter(filename);
230 debugSessionDAP = ds.openSession("*","CS_DAP_DebugSS");
231 debugSessionDAP.target.connect();
233 /* Check ID_CODE register (address 0x4AE0C204) to determine which
234 AM57xx variant is being used */
235 try {
236 id_code = debugSessionDAP.memory.readWord(0,0x4AE0C204,false);
237 } catch(ex) {
238 print("\n Trouble reading ID_CODE.\n");
239 }
241 print("ID_CODE = 0x" + d2h(id_code));
243 // Check STD_FUSE_ID_2 register (address 0x4AE0C20C) for package type
244 try {
245 fuse_id_2 = debugSessionDAP.memory.readWord(0,0x4AE0C20C,false);
246 } catch(ex) {
247 print("\n Trouble reading STD_FUSE_ID_2.\n");
248 }
249 pkg_type = (fuse_id_2 & 0x00030000) >> 16; // FUSE_ID_2[17:16] = pkg_type
251 switch(id_code) {
252 case 0x0B9BC02F:
253 print("AM571x SR1.0 detected.\n");
254 device_type = 571;
255 break;
256 case 0x1B9BC02F:
257 if(pkg_type == 1) {
258 print("AM570x SR2.0 detected.\n");
259 device_type = 570;
260 } else if(pkg_type == 2) {
261 print("AM571x SR2.0 detected.\n");
262 device_type = 571;
263 } else
264 print("AM571x/AM570x SR2.0 unrecognized package type\n")
265 break;
266 case 0x2B9BC02F:
267 if(pkg_type == 1) {
268 print("AM570x SR2.1 detected.\n");
269 device_type = 570;
270 } else if(pkg_type == 2) {
271 print("AM571x SR2.1 detected.\n");
272 device_type = 571;
273 } else
274 print("AM571x/AM570x SR2.1 unrecognized package type\n")
275 break;
276 case 0x0B99002F:
277 print("AM572x SR1.0 detected.\n");
278 device_type = 572;
279 break;
280 case 0x1B99002F:
281 print("AM572x SR1.1 detected.\n");
282 device_type = 572;
283 break;
284 case 0x2B99002F:
285 print("AM572x SR2.0 detected.\n");
286 device_type = 572;
287 break;
288 case 0x0BB5002F:
289 print("AM574x SR1.0 detected.\n");
290 device_type = 574;
291 break;
292 default:
293 print("Unable to identify which AM57xx variant.\n");
294 debugSessionDAP.target.disconnect();
295 throw("Terminating script.\n")
296 break;
297 }
300 var reg_val;
302 // CTRL_CORE_BOOTSTRAP
303 reg_val = printRegisterValue(debugSessionDAP, "CTRL_CORE_BOOTSTRAP", 0x4A0026C4);
304 if ( (reg_val & (1 << 15)) == (1 << 15) ) {
305 if ( (device_type == 574) || (device_type == 572) )
306 file.write(" * sysboot15 = 1, internal pulldown permanently disabled (recommended for eMMC boot)" + newline);
307 if ( (device_type == 571) || (device_type == 570) )
308 file.write(" * sysboot15 = 1, internal pulldown enabled at boot (recommended for GPMC NOR boot)" + newline);
309 } else {
310 if ( (device_type == 574) || (device_type == 572) )
311 file.write(" * sysboot15 = 0, internal pulldown enabled at boot (recommended for GPMC NOR boot)" + newline);
312 if ( (device_type == 571) || (device_type == 570) )
313 file.write(" * sysboot15 = 0, internal pulldown permanently disabled (recommended for eMMC boot)" + newline);
314 }
315 if ( (reg_val & (1 << 14)) == (1 << 14) ) {file.write(" * sysboot14 = 1, ILLEGAL VALUE!!!" + newline);}
316 if ( (reg_val & (1 << 13)) == (0 << 13) ) {file.write(" * XIP/NAND BOOTDEVICESIZE = 8-bit" + newline);}
317 if ( (reg_val & (1 << 13)) == (1 << 13) ) {file.write(" * XIP/NAND BOOTDEVICESIZE = 16-bit" + newline);}
318 if ( (reg_val & (3 << 11)) == (0 << 11) ) {file.write(" * XIP/NAND MUXCS0DEVICE = Non-muxed" + newline);}
319 if ( (reg_val & (3 << 11)) == (1 << 11) ) {file.write(" * XIP/NAND MUXCS0DEVICE = Muxed" + newline);}
320 if ( (reg_val & (3 << 11)) == (2 << 11) ) {file.write(" * XIP/NAND MUXCS0DEVICE = Reserved (undefined)" + newline);}
321 if ( (reg_val & (3 << 11)) == (3 << 11) ) {file.write(" * XIP/NAND MUXCS0DEVICE = Reserved (undefined)" + newline);}
322 if ( (reg_val & (1 << 10)) == (0 << 10) ) {file.write(" * XIP/NAND BOOTWAITEN, wait pin not monitored" + newline);}
323 if ( (reg_val & (1 << 10)) == (1 << 10) ) {file.write(" * XIP/NAND BOOTWAITEN, wait pin is monitored" + newline);}
324 if ( (reg_val & (3 << 8)) == (0 << 8) ) {file.write(" * SPEEDSELECT = Reserved" + newline);}
325 if ( (reg_val & (3 << 8)) == (1 << 8) ) {file.write(" * SPEEDSELECT = 20 MHz" + newline);}
326 if ( (reg_val & (3 << 8)) == (2 << 8) ) {file.write(" * SPEEDSELECT = 27 MHz" + newline);}
327 if ( (reg_val & (3 << 8)) == (3 << 8) ) {file.write(" * SPEEDSELECT = 19.2 MHz" + newline);}
328 if ( (reg_val & (3 << 6)) == (0 << 6) ) {file.write(" * QSPI offset = 64KB" + newline);}
329 if ( (reg_val & (3 << 6)) == (1 << 6) ) {file.write(" * QSPI offset = 128KB" + newline);}
330 if ( (reg_val & (3 << 6)) == (2 << 6) ) {file.write(" * QSPI offset = 256KB" + newline);}
331 if ( (reg_val & (3 << 6)) == (3 << 6) ) {file.write(" * QSPI offset = 512KB" + newline);}
332 if ( (reg_val & 0x3F) == (0x00) ) {file.write(" * USB -> eMMC" + newline);}
333 if ( (reg_val & 0x3F) == (0x01) ) {file.write(" * USB -> NAND" + newline);}
334 if ( (reg_val & 0x3F) == (0x02) ) {file.write(" * USB -> SD -> eMMC" + newline);}
335 if ( (reg_val & 0x3F) == (0x03) ) {file.write(" * USB -> SATA -> SD" + newline);}
336 if ( (reg_val & 0x3F) == (0x04) ) {file.write(" * USB -> UART -> XIP" + newline);}
337 if ( (reg_val & 0x3F) == (0x05) ) {file.write(" * SD -> XIP" + newline);}
338 if ( (reg_val & 0x3F) == (0x06) ) {file.write(" * SD -> QSPI_1" + newline);}
339 if ( (reg_val & 0x3F) == (0x07) ) {file.write(" * SD -> QSPI_4" + newline);}
340 if ( (reg_val & 0x3F) == (0x08) ) {file.write(" * Undefined" + newline);}
341 if ( (reg_val & 0x3F) == (0x09) ) {file.write(" * Undefined" + newline);}
342 if ( (reg_val & 0x3F) == (0x0A) ) {file.write(" * SD -> Fast XIP" + newline);}
343 if ( (reg_val & 0x3F) == (0x0B) ) {file.write(" * Undefined" + newline);}
344 if ( (reg_val & 0x3F) == (0x0C) ) {file.write(" * Undefined" + newline);}
345 if ( (reg_val & 0x3F) == (0x0D) ) {file.write(" * Undefined" + newline);}
346 if ( (reg_val & 0x3F) == (0x0E) ) {file.write(" * Undefined" + newline);}
347 if ( (reg_val & 0x3F) == (0x0F) ) {file.write(" * Undefined" + newline);}
348 if ( (reg_val & 0x3F) == (0x10) ) {file.write(" * USB" + newline);}
349 if ( (reg_val & 0x3F) == (0x11) ) {file.write(" * Undefined" + newline);}
350 if ( (reg_val & 0x3F) == (0x12) ) {file.write(" * Undefined" + newline);}
351 if ( (reg_val & 0x3F) == (0x13) ) {file.write(" * UART" + newline);}
352 if ( (reg_val & 0x3F) == (0x14) ) {file.write(" * SD -> USB" + newline);}
353 if ( (reg_val & 0x3F) == (0x15) ) {file.write(" * SD -> USB" + newline);}
354 if ( (reg_val & 0x3F) == (0x16) ) {file.write(" * SD -> USB" + newline);}
355 if ( (reg_val & 0x3F) == (0x17) ) {file.write(" * SD -> USB" + newline);}
356 if ( (reg_val & 0x3F) == (0x18) ) {file.write(" * SD -> USB" + newline);}
357 if ( (reg_val & 0x3F) == (0x19) ) {file.write(" * SD -> USB" + newline);}
358 if ( (reg_val & 0x3F) == (0x1A) ) {file.write(" * SD -> USB" + newline);}
359 if ( (reg_val & 0x3F) == (0x1B) ) {file.write(" * SD -> USB" + newline);}
360 if ( (reg_val & 0x3F) == (0x1C) ) {file.write(" * Undefined" + newline);}
361 if ( (reg_val & 0x3F) == (0x1D) ) {file.write(" * Undefined" + newline);}
362 if ( (reg_val & 0x3F) == (0x1E) ) {file.write(" * Undefined" + newline);}
363 if ( (reg_val & 0x3F) == (0x1F) ) {file.write(" * Undefined" + newline);}
364 if ( (reg_val & 0x3F) == (0x20) ) {file.write(" * eMMC -> USB" + newline);}
365 if ( (reg_val & 0x3F) == (0x21) ) {file.write(" * NAND -> USB" + newline);}
366 if ( (reg_val & 0x3F) == (0x22) ) {file.write(" * SD -> eMMC -> USB" + newline);}
367 if ( (reg_val & 0x3F) == (0x23) ) {file.write(" * SATA -> SD -> USB" + newline);}
368 if ( (reg_val & 0x3F) == (0x24) ) {file.write(" * XIP -> USB -> UART" + newline);}
369 if ( (reg_val & 0x3F) == (0x25) ) {file.write(" * XIP -> SD -> USB" + newline);}
370 if ( (reg_val & 0x3F) == (0x26) ) {file.write(" * QSPI_1 -> SD -> USB" + newline);}
371 if ( (reg_val & 0x3F) == (0x27) ) {file.write(" * QSPI_4 -> SD -> USB" + newline);}
372 if ( (reg_val & 0x3F) == (0x28) ) {file.write(" * Undefined" + newline);}
373 if ( (reg_val & 0x3F) == (0x29) ) {file.write(" * Undefined" + newline);}
374 if ( (reg_val & 0x3F) == (0x2A) ) {file.write(" * Undefined" + newline);}
375 if ( (reg_val & 0x3F) == (0x2B) ) {file.write(" * Undefined" + newline);}
376 if ( (reg_val & 0x3F) == (0x2C) ) {file.write(" * Undefined" + newline);}
377 if ( (reg_val & 0x3F) == (0x2D) ) {file.write(" * Undefined" + newline);}
378 if ( (reg_val & 0x3F) == (0x2E) ) {file.write(" * Undefined" + newline);}
379 if ( (reg_val & 0x3F) == (0x2F) ) {file.write(" * Undefined" + newline);}
380 if ( (reg_val & 0x3F) == (0x30) ) {file.write(" * SD" + newline);}
381 if ( (reg_val & 0x3F) == (0x31) ) {file.write(" * Undefined" + newline);}
382 if ( (reg_val & 0x3F) == (0x32) ) {file.write(" * Undefined" + newline);}
383 if ( (reg_val & 0x3F) == (0x33) ) {file.write(" * Undefined" + newline);}
384 if ( (reg_val & 0x3F) == (0x34) ) {file.write(" * SATA" + newline);}
385 if ( (reg_val & 0x3F) == (0x35) ) {file.write(" * XIP" + newline);}
386 if ( (reg_val & 0x3F) == (0x36) ) {file.write(" * QSPI_1" + newline);}
387 if ( (reg_val & 0x3F) == (0x37) ) {file.write(" * QSPI_4" + newline);}
388 if ( (reg_val & 0x3F) == (0x38) ) {file.write(" * eMMC" + newline);}
389 if ( (reg_val & 0x3F) == (0x39) ) {file.write(" * NAND" + newline);}
390 if ( (reg_val & 0x3F) == (0x3A) ) {file.write(" * Fast XIP" + newline);}
391 if ( (reg_val & 0x3F) == (0x3B) ) {file.write(" * eMMC (boot part.)" + newline);}
392 if ( (reg_val & 0x3F) == (0x3C) ) {file.write(" * " + newline);}
393 if ( (reg_val & 0x3F) == (0x3D) ) {file.write(" * " + newline);}
394 if ( (reg_val & 0x3F) == (0x3E) ) {file.write(" * " + newline);}
395 if ( (reg_val & 0x3F) == (0x3F) ) {file.write(" * " + newline);}
397 // Current tracing vector, word 1
398 file.write(newline);
399 reg_val = printRegisterValue(debugSessionDAP, "Current tracing vector, word 1", 0x4037F040);
400 decode_tracing_vector_1(reg_val);
402 // Current tracing vector, word 2
403 file.write(newline);
404 reg_val = printRegisterValue(debugSessionDAP, "Current tracing vector, word 2", 0x4037F044);
405 decode_tracing_vector_2(reg_val);
407 // Current tracing vector, word 3
408 file.write(newline);
409 reg_val = printRegisterValue(debugSessionDAP, "Current tracing vector, word 3", 0x4037F048);
410 decode_tracing_vector_3(reg_val);
412 // Current tracing vector, word 4
413 file.write(newline);
414 reg_val = printRegisterValue(debugSessionDAP, "Current tracing vector, word 4", 0x4037F04C);
415 decode_tracing_vector_4(reg_val);
417 // Cold reset tracing vector, word 1
418 file.write(newline);
419 reg_val = printRegisterValue(debugSessionDAP, "Cold reset tracing vector, word 1", 0x4037F050);
420 decode_tracing_vector_1(reg_val);
422 // Cold reset tracing vector, word 2
423 file.write(newline);
424 reg_val = printRegisterValue(debugSessionDAP, "Cold reset tracing vector, word 2", 0x4037F054);
425 decode_tracing_vector_2(reg_val);
427 // Cold reset tracing vector, word 3
428 file.write(newline);
429 reg_val = printRegisterValue(debugSessionDAP, "Cold reset tracing vector, word 3", 0x4037F058);
430 decode_tracing_vector_3(reg_val);
432 // Cold reset tracing vector, word 4
433 file.write(newline);
434 reg_val = printRegisterValue(debugSessionDAP, "Cold reset tracing vector, word 4", 0x4037F05C);
435 decode_tracing_vector_4(reg_val);
437 // Current copy of the PRM_RSTST register (reset reasons)
438 file.write(newline);
439 reg_val = printRegisterValue(debugSessionDAP, "Current copy of the PRM_RSTST register (reset reasons)", 0x4037F060);
440 decode_prm_rstst(reg_val);
442 // PRM_RSTST register
443 file.write(newline);
444 reg_val = printRegisterValue(debugSessionDAP, "PRM_RSTST", 0x4AE07D04);
445 decode_prm_rstst(reg_val);
447 debugSessionDAP.target.disconnect();
449 file.close();
450 print("Created file " + filename);