-function rpp_download(modelName, makertwObj)
+function rpp_download(modelName, buildDirectory)
CCSRoot = getpref('rpp', 'CCSRoot');
RppLibRoot = getpref('rpp', 'RppLibRoot');
- %TODO: parse the PROGRAM_FILE_EXT from target_tools.mk
- outfile = fullfile(makertwObj.BuildDirectory, [modelName, '.out']);
+ %TODO: parse the EXE_FILE_EXT from target_tools.mk
+ outfile = fullfile(buildDirectory, [modelName, '.out']);
+ downloadLog = fullfile(buildDirectory, 'download.log');
if isunix
CCSRoot, '/ccs_base/scripting/examples/loadti/loadti.sh" -a -r ', ...
'-c "', RppLibRoot, '/TMS570LS3137.ccxml" ', ...
'"', outfile, ...
- '" 2> "', fullfile(makertwObj.BuildDirectory, 'download.log'), '"']);
+ '" 2> "', downloadLog, '"']);
+
+ disp(['Done. <a href="matlab:open(''', downloadLog, ''')">Open download log.</a>']);
else
disp(['### Sorry code download is available for UNIX systems only.']);
disp(['### Build procedure for model: ''', modelName, ...
''' aborted due to an error.']);
+
case 'entry'
% Called at start of code generation process (before anything
% happens).
% FIXME: Implement step integrity verification?
+
case 'before_tlc'
% Called just prior to invoking TLC Compiler (actual code
% generation).
% Valid arguments at this stage are hookMethod, modelName, and
% buildArgs.
+
case 'after_tlc'
% Called just after to invoking TLC Compiler (actual code
% generation).
% FIXME: Implement model tasking mode check?
+
case 'before_make'
% Called after code generation is complete, and just prior to
% kicking off make process (assuming code generation only is not
% Copy extra makefiles and library files to code generation
% directory
- i_write_rpp_files();
+ rpp_write_files(modelName);
disp('********************');
disp('Debug on rpp_make_rtw_hook.m');
disp(buildOpts);
disp('---');
disp(buildArgs);
+ disp('---');
+ disp(rtwRoot);
disp('********************');
+
case 'after_make'
% Called after make process is complete. All arguments are valid at
% this stage.
- % FIXME: Implement here download to RPP hardware.
- % Use buildArgs to check if download is requested.
+ % Download generated binary to the board
+ %rpp_do_download(modelName);
+
case 'exit'
% Called at the end of the build process. All arguments are valid
end
-function i_write_rpp_files
+function rpp_write_files(modelName)
- lCodeGenFolder = Simulink.fileGenControl('getConfig').CodeGenFolder;
- buildAreaDstFolder = fullfile(lCodeGenFolder, 'slprj');
+ modelRoot = Simulink.fileGenControl('getConfig').CodeGenFolder;
+ buildFolder = fullfile(modelRoot, 'slprj');
- % Get CSS configuration variables and create paths configuration makefile
+ % Get configuration variables and create paths configuration makefile
CompilerRoot = getpref('rpp', 'CompilerRoot');
- TargetRoot = getpref('rpp', 'TargetRoot');
- RppLibRoot = getpref('rpp', 'RppLibRoot');
+ CCSRoot = getpref('rpp', 'CCSRoot');
+ TargetRoot = getpref('rpp', 'TargetRoot');
+ RppLibRoot = getpref('rpp', 'RppLibRoot');
- TargetPaths = fullfile(buildAreaDstFolder, 'target_paths.mk');
+ TargetPaths = fullfile(buildFolder, 'target_paths.mk');
fid = fopen(TargetPaths, 'w');
fwrite(fid, sprintf('%s\n\n', '# RPP paths'));
fwrite(fid, sprintf('COMPILER_ROOT = %s\n', CompilerRoot));
+ fwrite(fid, sprintf('CCS_ROOT = %s\n', CCSRoot));
fwrite(fid, sprintf('TARGET_ROOT = %s\n', TargetRoot));
fwrite(fid, sprintf('RPP_LIB_ROOT = %s\n', RppLibRoot));
fclose(fid);
% Copy the RPP version of target_tools.mk into the build area
tgtToolsFile = 'target_tools.mk';
- srcFile = fullfile(TargetRoot, tgtToolsFile);
- dstFile = fullfile(buildAreaDstFolder, tgtToolsFile);
- copyfile(srcFile, dstFile, 'f');
- % Make sure the file is not read-only
- fileattrib(dstFile, '+w');
-
- copyfile(fullfile(RppLibRoot, '/tmp/os_tasks.c'), ...
- fullfile(buildAreaDstFolder, 'os_tasks.c'), 'f');
+ copyfile(fullfile(TargetRoot, tgtToolsFile), ...
+ fullfile(buildFolder, tgtToolsFile));
+
+ % Copy dependecy sources
+ FIXMERppLibRoot = fullfile(RppLibRoot, 'tmp');
+ OutputFolder = fullfile(modelRoot, [modelName, '_rpp']); % TODO: get suffix from rpp.tlc BuildDirSuffix
+ OSSources = rpp_sources_required('freertos');
+ for i = OSSources
+ copyfile(fullfile(FIXMERppLibRoot, i{1}), ...
+ fullfile(OutputFolder, i{1}));
+ end
end
+
+
+%function rpp_do_download(modelName)
+%
+ %if verLessThan('matlab', '8.1')
+ %makertwObj = get_param(gcs, 'MakeRTWSettingsObject');
+ %else
+ % TODO use rtwprivate('get_makertwsettings',gcs,'BuildInfo') - see
+ % R2013a Simulink Coder release notes.
+ %makertwObj = coder.internal.ModelCodegenMgr.getInstance();
+ %end
+
+ % Check if user chose to Download to Launchpad in Settings
+ %makertwArgs = makertwObj.BuildInfo.BuildArgs;
+ %downloadToLaunchPad = 1;
+ %for i=1:length(makertwArgs)
+ %if strcmp(makertwArgs(i).DisplayLabel,'LAUNCHPAD_DOWNLOAD')
+ %downloadToLaunchPad = str2double(makertwArgs(i).Value);
+ %end
+ %end
+
+ %if false
+ %rpp_download(modelName, makertwObj.BuildDirectory);
+ %end
+
+%end
--- /dev/null
+% Copyright (C) 2013 Czech Technical University in Prague
+%
+% Authors:
+% - Carlos Jenkins <carlos@jenkins.co.cr>
+%
+% This program is free software; you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation; either version 2 of the License, or
+% (at your option) any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this program. If not, see <http://www.gnu.org/licenses/>.
+%
+% File : rpp_sources_required.m
+% Abstract:
+% Returns an array of required source files for given depdency.
+%
+% References:
+% None
+
+
+function sources = rpp_sources_required(dep)
+
+ freertos = {'os_tasks.c', ...
+ 'os_list.c'};
+
+ gio = {};
+
+ all = [freertos, gio];
+
+ switch dep
+ case 'freertos'
+ sources = freertos;
+ case 'gio'
+ sources = gio;
+ case 'all'
+ sources = all;
+ end
+end
+