1 % Copyright (C) 2013-2014 Czech Technical University in Prague
4 % - Carlos Jenkins <carlos@jenkins.co.cr>
6 % This document contains proprietary information belonging to Czech
7 % Technical University in Prague. Passing on and copying of this
8 % document, and communication of its contents is not permitted
9 % without prior written authorization.
11 % File : rpp_download.m
13 % Code download utility for Simulink RPP Target.
15 % This function is optionally executed at the end of the build process
16 % if it is successful and the user selected "Download compiled binary to
17 % RPP" option on the build configuration panel. This function calls
18 % loadti.sh script with the generated binary and using configuration for
19 % the XDS100v2 JTAG Emulators.
22 % loadti utility wiki at http://processors.wiki.ti.com/index.php/Loadti
23 % Readme file in <cssroot>/ccs_base/scripting/examples/loadti/readme.txt
26 function rpp_download(modelName, buildDirectory, use_openocd, use_sdram)
27 RppLibRoot = getpref('rpp', 'RppLibRoot');
29 %TODO: parse the EXE_FILE_EXT from target_tools.mk
30 outfile = fullfile(buildDirectory, [modelName, '.out']);
31 downloadLog = fullfile(buildDirectory, 'download.log');
34 disp(['OpenOCD will be used.'])
36 disp(['Will download to SDRAM'])
38 RppLibRoot '/../loadopenocd/loadopenocd.sh -d flash -b -s ' ...
39 , outfile, ' 2> ' , downloadLog ];
40 disp('### Running downloader script:');
42 status = system(command);
44 throw(MException('rpp:targetDlErr', ['Failed to download ' modelName ' to the target']))
46 disp(['Done. <a href="matlab:open(''', downloadLog, ''')">Open download log.</a>']);
48 disp(['Will download to Flash'])
50 RppLibRoot '/../loadopenocd/loadopenocd.sh -d flash -b -s ' ...
51 , outfile, ' 2> ' , downloadLog ];
52 disp('### Running downloader script:');
54 status = system(command);
56 throw(MException('rpp:targetDlErr', ['Failed to download ' modelName ' to the target']))
58 disp(['Done. <a href="matlab:open(''', downloadLog, ''')">Open download log.</a>']);
61 disp(['TI DSS Generic Loader will be used.'])
63 disp(['Will download to SDRAM'])
64 disp(['Not yet implemented'])
66 disp(['Will download to Flash'])
70 disp(['### Downloading ', modelName, ' to RPP board...']);
72 % -a, --async-run Run the specified executable and return without halting
73 % -r, --reset Reset target before run
74 % -c, --cfg-file=CONFIG_FILE Target setup config file
76 'CCS_SCRIPTING="' CCSRoot '/ccs_base/scripting/" ' ...
77 '"' RppLibRoot '/../loadti/loadti.sh" -a -r ' ...
78 '-c "', RppLibRoot, '/rpp/TMS570LS3137.ccxml" ', ...
80 '" 2> "', downloadLog, '"'];
81 disp('### Running downloader script:');
83 status = system(command);
85 throw(MException('rpp:targetDlErr', ['Failed to download ' modelName ' to the target']))
88 disp(['Done. <a href="matlab:open(''', downloadLog, ''')">Open download log.</a>']);
91 disp(['### Sorry code download is available for UNIX systems only.']);
92 disp(['### -> Add support for non UNIX systems in <targetroot>/rpp/rpp_download.m file.']);