]> 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
[OSAL]: Added testcase for task sub module
[processor-sdk/pdk.git] / packages / ti / drv / sciclient / tools / ccsLoadDmsc / j7200 / launch.js
1 /*
2  * Copyright (c) 2018-2022, 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, if using 'freertos'
51 isFreertos = 1;
52 // Set this to 1, if using 'SafeRTOS'
53 isSafertos = 0;
55 //PDK path. Edit this
56 pdkPath = "/ti/j7presi/workarea/pdk";
58 //path to board config elf
59 pathSciclient = pdkPath+"/packages/ti/drv/sciclient/tools/ccsLoadDmsc/j7200/"
60 ccs_init_elf_file = pathSciclient+"sciclient_ccs_init_mcu1_0_release.xer5f";
61 loadSciserverFlag = 1;
62 if(isFreertos == 1)
63 {
64     //Path to FreeRTOS sciserver
65     sciserver_elf_file = pathSciclient+"sciserver_testapp_freertos_mcu1_0_release.xer5f";
66 }
67 else if(isSafertos == 1)
68 {
69     //Path to SafeRTOS sciserver
70     sciserver_elf_file = pathSciclient+"sciserver_testapp_safertos_mcu1_0_release.xer5f";
71 }
73 //path to sysfw bin
74 sysfw_bin = pdkPath+"/packages/ti/drv/sciclient/soc/sysfw/binaries/ti-fs-firmware-j7200-gp.bin"
76 //<!!!!!! EDIT THIS !!!!!>
78 // Import the DSS packages into our namespace to save on typing
79 importPackage(Packages.com.ti.debug.engine.scripting)
80 importPackage(Packages.com.ti.ccstudio.scripting.environment)
81 importPackage(Packages.java.lang);
82 importPackage(Packages.java.io);
84 function updateScriptVars()
85 {
86     //Open a debug session
87     dsMCU1_0 = debugServer.openSession( ".*MCU_Cortex_R5_0" );
88     dsDMSC_0 = debugServer.openSession( ".*DMSC_Cortex_M3_0" );
89 }
91 function printVars()
92 {
93     updateScriptVars();
94 }
96 function connectTargets()
97 {
98     /* Set timeout of 20 seconds */
99     script.setScriptTimeout(200000);
100     updateScriptVars();
101     sysResetVar=dsDMSC_0.target.getResetType(1);
102     sysResetVar.issueReset();
103     print("Connecting to DMSC_Cortex_M3_0!");
104     // Connect targets
105     dsDMSC_0.target.connect();
106     print("Fill R5F ATCM memory...");
107     dsDMSC_0.memory.fill(0x61000000, 0, 0x8000, 0);
108     print("Writing While(1) for R5F")
109     dsDMSC_0.memory.writeWord(0, 0x61000000, 0xE59FF004); /* ldr        pc, [pc, #4] */
110     dsDMSC_0.memory.writeWord(0, 0x61000004, 0x38);       /* Address 0x38 */
111     dsDMSC_0.memory.writeWord(0, 0x61000038, 0xEAFFFFFE) /* b          #0x38 */
112     print("Loading DMSC Firmware ... " + sysfw_bin);
113     // Load the DMSC firmware
114     dsDMSC_0.memory.loadRaw(0, 0x40000, sysfw_bin, 32, false);
115     print("DMSC Firmware Load Done...");
116     // Set Stack pointer and Program Counter
117     stackPointer = dsDMSC_0.memory.readWord(0, 0x40000);
118     progCounter = dsDMSC_0.memory.readWord(0, 0x40004);
119     dsDMSC_0.memory.writeRegister("SP", stackPointer);
120     dsDMSC_0.memory.writeRegister("PC", progCounter);
121     print( "DMSC Firmware run starting now...");
122     // Run the DMSC firmware
123     dsDMSC_0.target.runAsynch();
124     /* Run the DDR Configuration */
125     print("J7200 Running the DDR configuration... Wait till it completes!");
126     dsDMSC_0.target.halt();
127     dsDMSC_0.expression.evaluate("J7ES_LPDDR4_Config_Late()");
128     dsDMSC_0.target.runAsynch();
129     print("Connecting to MCU Cortex_R5_0!");
131     // Connect the MCU R5F
132     dsMCU1_0.target.connect();
133     // This is done to support other boot modes. OSPI is the most stable.
134     // MMC is not always stable.
135     bootMode = dsMCU1_0.memory.readWord(0, 0x43000030) & 0xF8;
136     print (" WKUP Boot Mode is " + bootMode);
137     mainBootMode = dsMCU1_0.memory.readWord(0, 0x100030) & 0xFF;
138     print (" Main Boot Mode is " + mainBootMode);
139     if ((bootMode != 0x38) || (mainBootMode != 0x11))
140     {
141         print("Disable MCU Timer for ROM clean up");
142         dsMCU1_0.memory.writeWord(0, 0x40400010, 0x1); /* Write reset to MCU Timer 0. Left running by ROM */
143         dsMCU1_0.memory.writeWord(0, 0x40F80430, 0xFFFFFFFF); /* Clear Pending Interrupts */
144         dsMCU1_0.memory.writeWord(0, 0x40F80018, 0x0); /* Clear Pending Interrupts */
145         // Reset the R5F to be in clean state.
146         dsMCU1_0.target.reset();
147         // Load the board configuration init file.
148         dsMCU1_0.expression.evaluate('GEL_Load("'+ ccs_init_elf_file +'")');
149         // Run Asynchronously
150         dsMCU1_0.target.runAsynch();
151         print ("Running Async");
152         // Halt the R5F and re-run.
153         dsMCU1_0.target.halt();
154     }
155     // Reset the R5F to be in clean state.
156     dsMCU1_0.target.reset();
157     print("Running the board configuration initialization from R5!");
158     // Load the board configuration init file.
159     dsMCU1_0.memory.loadProgram(ccs_init_elf_file);
160     // Halt the R5F and re-run.
161     dsMCU1_0.target.halt();
162     // Run Synchronously for the executable to finish
163     dsMCU1_0.target.run();
164     dsMCU1_0.target.halt();
165     dsMCU1_0.target.reset();
168     dsMCU1_0.target.restart();
169     
172 function disconnectTargets()
174     updateScriptVars();
175     // Reset the R5F to be in clean state.
176     dsMCU1_0.target.reset();
177     // Disconnect targets
178     dsDMSC_0.target.disconnect();
181 function sampleDDRCheck ()
183     print("Running DDR Memory Checks....");
184     dsMCU1_0.memory.fill (0x80000000, 0, 1024, 0xA5A5A5A5);
185     ar = dsMCU1_0.memory.readWord(0, 0x80000000, 1024);
186     fail = 0 
187     for (i = 0; i < ar.length; i++) {
188             x = ar[i]; 
189             if (x != 0xA5A5A5A5)
190             {   
191                 fail = 1;
192             }
193         } 
194     if (fail == 1)
195     {   
196         print ("0x80000000: DDR memory sample check failed !!");
197     }
198     dsMCU1_0.memory.fill (0x81000000, 0, 1024, 0x5A5A5A5A);
199     ar = dsMCU1_0.memory.readWord(0, 0x81000000, 1024);
200     fail = 0 
201     for (i = 0; i < ar.length; i++) {
202             x = ar[i]; 
203             if (x != 0x5a5a5a5a)
204             {   
205                 fail = 1;
206             }
207         } 
208     if (fail == 1)
209     {   
210         print ("0x81000000: DDR memory sample check failed !!");
211     }
215 function loadSciserver()
217     updateScriptVars();
218     print("######################################################################################");
219     print("Loading Sciserver Application on MCU1_0. This will service RM/PM messages");
220     print("If you do not want this to be loaded update the launch script to make loadSciserverFlag = 0");
221     print("If you want to load and run other cores, please run the MCU1_0 core after Sciserver is loaded. ");
222     print("######################################################################################");
223     dsMCU1_0.expression.evaluate('GEL_Load("'+ sciserver_elf_file +'")');
226 function doEverything()
228     printVars();
229     connectTargets();
230     disconnectTargets();
231     sampleDDRCheck ();
232     if (loadSciserverFlag == 1)
233     {
234         loadSciserver();
235     }
236     print("Happy Debugging!!");
239 var ds;
240 var debugServer;
241 var script;
243 // Check to see if running from within CCSv4 Scripting Console
244 var withinCCS = (ds !== undefined);
246 // Create scripting environment and get debug server if running standalone
247 if (!withinCCS)
249     // Import the DSS packages into our namespace to save on typing
250     importPackage(Packages.com.ti.debug.engine.scripting);
251     importPackage(Packages.com.ti.ccstudio.scripting.environment);
252     importPackage(Packages.java.lang);
254     // Create our scripting environment object - which is the main entry point into any script and
255     // the factory for creating other Scriptable ervers and Sessions
256     script = ScriptingEnvironment.instance();
258     // Get the Debug Server and start a Debug Session
259     debugServer = script.getServer("DebugServer.1");
261 else // otherwise leverage existing scripting environment and debug server
263     debugServer = ds;
264     script = env;
267 doEverything();