/* * Copyright (c) 2006-2014, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ function d2h(d) {return ("00000000" + (d).toString(16)).slice(-8);} function printRegisterValue(ds, name, addr) { value = debugSessionDAP.memory.readWord(0,addr,false); value_string = d2h(value); file.write(name + " = 0x" + value_string + "\n"); return value; // return the register value for interrogation } // Build a filename that includes date/time var today = new Date(); var year4digit = today.getFullYear(); var month2digit = ("0" + (today.getMonth()+1)).slice(-2); var day2digit = ("0" + today.getDate()).slice(-2); var hour2digit = ("0" + today.getHours()).slice(-2); var minutes2digit = ("0" + today.getMinutes()).slice(-2); var seconds2digit = ("0" + today.getSeconds()).slice(-2); var filename_date = '_' + year4digit + '-' + month2digit + '-' + day2digit + '_' + hour2digit + minutes2digit + seconds2digit; var userHomeFolder = System.getProperty("user.home"); var filename = userHomeFolder + '/Desktop/' + 'am335x-ds0-analysis' + filename_date + '.txt'; debugSessionDAP = ds.openSession("*","CS_DAP_M3"); try { debugSessionDAP.target.connect(); } catch (ex) { print("\n ERROR: Could not connect to DAP_M3.\n"); } file = new java.io.FileWriter(filename); var reg_val; // PRM_MPU: PM_MPU_PWRSTST reg_val = printRegisterValue(debugSessionDAP, "PRM_MPU: PM_MPU_PWRSTST", 0x44E00E04); if ( reg_val == 0 ) { file.write(" * Cortex A8 is OFF.\n"); } else { file.write(" * ERROR: Cortex A8 is still on!\n"); } // PRM_GFX: PM_GFX_PWRSTST reg_val = printRegisterValue(debugSessionDAP, "PRM_GFX: PM_GFX_PWRSTST", 0x44E01110); if ( reg_val == 0 ) { file.write(" * SGX530 is OFF.\n"); } else { file.write(" * ERROR: SGX530 is still on!\n"); } // PRM_PER: PM_PER_PWRSTST reg_val = printRegisterValue(debugSessionDAP, "PRM_PER: PM_PER_PWRSTST", 0x44E00C08); if ( reg_val == 0x00200001 ) { file.write(" * PER domain in retention (OCMC RAM retained).\n"); } else if ( reg_val&3 == 3) { file.write(" * ERROR: PER domain still on!\n"); // CM_PER: CM_PER_L4LS_CLKSTCTRL reg_val = printRegisterValue(debugSessionDAP, "CM_PER: CM_PER_L4LS_CLKSTCTRL", 0x44E00000); if ( reg_val & 1<<28 ) {file.write(" * ERROR: TIMER6 active!\n");} if ( reg_val & 1<<27 ) {file.write(" * ERROR: TIMER5 active!\n");} if ( reg_val & 1<<25 ) {file.write(" * ERROR: SPI active!\n");} if ( reg_val & 1<<24 ) {file.write(" * ERROR: I2C active!\n");} if ( reg_val & 1<<21 ) {file.write(" * ERROR: GPIO3 active!\n");} if ( reg_val & 1<<20 ) {file.write(" * ERROR: GPIO2 active!\n");} if ( reg_val & 1<<19 ) {file.write(" * ERROR: GPIO1 active!\n");} if ( reg_val & 1<<17 ) {file.write(" * ERROR: LCDC active!\n");} if ( reg_val & 1<<16 ) {file.write(" * ERROR: TIMER4 active!\n");} if ( reg_val & 1<<15 ) {file.write(" * ERROR: TIMER3 active!\n");} if ( reg_val & 1<<14 ) {file.write(" * ERROR: TIMER2 active!\n");} if ( reg_val & 1<<13 ) {file.write(" * ERROR: TIMER7 active!\n");} if ( reg_val & 1<<11 ) {file.write(" * ERROR: CAN active!\n");} if ( reg_val & 1<<10 ) {file.write(" * ERROR: UART active!\n");} if ( reg_val & 1<<8 ) {file.write(" * ERROR: L4LS active!\n");} // CM_PER: CM_PER_L3_CLKSTCTRL reg_val = printRegisterValue(debugSessionDAP, "CM_PER: CM_PER_L3_CLKSTCTRL", 0x44E0000C); if ( reg_val & 1<<7 ) {file.write(" * ERROR: MCASP active!\n");} if ( reg_val & 1<<6 ) {file.write(" * ERROR: CPTS_RFT active!\n");} if ( reg_val & 1<<4 ) {file.write(" * ERROR: L3 active!\n");} if ( reg_val & 1<<3 ) {file.write(" * ERROR: MMC active!\n");} if ( reg_val & 1<<2 ) {file.write(" * ERROR: EMIF active!\n");} } else { file.write(" * ERROR: Manually inspect PER domain. Unexpected combo.\n"); } file.close(); print("Created file " + filename); debugSessionDAP.target.disconnect();