]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/pdk.git/blob - packages/ti/drv/sciclient/tools/ccsLoadDmsc/j7200/launch.js
J7200: Sciclient Migrate
[processor-sdk/pdk.git] / packages / ti / drv / sciclient / tools / ccsLoadDmsc / j7200 / launch.js
1 /*
2  * Copyright (c) 2018-2019, 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  */
33 //
34 //File Name: launch_j7200.js
35 //Description:
36 //   Launch the DMSC firmware and board configuration from R5F.
37 //
38 //Usage:
39 //
40 //From CCS Scripting console
41 //  1. loadJSFile "C:\\ti\\launch_j7200.js"
42 //
43 //Note:
44 //  1. Search for "edit this" to look at changes that need to be edited
45 //     for your usage.
46 //
49 //<!!!!!! EDIT THIS !!!!!>
50 // Set this to 1 to allow loading the GEL files directly from the ccxml file.
51 disableGelLoad = 0;
52 // Set to 1 to use the firmware with Firewalls.
53 if (disableGelLoad == 0)
54 {
55     //Path to GEL files
56     gelFilePath = "k3-avv-repo/framework/gels/K3J7";
57 }
58 //PDK path. Edit this
59 pdkPath = "/ti/j7presi/workarea/pdk";
61 //path to board config elf
62 ccs_init_elf_file = pdkPath+"/packages/ti/drv/sciclient/tools/ccsLoadDmsc/j7200/sciclient_ccs_init_mcu1_0_release.xer5f";
64 //path to sysfw bin
65 sysfw_bin = pdkPath+"/packages/ti/drv/sciclient/soc/sysfw/binaries/ti-sci-firmware-j7200-gp.bin"
67 //<!!!!!! EDIT THIS !!!!!>
69 // Import the DSS packages into our namespace to save on typing
70 importPackage(Packages.com.ti.debug.engine.scripting)
71 importPackage(Packages.com.ti.ccstudio.scripting.environment)
72 importPackage(Packages.java.lang)
73 importPackage(java.io);
74 importPackage(java.lang);
76 function updateScriptVars()
77 {
78     //Open a debug session
79     dsMCU1_0 = debugServer.openSession( ".*MCU_Cortex_R5_0" );
80     dsDMSC_0 = debugServer.openSession( ".*DMSC_Cortex_M3_0" );
81 }
83 function printVars()
84 {
85     updateScriptVars();
86 }
88 function connectTargets()
89 {
90     /* Set timeout of 20 seconds */
91     script.setScriptTimeout(200000);
92     updateScriptVars();
93     sysResetVar=dsDMSC_0.target.getResetType(1);
94     sysResetVar.issueReset();
95     print("Connecting to DMSC_Cortex_M3_0!");
96     // Connect targets
97     dsDMSC_0.target.connect();
98     print("Fill R5F ATCM memory...");
99     dsDMSC_0.memory.fill(0x61000000, 0, 0x2000, 0);
100     print("Writing While(1) for R5F")
101     dsDMSC_0.memory.writeWord(0, 0x61000000, 0xE59FF004); /* ldr        pc, [pc, #4] */
102     dsDMSC_0.memory.writeWord(0, 0x61000004, 0x38);       /* Address 0x38 */
103     dsDMSC_0.memory.writeWord(0, 0x61000038, 0xEAFFFFFE) /* b          #0x38 */
104     print("Loading DMSC Firmware ... " + sysfw_bin);
105     // Load the DMSC firmware
106     dsDMSC_0.memory.loadRaw(0, 0x40000, sysfw_bin, 32, false);
107     print("DMSC Firmware Load Done...");
108     // Set Stack pointer and Program Counter
109     stackPointer = dsDMSC_0.memory.readWord(0, 0x40000);
110     progCounter = dsDMSC_0.memory.readWord(0, 0x40004);
111     dsDMSC_0.memory.writeRegister("SP", stackPointer);
112     dsDMSC_0.memory.writeRegister("PC", progCounter);
113     print( "DMSC Firmware run starting now...");
114     // Run the DMSC firmware
115     dsDMSC_0.target.runAsynch();
116     print("Connecting to MCU Cortex_R5_0!");
118     // Connect the MCU R5F
119     dsMCU1_0.target.connect();
120     // This is done to support other boot modes. OSPI is the most stable.
121     // MMC is not always stable.
122     bootMode = dsMCU1_0.memory.readWord(0, 0x43000030) & 0xF8;
123     if (bootMode != 0x38)
124     {
125         print("Disable MCU Timer for ROM clean up");
126         dsMCU1_0.memory.writeWord(0, 0x40400010, 0x1); /* Write reset to MCU Timer 0. Left running by ROM */
127         dsMCU1_0.memory.writeWord(0, 0x40F80430, 0xFFFFFFFF); /* Clear Pending Interrupts */
128         dsMCU1_0.memory.writeWord(0, 0x40F80018, 0x0); /* Clear Pending Interrupts */
129         // Reset the R5F to be in clean state.
130         dsMCU1_0.target.reset();
131         // Load the board configuration init file.
132         dsMCU1_0.expression.evaluate('GEL_Load("'+ ccs_init_elf_file +'")');
133         // Run Asynchronously
134         dsMCU1_0.target.runAsynch();
135         print ("Running Async");
136         // Halt the R5F and re-run.
137         dsMCU1_0.target.halt();
138     }
139     // Reset the R5F to be in clean state.
140     dsMCU1_0.target.reset();
141     print("Running the board configuration initialization from R5!");
142     // Load the board configuration init file.
143     dsMCU1_0.memory.loadProgram(ccs_init_elf_file);
144     // Halt the R5F and re-run.
145     dsMCU1_0.target.halt();
146     // Run Synchronously for the executable to finish
147     dsMCU1_0.target.run();
149     /* Run the DDR Configuration */
150     print("J7200 TODO: Running the DDR configuration... Wait till it completes!");
151     //dsDMSC_0.target.halt();
152     //dsDMSC_0.expression.evaluate("J7ES_LPDDR4_Config_Late()");
153     //dsDMSC_0.target.runAsynch();
156 function disconnectTargets()
158     updateScriptVars();
159     // Reset the R5F to be in clean state.
160     dsMCU1_0.target.reset();
161     // Disconnect targets
162     dsDMSC_0.target.disconnect();
165 function doEverything()
167     printVars();
168     connectTargets();
169     disconnectTargets();
170     print("Okay you are good to go.. Happy Debugging!!");
173 var ds;
174 var debugServer;
175 var script;
177 // Check to see if running from within CCSv4 Scripting Console
178 var withinCCS = (ds !== undefined);
180 // Create scripting environment and get debug server if running standalone
181 if (!withinCCS)
183     // Import the DSS packages into our namespace to save on typing
184     importPackage(Packages.com.ti.debug.engine.scripting);
185     importPackage(Packages.com.ti.ccstudio.scripting.environment);
186     importPackage(Packages.java.lang);
188     // Create our scripting environment object - which is the main entry point into any script and
189     // the factory for creating other Scriptable ervers and Sessions
190     script = ScriptingEnvironment.instance();
192     // Get the Debug Server and start a Debug Session
193     debugServer = script.getServer("DebugServer.1");
195 else // otherwise leverage existing scripting environment and debug server
197     debugServer = ds;
198     script = env;
201 doEverything();