/* * Copyright (c) 2019, 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. * */ var padconf_registers_am571x_am570x = [ 0x4A003400, 0x4A003404, 0x4A003408, 0x4A00340C, 0x4A003410, 0x4A003414, 0x4A003418, 0x4A00341C, 0x4A003420, 0x4A003424, 0x4A003428, 0x4A00342C, 0x4A003430, 0x4A003434, 0x4A003438, 0x4A00343C, 0x4A003440, 0x4A003444, 0x4A003448, 0x4A00344C, 0x4A003450, 0x4A003454, 0x4A003458, 0x4A00345C, 0x4A003460, 0x4A003464, 0x4A003468, 0x4A00346C, 0x4A003470, 0x4A003474, 0x4A003478, 0x4A00347C, 0x4A003480, 0x4A003484, 0x4A003488, 0x4A00348C, 0x4A003490, 0x4A003494, 0x4A003498, 0x4A00349C, 0x4A0034A0, 0x4A0034A4, 0x4A0034A8, 0x4A0034AC, 0x4A0034B0, 0x4A0034B4, 0x4A0034B8, 0x4A0034BC, 0x4A0034C0, 0x4A0034C4, 0x4A0034C8, 0x4A0034CC, 0x4A0034D0, 0x4A0034D4, 0x4A0034D8, 0x4A003554, 0x4A003558, 0x4A00355C, 0x4A003560, 0x4A003564, 0x4A003568, 0x4A00356C, 0x4A003570, 0x4A003574, 0x4A003578, 0x4A00357C, 0x4A003580, 0x4A003584, 0x4A003588, 0x4A00358C, 0x4A003590, 0x4A003594, 0x4A003598, 0x4A00359C, 0x4A0035A0, 0x4A0035A4, 0x4A0035A8, 0x4A0035AC, 0x4A0035B0, 0x4A0035B4, 0x4A0035B8, 0x4A0035BC, 0x4A0035C0, 0x4A0035C4, 0x4A0035C8, 0x4A0035CC, 0x4A0035D0, 0x4A0035D4, 0x4A0035D8, 0x4A0035DC, 0x4A0035E0, 0x4A0035E4, 0x4A0035E8, 0x4A0035EC, 0x4A0035F0, 0x4A0035F4, 0x4A0035F8, 0x4A0035FC, 0x4A003600, 0x4A003604, 0x4A003608, 0x4A00360C, 0x4A003610, 0x4A003614, 0x4A003618, 0x4A00361C, 0x4A003620, 0x4A003624, 0x4A003628, 0x4A00362C, 0x4A003630, 0x4A003634, 0x4A003638, 0x4A00363C, 0x4A003640, 0x4A003644, 0x4A003648, 0x4A00364C, 0x4A003650, 0x4A003654, 0x4A003658, 0x4A00365C, 0x4A003660, 0x4A003664, 0x4A003668, 0x4A00366C, 0x4A003670, 0x4A003674, 0x4A003678, 0x4A00367C, 0x4A003680, 0x4A003684, 0x4A003688, 0x4A00368C, 0x4A003690, 0x4A003694, 0x4A003698, 0x4A00369C, 0x4A0036A0, 0x4A0036A4, 0x4A0036A8, 0x4A0036AC, 0x4A0036B0, 0x4A0036B4, 0x4A0036B8, 0x4A0036BC, 0x4A0036C0, 0x4A0036C4, 0x4A0036C8, 0x4A0036CC, 0x4A0036D0, 0x4A0036D4, 0x4A0036D8, 0x4A0036DC, 0x4A0036E0, 0x4A0036E4, 0x4A0036E8, 0x4A0036EC, 0x4A0036F0, 0x4A0036F4, 0x4A0036F8, 0x4A0036FC, 0x4A003700, 0x4A003704, 0x4A003708, 0x4A00370C, 0x4A003710, 0x4A003714, 0x4A003718, 0x4A00371C, 0x4A003720, 0x4A003724, 0x4A003728, 0x4A00372C, 0x4A003730, 0x4A003734, 0x4A003738, 0x4A00373C, 0x4A003740, 0x4A003744, 0x4A003748, 0x4A00374C, 0x4A003750, 0x4A003754, 0x4A003758, 0x4A00375C, 0x4A003760, 0x4A003764, 0x4A003768, 0x4A00376C, 0x4A003770, 0x4A003774, 0x4A003778, 0x4A00377C, 0x4A003780, 0x4A003784, 0x4A003788, 0x4A00378C, 0x4A003790, 0x4A003794, 0x4A003798, 0x4A00379C, 0x4A0037A0, 0x4A0037A4, 0x4A0037A8, 0x4A0037AC, 0x4A0037B0, 0x4A0037B4, 0x4A0037B8, 0x4A0037BC, 0x4A0037C0, 0x4A0037C4, 0x4A0037C8, 0x4A0037CC, 0x4A0037D0, 0x4A0037D4, 0x4A0037E0, 0x4A0037E4, 0x4A0037E8, 0x4A0037EC, 0x4A0037F0, 0x4A0037F4, 0x4A0037F8, 0x4A0037FC, 0x4A003800, 0x4A003804, 0x4A003808, 0x4A00380C, 0x4A003818, 0x4A003824, 0x4A003828, 0x4A00382C, 0x4A003830, 0x4A003834, 0x4A003838, 0x4A00383C, 0x4A003840, 0x4A003844, 0x4A003848, 0x4A00384C, 0x4A00385C, 0x4A003860, 0x4A003864 ]; var padconf_registers_am574x_am572x = [ 0x4A003400, 0x4A003404, 0x4A003408, 0x4A00340C, 0x4A003410, 0x4A003414, 0x4A003418, 0x4A00341C, 0x4A003420, 0x4A003424, 0x4A003428, 0x4A00342C, 0x4A003430, 0x4A003434, 0x4A003438, 0x4A00343C, 0x4A003440, 0x4A003444, 0x4A003448, 0x4A00344C, 0x4A003450, 0x4A003454, 0x4A003458, 0x4A00345C, 0x4A003460, 0x4A003464, 0x4A003468, 0x4A00346C, 0x4A003470, 0x4A003474, 0x4A003478, 0x4A00347C, 0x4A003480, 0x4A003484, 0x4A003488, 0x4A00348C, 0x4A003490, 0x4A003494, 0x4A003498, 0x4A00349C, 0x4A0034A0, 0x4A0034A4, 0x4A0034A8, 0x4A0034AC, 0x4A0034B0, 0x4A0034B4, 0x4A0034B8, 0x4A0034BC, 0x4A0034C0, 0x4A0034C4, 0x4A0034C8, 0x4A0034CC, 0x4A0034D0, 0x4A0034D4, 0x4A0034D8, 0x4A0034DC, 0x4A0034E0, 0x4A0034E4, 0x4A0034E8, 0x4A0034EC, 0x4A0034F0, 0x4A0034F4, 0x4A0034F8, 0x4A0034FC, 0x4A003500, 0x4A003504, 0x4A003508, 0x4A00350C, 0x4A003510, 0x4A003514, 0x4A003518, 0x4A00351C, 0x4A003520, 0x4A003524, 0x4A003528, 0x4A00352C, 0x4A003530, 0x4A003534, 0x4A003538, 0x4A00353C, 0x4A003540, 0x4A003544, 0x4A003548, 0x4A00354C, 0x4A003550, 0x4A003554, 0x4A003558, 0x4A00355C, 0x4A003560, 0x4A003564, 0x4A003568, 0x4A00356C, 0x4A003570, 0x4A003574, 0x4A003578, 0x4A00357C, 0x4A003580, 0x4A003584, 0x4A003588, 0x4A00358C, 0x4A003590, 0x4A003594, 0x4A003598, 0x4A00359C, 0x4A0035A0, 0x4A0035A4, 0x4A0035A8, 0x4A0035AC, 0x4A0035B0, 0x4A0035B4, 0x4A0035B8, 0x4A0035BC, 0x4A0035C0, 0x4A0035C4, 0x4A0035C8, 0x4A0035CC, 0x4A0035D0, 0x4A0035D4, 0x4A0035D8, 0x4A0035DC, 0x4A0035E0, 0x4A0035E4, 0x4A0035E8, 0x4A0035EC, 0x4A0035F0, 0x4A0035F4, 0x4A0035F8, 0x4A0035FC, 0x4A003600, 0x4A003604, 0x4A003608, 0x4A00360C, 0x4A003610, 0x4A003614, 0x4A003618, 0x4A00361C, 0x4A003620, 0x4A003624, 0x4A003628, 0x4A00362C, 0x4A003630, 0x4A003634, 0x4A003638, 0x4A00363C, 0x4A003640, 0x4A003644, 0x4A003648, 0x4A00364C, 0x4A003650, 0x4A003654, 0x4A003658, 0x4A00365C, 0x4A003660, 0x4A003664, 0x4A003668, 0x4A00366C, 0x4A003670, 0x4A003674, 0x4A003678, 0x4A00367C, 0x4A003680, 0x4A003684, 0x4A003688, 0x4A00368C, 0x4A003690, 0x4A003694, 0x4A003698, 0x4A00369C, 0x4A0036A0, 0x4A0036A4, 0x4A0036A8, 0x4A0036AC, 0x4A0036B0, 0x4A0036B4, 0x4A0036B8, 0x4A0036BC, 0x4A0036C0, 0x4A0036C4, 0x4A0036C8, 0x4A0036CC, 0x4A0036D0, 0x4A0036D4, 0x4A0036D8, 0x4A0036DC, 0x4A0036E0, 0x4A0036E4, 0x4A0036E8, 0x4A0036EC, 0x4A0036F0, 0x4A0036F4, 0x4A0036F8, 0x4A0036FC, 0x4A003700, 0x4A003704, 0x4A003708, 0x4A00370C, 0x4A003710, 0x4A003714, 0x4A003718, 0x4A00371C, 0x4A003720, 0x4A003724, 0x4A003728, 0x4A00372C, 0x4A003730, 0x4A003734, 0x4A003738, 0x4A00373C, 0x4A003740, 0x4A003744, 0x4A003748, 0x4A00374C, 0x4A003750, 0x4A003754, 0x4A003758, 0x4A00375C, 0x4A003760, 0x4A003764, 0x4A003768, 0x4A00376C, 0x4A003770, 0x4A003774, 0x4A003778, 0x4A00377C, 0x4A003780, 0x4A003784, 0x4A003788, 0x4A00378C, 0x4A003790, 0x4A003794, 0x4A003798, 0x4A00379C, 0x4A0037A0, 0x4A0037A4, 0x4A0037A8, 0x4A0037AC, 0x4A0037B0, 0x4A0037B4, 0x4A0037B8, 0x4A0037BC, 0x4A0037C0, 0x4A0037C4, 0x4A0037C8, 0x4A0037CC, 0x4A0037D0, 0x4A0037D4, 0x4A0037E0, 0x4A0037E4, 0x4A0037E8, 0x4A0037EC, 0x4A0037F0, 0x4A0037F4, 0x4A0037F8, 0x4A0037FC, 0x4A003800, 0x4A003804, 0x4A003808, 0x4A00380C, 0x4A003818, 0x4A00381C, 0x4A003820, 0x4A003824, 0x4A003828, 0x4A00382C, 0x4A003830, 0x4A003834, 0x4A003838, 0x4A00383C, 0x4A003840, 0x4A003844, 0x4A003848, 0x4A00384C, 0x4A00385C, 0x4A003860, 0x4A003864 ]; debugSessionDAP = ds.openSession("*","CS_DAP_DebugSS"); debugSessionDAP.target.connect(); /* Check ID_CODE register (address 0x4AE0C204) to determine which AM57xx variant is being used */ try { id_code = debugSessionDAP.memory.readWord(0,0x4AE0C204,false); } catch(ex) { print("\n Trouble reading ID_CODE.\n"); } print("ID_CODE = 0x" + d2h(id_code)); // Check STD_FUSE_ID_2 register (address 0x4AE0C20C) for package type try { fuse_id_2 = debugSessionDAP.memory.readWord(0,0x4AE0C20C,false); } catch(ex) { print("\n Trouble reading STD_FUSE_ID_2.\n"); } pkg_type = (fuse_id_2 & 0x00030000) >> 16; // FUSE_ID_2[17:16] = pkg_type switch(id_code) { case 0x0B9BC02F: print("AM571x SR1.0 detected.\n"); device_type = 571; break; case 0x1B9BC02F: if(pkg_type == 1) { print("AM570x SR2.0 detected.\n"); device_type = 570; } else if(pkg_type == 2) { print("AM571x SR2.0 detected.\n"); device_type = 571; } else print("AM571x/AM570x SR2.0 unrecognized package type\n") break; case 0x2B9BC02F: if(pkg_type == 1) { print("AM570x SR2.1 detected.\n"); device_type = 570; } else if(pkg_type == 2) { print("AM571x SR2.1 detected.\n"); device_type = 571; } else print("AM571x/AM570x SR2.1 unrecognized package type\n") break; case 0x0B99002F: print("AM572x SR1.0 detected.\n"); device_type = 572; break; case 0x1B99002F: print("AM572x SR1.1 detected.\n"); device_type = 572; break; case 0x2B99002F: print("AM572x SR2.0 detected.\n"); device_type = 572; break; case 0x0BB5002F: print("AM574x SR1.0 detected.\n"); device_type = 574; break; default: print("Unable to identify which AM57xx variant.\n"); debugSessionDAP.target.disconnect(); throw("Terminating script.\n") break; } //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/' + 'am57xx-padconf' + filename_date + '.rd1'; file = new java.io.FileWriter(filename); if (device_type == 570) { file.write("PadConf AM570x_SR2.1_SR2.0\n"); padconf_registers = padconf_registers_am571x_am570x; } else if (device_type == 571) { file.write("PadConf AM571x_SR2.0_SR1.0\n"); padconf_registers = padconf_registers_am571x_am570x; } else if (device_type == 572) { file.write("PadConf AM572x_SR2.0_SR1.1\n"); padconf_registers = padconf_registers_am574x_am572x; } else if (device_type == 574) { file.write("PadConf AM574x_SR1.0\n"); padconf_registers = padconf_registers_am574x_am572x; } else { throw("Error -- code shouldn't get here.") } // helper function to create 8-digit hex numbers in ascii format function d2h(d) {return ("00000000" + (+d).toString(16)).slice(-8);} // read CTT data from physical addresses for(i=0; i