1 /*
2 * Copyright (c) 2006-2014, 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 function printRegisterValue(ds, name, addr)
37 {
38 value = ds.memory.readWord(0,addr,false);
39 value_string = d2h(value);
40 file.write(name + " = 0x" + value_string + "\n");
41 return value; // return the register value for interrogation
42 }
44 function getRegisterValue(ds, addr)
45 {
46 return ds.memory.readWord(0,addr,false);
47 }
49 // Build a filename that includes date/time
50 var today = new Date();
51 var year4digit = today.getFullYear();
52 var month2digit = ("0" + (today.getMonth()+1)).slice(-2);
53 var day2digit = ("0" + today.getDate()).slice(-2);
54 var hour2digit = ("0" + today.getHours()).slice(-2);
55 var minutes2digit = ("0" + today.getMinutes()).slice(-2);
56 var seconds2digit = ("0" + today.getSeconds()).slice(-2);
57 var filename_date = '_' + year4digit + '-' + month2digit + '-' + day2digit + '_' + hour2digit + minutes2digit + seconds2digit;
58 var userHomeFolder = System.getProperty("user.home");
59 var filename = userHomeFolder + '/Desktop/' + 'am335x-ds0-analysis' + filename_date + '.txt';
61 debugSessionDAP = ds.openSession("*","CS_DAP_M3");
63 try {
64 debugSessionDAP.target.connect();
65 } catch (ex) {
66 print("\n ERROR: Could not connect to DAP_M3.\n");
67 }
69 file = new java.io.FileWriter(filename);
72 var reg_val;
74 // PRM_MPU: PM_MPU_PWRSTST
75 reg_val = printRegisterValue(debugSessionDAP, "PRM_MPU: PM_MPU_PWRSTST", 0x44E00E04);
76 if ( reg_val == 0 ) {
77 file.write(" * Cortex A8 is OFF.\n");
78 } else {
79 file.write(" * ERROR: Cortex A8 is still on!\n");
80 }
82 // PRM_GFX: PM_GFX_PWRSTST
83 reg_val = printRegisterValue(debugSessionDAP, "PRM_GFX: PM_GFX_PWRSTST", 0x44E01110);
84 if ( reg_val == 0 ) {
85 file.write(" * SGX530 is OFF.\n");
86 } else {
87 file.write(" * ERROR: SGX530 is still on!\n");
88 }
90 // PRM_PER: PM_PER_PWRSTST
91 reg_val = printRegisterValue(debugSessionDAP, "PRM_PER: PM_PER_PWRSTST", 0x44E00C08);
92 if ( reg_val == 0x00200001 ) {
93 file.write(" * PER domain in retention (OCMC RAM retained).\n");
94 } else if ( reg_val&3 == 3) {
95 file.write(" * ERROR: PER domain still on!\n");
97 // CM_PER: CM_PER_L4LS_CLKSTCTRL
98 reg_val = printRegisterValue(debugSessionDAP, "CM_PER: CM_PER_L4LS_CLKSTCTRL", 0x44E00000);
99 if ( reg_val & 1<<28 ) {file.write(" * ERROR: TIMER6 active!\n");}
100 if ( reg_val & 1<<27 ) {file.write(" * ERROR: TIMER5 active!\n");}
101 if ( reg_val & 1<<25 ) {file.write(" * ERROR: SPI active!\n");}
102 if ( reg_val & 1<<24 ) {file.write(" * ERROR: I2C active!\n");}
103 if ( reg_val & 1<<21 ) {file.write(" * ERROR: GPIO3 active!\n");}
104 if ( reg_val & 1<<20 ) {file.write(" * ERROR: GPIO2 active!\n");}
105 if ( reg_val & 1<<19 ) {file.write(" * ERROR: GPIO1 active!\n");}
106 if ( reg_val & 1<<17 ) {file.write(" * ERROR: LCDC active!\n");}
107 if ( reg_val & 1<<16 ) {file.write(" * ERROR: TIMER4 active!\n");}
108 if ( reg_val & 1<<15 ) {file.write(" * ERROR: TIMER3 active!\n");}
109 if ( reg_val & 1<<14 ) {file.write(" * ERROR: TIMER2 active!\n");}
110 if ( reg_val & 1<<13 ) {file.write(" * ERROR: TIMER7 active!\n");}
111 if ( reg_val & 1<<11 ) {file.write(" * ERROR: CAN active!\n");}
112 if ( reg_val & 1<<10 ) {file.write(" * ERROR: UART active!\n");}
113 if ( reg_val & 1<<8 ) {file.write(" * ERROR: L4LS active!\n");}
115 // CM_PER: CM_PER_L3_CLKSTCTRL
116 reg_val = printRegisterValue(debugSessionDAP, "CM_PER: CM_PER_L3_CLKSTCTRL", 0x44E0000C);
117 if ( reg_val & 1<<7 ) {file.write(" * ERROR: MCASP active!\n");}
118 if ( reg_val & 1<<6 ) {file.write(" * ERROR: CPTS_RFT active!\n");}
119 if ( reg_val & 1<<4 ) {file.write(" * ERROR: L3 active!\n");}
120 if ( reg_val & 1<<3 ) {file.write(" * ERROR: MMC active!\n");}
121 if ( reg_val & 1<<2 ) {file.write(" * ERROR: EMIF active!\n");}
122 } else {
123 file.write(" * ERROR: Manually inspect PER domain. Unexpected combo.\n");
124 }
126 file.close();
127 print("Created file " + filename);
129 /***************************************************************************************
130 Create CSV File that dumps out padconf data for use
131 in conjunction with the spreadsheet from:
132 http://processors.wiki.ti.com/index.php/Optimizing_AM335x_IO_Power_in_DeepSleep0
133 ****************************************************************************************/
137 var filename = userHomeFolder + '/Desktop/' + 'am335x-ds0-padconf' + filename_date + '.csv';
138 file = new java.io.FileWriter(filename);
140 var ds0_padconf_regs = [
141 0x44E10800,
142 0x44E10804,
143 0x44E10808,
144 0x44E1080c,
145 0x44E10810,
146 0x44E10814,
147 0x44E10818,
148 0x44E1081c,
149 0x44E10820,
150 0x44E10824,
151 0x44E10828,
152 0x44E1082c,
153 0x44E10830,
154 0x44E10834,
155 0x44E10838,
156 0x44E1083c,
157 0x44E10840,
158 0x44E10844,
159 0x44E10848,
160 0x44E1084c,
161 0x44E10850,
162 0x44E10854,
163 0x44E10858,
164 0x44E1085c,
165 0x44E10860,
166 0x44E10864,
167 0x44E10868,
168 0x44E1086c,
169 0x44E10870,
170 0x44E10874,
171 0x44E10878,
172 0x44E1087c,
173 0x44E10880,
174 0x44E10884,
175 0x44E10888,
176 0x44E1088c,
177 0x44E10890,
178 0x44E10894,
179 0x44E10898,
180 0x44E1089c,
181 0x44E108a0,
182 0x44E108a4,
183 0x44E108a8,
184 0x44E108ac,
185 0x44E108b0,
186 0x44E108b4,
187 0x44E108b8,
188 0x44E108bc,
189 0x44E108c0,
190 0x44E108c4,
191 0x44E108c8,
192 0x44E108cc,
193 0x44E108d0,
194 0x44E108d4,
195 0x44E108d8,
196 0x44E108dc,
197 0x44E108e0,
198 0x44E108e4,
199 0x44E108e8,
200 0x44E108ec,
201 0x44E108f0,
202 0x44E108f4,
203 0x44E108f8,
204 0x44E108fc,
205 0x44E10900,
206 0x44E10904,
207 0x44E10908,
208 0x44E1090c,
209 0x44E10910,
210 0x44E10914,
211 0x44E10918,
212 0x44E1091c,
213 0x44E10920,
214 0x44E10924,
215 0x44E10928,
216 0x44E1092c,
217 0x44E10930,
218 0x44E10934,
219 0x44E10938,
220 0x44E1093c,
221 0x44E10940,
222 0x44E10944,
223 0x44E10948,
224 0x44E1094c,
225 0x44E10950,
226 0x44E10954,
227 0x44E10958,
228 0x44E1095c,
229 0x44E10960,
230 0x44E10964,
231 0x44E10968,
232 0x44E1096c,
233 0x44E10970,
234 0x44E10974,
235 0x44E10978,
236 0x44E1097c,
237 0x44E10980,
238 0x44E10984,
239 0x44E10988,
240 0x44E1098c,
241 0x44E10990,
242 0x44E10994,
243 0x44E10998,
244 0x44E1099c,
245 0x44E109a0,
246 0x44E109a4,
247 0x44E109a8,
248 0x44E109ac,
249 0x44E109b0,
250 0x44E109b4,
251 0x44E109b8,
252 0x44E109bc,
253 0x44E109c0,
254 0x44E109c4,
255 0x44E109c8,
256 0x44E109d0,
257 0x44E109d4,
258 0x44E109d8,
259 0x44E109dc,
260 0x44E109e0,
261 0x44E109e4,
262 0x44E109e8,
263 0x44E109ec,
264 0x44E109f0,
265 0x44E109f8,
266 0x44E10a00,
267 0x44E109f4,
268 0x44E10a04,
269 0x44E10a08,
270 0x44E10a0c,
271 0x44E10a10,
272 0x44E10a14,
273 0x44E10a18,
274 0x44E10a1c,
275 0x44E10a20,
276 0x44E10a24,
277 0x44E10a28,
278 0x44E10a2c,
279 0x44E10a30,
280 0x44E10a34];
282 // Column Headers for CSV
283 file.write("Address,dts offset,Raw Reg Val,Mux Mode,Pull,RxActive,Slew\r\n");
285 // Fill out one line per loop iteration
286 for (i=0; i<ds0_padconf_regs.length; i++)
287 {
288 reg_val = getRegisterValue(debugSessionDAP, ds0_padconf_regs[i]);
289 file.write("0x" + d2h(ds0_padconf_regs[i])); // Address
290 file.write(",0x" + d2h(ds0_padconf_regs[i]-0x44e10800)); // dts offset
291 file.write(",0x" + d2h(reg_val)); // Raw Reg Val
292 file.write("," + (reg_val & 7) ); // Mux Mode
294 // Pullup/Pulldown Decoding
295 if ( (reg_val & (1<<3)) == 0 )
296 {
297 if( (reg_val & (1<<4)) == 0 )
298 file.write(",pulldown");
299 else
300 file.write(",pullup");
301 }
302 else
303 {
304 file.write(",no pull");
305 }
307 // RxActive
308 if( (reg_val & (1<<5)) )
309 file.write(",enabled");
310 else
311 file.write(",disabled");
313 // Slew
314 if( (reg_val & (1<<6)) )
315 file.write(",slow");
316 else
317 file.write(",fast");
319 file.write("\r\n"); // CSV specifies CR/LF for line endings
321 }
323 file.close();
324 print("Created file " + filename);
326 debugSessionDAP.target.disconnect();