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 executed by rpp_make_rtw_hook.m only if the build process
16 % finished successfully and RPP_DOWNLOAD is set to TRUE. The RPP_DOWNLOAD option
17 % is controlled by "Download to RPP board" option in RPP code generation options.
19 % Avoid executing this function with Code Composer Studio running on background.
22 % use_openocd - When set to TRUE, an OpenOCD will be used for the code
23 % download. This tool is available only for Unix based systems.
24 % When set to FALSE, a Texas Instruments Loader will be used.
25 % for the code download. The TI tool is available for Unix based
26 % systems and Windows.
27 % This parameter is controled by "Use OpenOCD to download the compiled binary"
28 % option in RPP code generation options.
29 % use_sdram - When set to TRUE, the code will be downloaded into SDRAM. This option
30 % requires a base code for the MPU, EMIF, POM and SDRAM configuration to
31 % be present in the device Flash memory. The presence of the code is not
33 % When set to FALSE, the code will be downloaded into the Flash memory.
34 % This option is usefull for debugging as the Flash memory has very limited
36 % NOTE: The code execution may be slower from the SDRAM than from the Flash.
37 % NOTE: This function is not yet implemented.
38 % This parameter is controlled by "Download compiled binary to SDRAM"
39 % option in RPP code generation options.
42 % loadti utility wiki at http://processors.wiki.ti.com/index.php/Loadti
43 % Readme file in <cssroot>/ccs_base/scripting/examples/loadti/readme.txt
44 % OpenOCD wiki at https://rtime.felk.cvut.cz/hw/index.php/TMS570LS3137#OpenOCD_setup_and_Flashing
46 function rpp_download(modelName, buildDirectory, use_openocd, use_sdram, ccxml_filename)
47 RppLibRoot = getpref('rpp', 'RppLibRoot');
48 CCSRoot = getpref('rpp', 'CCSRoot');
50 %TODO: parse the EXE_FILE_EXT from target_tools.mk
51 outfile = fullfile(buildDirectory, [modelName, '.out']);
52 downloadLog = fullfile(buildDirectory, 'download.log');
56 disp(['### Sorry, Downloading to the SDRAM is not yet implemented.'])
57 disp(['### -> Uncheck the option "Download compiled binary to SDRAM" (set use_openocd to false) to download the code to the Flash memory.'])
61 RppLibRoot '/../loadopenocd/loadopenocd.sh -d flash -b -s ' ...
62 , outfile, ' 2> ' , downloadLog ];
63 disp('### Running downloader script:');
65 status = system(command);
67 throw(MException('rpp:targetDlErr', ['Failed to download ' modelName ' to the target']))
69 disp(['Done. <a href="matlab:open(''', downloadLog, ''')">Open download log.</a>']);
71 disp(['### Sorry code download via OpenOCD is available for UNIX systems only. Uncheck the option']);
72 disp(['### -> Uncheck the option "Use OpenOCD to download the compiled binary" to use Ti downloader, which is functional under Windows.']);
77 disp(['### Sorry, Downloading to the SDRAM is not yet implemented.'])
78 disp(['### -> Uncheck the option "Download compiled binary to SDRAM" (set use_sdram to false) to download the code to the Flash memory.'])
80 disp(['### Downloading ', modelName, ' to RPP board...']);
82 ccxml_filename = strcat(RppLibRoot, '/../loadti/', strrep(char(ccxml_filename), '"', ''));
83 % -r, --reset Reset target before run
84 % -c, --cfg-file=CONFIG_FILE Target setup config file
86 'CCS_SCRIPTING="' CCSRoot '/ccs_base/scripting/" ' ...
87 '"' RppLibRoot '/../loadti/loadti.sh" -r ' ...
88 '-c "', ccxml_filename, '" ', ...
90 '" 2> "', downloadLog, '"'];
92 ccxml_filename = strcat(RppLibRoot, '\..\loadti\', strrep(char(ccxml_filename), '"', ''));
93 % -r, --reset Reset target before run
94 % -c, --cfg-file=CONFIG_FILE Target setup config file
96 'set CCS_SCRIPTING="' CCSRoot '\ccs_base\DebugServer"&&' ...
97 '"' RppLibRoot '\..\loadti\loadti.bat" -r ' ...
98 '-c "', ccxml_filename, '" ', ...
101 disp('### Running downloader script:');
103 status = system(command, '-echo');
105 throw(MException('rpp:targetDlErr', ['Failed to download ' modelName ' to the target']))
107 disp(['Done. <a href="matlab:open(''', downloadLog, ''')">Open download log.</a>']);