]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - rpp/rpp/rpp_download.m
Do not ignore errors when downloading binary to the target
[pes-rpp/rpp-simulink.git] / rpp / rpp / rpp_download.m
1 % Copyright (C) 2013-2014 Czech Technical University in Prague
2 %
3 % Authors:
4 %     - Carlos Jenkins <carlos@jenkins.co.cr>
5 %
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.
10 %
11 % File : rpp_download.m
12 % Abstract:
13 %     Code download utility for Simulink RPP Target.
14 %
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.
20 %
21 % References:
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
24
25
26 function rpp_download(modelName, buildDirectory)
27
28     CCSRoot    = getpref('rpp', 'CCSRoot');
29     RppLibRoot = getpref('rpp', 'RppLibRoot');
30
31     %TODO: parse the EXE_FILE_EXT from target_tools.mk
32     outfile     = fullfile(buildDirectory, [modelName, '.out']);
33     downloadLog = fullfile(buildDirectory, 'download.log');
34
35     if isunix
36
37         disp(['### Downloading ', modelName, ' to RPP board...']);
38
39         % -a,   --async-run             Run the specified executable and return without halting
40         % -r,   --reset                 Reset target before run
41         % -c,   --cfg-file=CONFIG_FILE  Target setup config file
42         command = [...
43             'CCS_SCRIPTING="' CCSRoot '/ccs_base/scripting/" ' ...
44             '"' RppLibRoot '/../loadti/loadti.sh" -a -r ' ...
45             '-c "', RppLibRoot, '/rpp/TMS570LS3137.ccxml" ', ...
46             '"', outfile, ...
47             '" 2> "', downloadLog, '"'];
48         disp('### Running downloader script:');
49         disp(command);
50         status = system(command);
51         if status ~= 0,
52             throw(MException('rpp:targetDlErr', ['Failed to download ' modelName ' to the target']))
53         end
54
55         disp(['Done. <a href="matlab:open(''', downloadLog, ''')">Open download log.</a>']);
56
57     else
58         disp(['### Sorry code download is available for UNIX systems only.']);
59         disp(['###     -> Add support for non UNIX systems in <targetroot>/rpp/rpp_download.m file.']);
60     end
61 end