% Abstract:
% Code download utility for Simulink RPP Target.
%
-% This function is optionally executed at the end of the build process
-% if it is successful and the user selected "Download compiled binary to
-% RPP" option on the build configuration panel. This function calls
-% loadti.sh script with the generated binary and using configuration for
-% the XDS100v2 JTAG Emulators.
+% This function is executed by rpp_make_rtw_hook.m only if the build process
+% finished successfully and RPP_DOWNLOAD is set to TRUE. The RPP_DOWNLOAD option
+% is controlled by "Download to RPP board" option in RPP code generation options.
+%
+% Avoid executing this function with Code Composer Studio running on background.
+%
+% Parameters:
+% use_openocd - When set to TRUE, an OpenOCD will be used for the code
+% download. This tool is available only for Unix based systems.
+% When set to FALSE, a Texas Instruments Loader will be used.
+% for the code download. The TI tool is available for Unix based
+% systems and Windows.
+% This parameter is controled by "Use OpenOCD to download the compiled binary"
+% option in RPP code generation options.
+% use_sdram - When set to TRUE, the code will be downloaded into SDRAM. This option
+% requires a base code for the MPU, EMIF, POM and SDRAM configuration to
+% be present in the device Flash memory. The presence of the code is not
+% verified.
+% When set to FALSE, the code will be downloaded into the Flash memory.
+% This option is usefull for debugging as the Flash memory has very limited
+% number of rewrites.
+% NOTE: The code execution may be slower from the SDRAM than from the Flash.
+% NOTE: This function is not yet implemented.
+% This parameter is controlled by "Download compiled binary to SDRAM"
+% option in RPP code generation options.
%
% References:
% loadti utility wiki at http://processors.wiki.ti.com/index.php/Loadti
% Readme file in <cssroot>/ccs_base/scripting/examples/loadti/readme.txt
-
+% OpenOCD wiki at https://rtime.felk.cvut.cz/hw/index.php/TMS570LS3137#OpenOCD_setup_and_Flashing
function rpp_download(modelName, buildDirectory, use_openocd, use_sdram)
RppLibRoot = getpref('rpp', 'RppLibRoot');