]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/commitdiff
Implemented a temporal compilation system fix to get the FreeRTOS sources files compi...
authorCarlos Jenkins <carlos@jenkins.co.cr>
Wed, 15 May 2013 18:42:17 +0000 (20:42 +0200)
committerCarlos Jenkins <carlos@jenkins.co.cr>
Wed, 15 May 2013 18:42:17 +0000 (20:42 +0200)
refs/rtw_ref.pdf [new file with mode: 0644]
rpp/rpp/rpp_download.m
rpp/rpp/rpp_lib_include.m
rpp/rpp/rpp_make_rtw_hook.m
rpp/rpp/rpp_sources_required.m [new file with mode: 0644]

diff --git a/refs/rtw_ref.pdf b/refs/rtw_ref.pdf
new file mode 100644 (file)
index 0000000..fdb5773
Binary files /dev/null and b/refs/rtw_ref.pdf differ
index 505ce74ed2e19496241625a7c965f131e411f98b..37520970aecb78ee06fff16a61a49db2ec8eac86 100644 (file)
 
 
 
-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
 
@@ -49,7 +50,9 @@ function rpp_download(modelName, makertwObj)
                 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.']);
index b7233337208a8f5afe8a3a99b2616ca1da42ae36..943e1c1edacc67a73bf0d5121cb2b2cf893d7a18 100644 (file)
 
 function rpp_lib_include(buildInfo)
 
-    % FIXME: Remove /tmp when library is modularized.
-    RppLibRoot = fullfile(getpref('rpp', 'RppLibRoot'), 'tmp');
-
-    buildInfo.addSourceFiles('os_tasks.c'  , RppLibRoot, 'CustomCode');
-    buildInfo.addSourceFiles('os_semphr.c', RppLibRoot, 'CustomCode');
-
-    disp(RppLibRoot);
-    disp(buildInfo);
+    OSSources = rpp_sources_required('freertos');
+    RppLibRoot = getpref('rpp', 'RppLibRoot');
+    % FIXME: Remove FIXMERppLibRoot when library is modularized.
+    FIXMERppLibRoot = fullfile(RppLibRoot, 'tmp');
+    buildInfo.addSourceFiles(OSSources, FIXMERppLibRoot);
 
 end
index 07bbc0a2bdbbdc35608c30250a32a5bd7f80c74a..75528f24eeb13631d7e0c3664c161736746944b4 100644 (file)
@@ -38,6 +38,7 @@ function rpp_make_rtw_hook(hookMethod, modelName, rtwRoot, templateMakefile, ...
             disp(['### Build procedure for model: ''', modelName, ...
                   ''' aborted due to an error.']);
 
+
         case 'entry'
             % Called at start of code generation process (before anything
             % happens).
@@ -46,12 +47,14 @@ function rpp_make_rtw_hook(hookMethod, modelName, rtwRoot, templateMakefile, ...
 
             % 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).
@@ -60,6 +63,7 @@ function rpp_make_rtw_hook(hookMethod, modelName, rtwRoot, templateMakefile, ...
 
             % 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
@@ -67,21 +71,25 @@ function rpp_make_rtw_hook(hookMethod, modelName, rtwRoot, templateMakefile, ...
 
             % 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
@@ -93,33 +101,64 @@ function rpp_make_rtw_hook(hookMethod, modelName, rtwRoot, templateMakefile, ...
 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
diff --git a/rpp/rpp/rpp_sources_required.m b/rpp/rpp/rpp_sources_required.m
new file mode 100644 (file)
index 0000000..f429cf3
--- /dev/null
@@ -0,0 +1,45 @@
+% 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
+