2023-05-03 14:54:13 +03:00
/ *
* Copyright ( c ) 2021 , 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 .
* /
/ *
Description :
Load executables to various CPUs on the SOC
Usage :
1. Modify "sdkPath" ( search for EDIT THIS ) to point to the absolute path of the SDK .
- On windows make sure to use '/' or '\\' as path separator
2. Launch AM64x _GP _EVM target connection in CCS , however DO NOT connect to any CPUs .
3. From CCS Scripting console do ( CCS Tool Bar > View > Scripting Console )
js : > loadJSFile "<path/to/sdk>/tools/ccs_load/am64x/load.js"
4. After successful execution you should see a log like below
js : > loadJSFile "C:/ti/mcu_plus_sdk/tools/ccs_load/am64x/load.js"
Connecting , halting , reseting ...
[ r5fss0 - 0 ] Loading ... C : / t i / m c u _ p l u s _ s d k / e x a m p l e s / d r i v e r s / i p c / i p c _ r p m s g _ e c h o / a m 6 4 x - e v m / r 5 f s s 0 - 0 _ f r e e r t o s / t i - a r m - c l a n g / i p c _ r p m s g _ e c h o . d e b u g . o u t
[ r5fss0 - 1 ] Loading ... C : / t i / m c u _ p l u s _ s d k / e x a m p l e s / d r i v e r s / i p c / i p c _ r p m s g _ e c h o / a m 6 4 x - e v m / r 5 f s s 0 - 1 _ n o r t o s / t i - a r m - c l a n g / i p c _ r p m s g _ e c h o . d e b u g . o u t
[ r5fss1 - 0 ] Loading ... C : / t i / m c u _ p l u s _ s d k / e x a m p l e s / d r i v e r s / i p c / i p c _ r p m s g _ e c h o / a m 6 4 x - e v m / r 5 f s s 1 - 0 _ n o r t o s / t i - a r m - c l a n g / i p c _ r p m s g _ e c h o . d e b u g . o u t
[ r5fss1 - 1 ] Loading ... C : / t i / m c u _ p l u s _ s d k / e x a m p l e s / d r i v e r s / i p c / i p c _ r p m s g _ e c h o / a m 6 4 x - e v m / r 5 f s s 1 - 1 _ n o r t o s / t i - a r m - c l a n g / i p c _ r p m s g _ e c h o . d e b u g . o u t
[ m4fss0 - 0 ] Skipping load , C : / t i / m c u _ p l u s _ s d k / e x a m p l e s / d r i v e r s / i p c / i p c _ r p m s g _ e c h o / a m 6 4 x - e v m / m 4 f s s 0 - 0 _ n o r t o s / t i - a r m - c l a n g / i p c _ r p m s g _ e c h o . d e b u g . o u t f i l e N O T F O U N D . . .
[ r5fss0 - 1 ] Running ...
[ r5fss1 - 0 ] Running ...
[ r5fss1 - 1 ] Running ...
[ r5fss0 - 0 ] Running ...
All DONE ! ! !
5. If any of the logs in step 4 show "fail" or "error" messages then
check your EVM , CCS , SDK setup , Executables path and try again .
6. To reload without power cycles , repeat step 4 onwards .
* /
// !!! EDIT THIS !!! Edit all of below based on the example you want to run
runAfterLoad = true ;
// Указать путь к текущей папке
2023-06-09 13:57:20 +03:00
var script _path = "/home/algin/workspace_v11/sitara_depot/utils/ddr_init/ccs_files" ;
2023-05-03 14:54:13 +03:00
print ( "script_path = " + script _path ) ;
// !!! EDIT THIS !!! Comment lines below for CPUs that are not needed to be loaded, change 'os' based on the 'os' combo that you have
var elf _file = { } ;
elf _file [ "r5fss0-0" ] = script _path + "/am64xevm_ddr_init.release.out" ;
print ( "[load_ddr_init]: elf_file = " + elf _file [ "r5fss0-0" ] ) ;
function connectHaltResetCpu ( cpu )
{
dsCPU [ cpu ] . target . connect ( ) ;
dsCPU [ cpu ] . target . halt ( ) ;
dsCPU [ cpu ] . target . reset ( ) ;
}
function runCpu ( cpu )
{
if ( cpu && File ( elf _file [ cpu ] ) . isFile ( ) )
{
if ( runAfterLoad )
{
print ( "[" + cpu + "] Running ... " ) ;
dsCPU [ cpu ] . target . runAsynch ( ) ;
}
}
}
function loadCpu ( cpu )
{
if ( cpu && File ( elf _file [ cpu ] ) . isFile ( ) )
{
print ( "[" + cpu + "] Loading ... " + elf _file [ cpu ] ) ;
dsCPU [ cpu ] . memory . loadProgram ( elf _file [ cpu ] ) ;
}
else
{
print ( "[" + cpu + "] Skipping load, " + elf _file [ cpu ] + " file NOT FOUND ... " ) ;
}
}
function doEverything ( )
{
/* Set timeout of in units of msecs */
script . setScriptTimeout ( 10 * 1000 ) ;
// Open a debug session
dsCPU [ "r5fss0-0" ] = debugServer . openSession ( ".*MAIN_Cortex_R5_0_0" ) ;
print ( "Connecting, halting, reseting ..." ) ;
connectHaltResetCpu ( "r5fss0-0" ) ;
loadCpu ( "r5fss0-0" ) ;
runCpu ( "r5fss0-0" ) ;
print ( "[load_ddr_init]: Waiting 1 sec while ddr_init works..." ) ;
Thread . sleep ( 1000 ) ;
print ( "[load_ddr_init]: Reseting the CPU..." ) ;
dsCPU [ "r5fss0-0" ] . target . reset ( ) ;
print ( "[load_ddr_init]: All DONE !!!" ) ;
}
// Import the DSS packages into our namespace to save on typing
importPackage ( Packages . com . ti . debug . engine . scripting )
importPackage ( Packages . com . ti . ccstudio . scripting . environment )
importPackage ( Packages . java . lang )
importPackage ( java . io ) ;
importPackage ( java . lang ) ;
var dsCPU = { } ;
var ds ;
var debugServer ;
var script ;
// Check to see if running from within CCSv4 Scripting Console
var withinCCS = ( ds !== undefined ) ;
// !!! EDIT THIS !!! Add absolute path to the CCXML file here.
fileCcxml = script _path + "/am64x_xds560v2.ccxml" ;
// Create scripting environment and get debug server if running standalone
if ( ! withinCCS )
{
// Import the DSS packages into our namespace to save on typing
importPackage ( Packages . com . ti . debug . engine . scripting ) ;
importPackage ( Packages . com . ti . ccstudio . scripting . environment ) ;
importPackage ( Packages . java . lang ) ;
// Create our scripting environment object - which is the main entry point into any script and
// the factory for creating other Scriptable ervers and Sessions
script = ScriptingEnvironment . instance ( ) ;
// Get the Debug Server and start a Debug Session
debugServer = script . getServer ( "DebugServer.1" ) ;
// Check if the CCXML file exists.
if ( ! File ( fileCcxml ) . isFile ( ) )
{
print ( "[ERROR] File " + fileCcxml + " not found !!!" ) ;
print ( "Seems like the script is not run from within CCS. Please edit the load_dmsc_hsfs.js script to add a path to your CCXML configuration file in this case." )
}
else
{
debugServer . setConfig ( fileCcxml ) ;
doEverything ( ) ;
}
}
else // otherwise leverage existing scripting environment and debug server
{
debugServer = ds ;
script = env ;
doEverything ( ) ;
}