www.gusucode.com > ArmCompilerSupportPackage > doc/html/PackageSetupandConfiguration.m

    %% Package Setup and Configuration
% Getting up and running with this support package, detailing the main 
% settings in the model's Configuration Parameters. Also included is a
% brief description of changing hardware startup & source code to be Arm
% Compiler compatible, if it is not already compatible. 

%% Initialization -- Setting the Path    
% Before getting into the details in the Configuration Parameters, it is
% essential to direct MATLAB & Simulink to the proper Arm Compiler install
% directory. This is implemented by setting a preference, which unlike an
% environmental variable will last when closing and opening MATLAB again.
% The preference is set to the user 'ArmCompiler'. Set the path for Arm 
% Compiler 6 with the following syntax in the MATLAB Command Window:
%   addpref('ArmCompiler','AC6_Path',fullfile('C:\','"Program Files"','"<DS-5 install directory>"','sw','ARMCompiler<version>','bin'));
% 
% Note the parentheses around the parts of the path that have spaces
% (required), and the use of the 'fullfile' command. This is recommended to
% format the full path correctly.
%
% Similarly the path to Arm Compiler 5 files can be set with the following
% syntax:
%   addpref('ArmCompiler','AC5_Path',fullfile('C:\','"Program Files"','"<DS-5 install directory>"','sw','ARMCompiler<version>','bin'));
% 
% To test this is configured correctly you can run the following command,
% which should return the full path to the Arm Compiler directory:
%   getpref('ArmCompiler','AC6_Path')
% If this returns an empty string or an error, try adding the preference
% again using the above syntax, making sure there are no errors in the path
% name or typos.
%

%% Code Generation -- Target selection
% 
% * System target file -- Choose 'ert.tlc' to generate code with Embedded
% Coder.
% * Language -- C or C++. Either will work.
% 
%
%% Code Generation -- Build process -- Toolchain settings
% 
% 
% * Toolchain -- Select either Arm Compiler 5 or Arm Compiler 6 toolchains
% * Build configuration -- Either 'Faster Builds', 'Faster Runs', 'Debug', or
% 'Specify'. Selecting 'Specify' will allow modifications to the options
% used during the code generation process; the other options are set. Note
% that the user will have to specify 
%
% There are two other pre-configured
% options, Arm Compiler 5 and Arm Compiler 6. For production use Arm
% Compiler 6 provides the best code performance and smallest compiled code
% size. For more information on how to obtain Arm Compiler 6 see <SettingUpArmTools.html Setting up Arm Tools.>
%
% For information on Arm Compiler 6 flags, see the <https://developer.arm.com/docs/100748/latest 
% Arm documentation>.
%
%% Configuring a Target to use Arm Compiler 
% Some hardware targets, enabled by a MATLAB Add-On, are preconfigured to one specific compiler. 
% To compile your algorithm/control system
% with Arm Compiler for your target hardware, changes may be required to
% these files. This section provides a walk-through on where to find the
% files to change. A specific board is used to provide a concrete example,
% the ST Nucleo F401RE board. The paths and data
% might change from this example as that Add-On undergoes revision. 
%
%
% At a high level, changes to the following may be required:
% 
% * Compiler flags
% * Linker flags
% * Assembly flags
% * Link objects
% * Include folders/files
% * Compiler defines
% * Libraries
%
%
% Most of these changes, sans changes to the source code itself, will take
% place in an 'attributes' .xml file specific to the hardware board. For the ST Nucleo F401RE board, the
% relevant xml file will be located here on Windows and a similar location on Linux (changing editions if you have a
% different version of MATLAB installed):
%   C:\ProgramData\MATLAB\SupportPackages\R2018a\toolbox\target\supportpackages\stmnucleo\registry\attributes
%
% In this attributes folder you will find many .xml files for each board supported by this package; 
% the file of interest here is STNucleoF401RESTNucleoF401RE.xml. 
% First, copy that file and rename to
% STNucleoF401RESTNucleoF401RE-Default.xml to save a copy of the original
% should things go wrong. Next go into that .xml file and change the following parts of the .xml
% to the proper values for Arm Compiler 5 or Arm Compiler 6:
%
% 
% * '<compileflags>'
% * '<assemblyflags>'
% * '<linkflags>'
% * Any '<includepath>' that refers to the wrong compiler, such as:
% '<includepath>$(MBED_LIBRARY_ROOT_DIR)/TARGET_NUCLEO_F401RE/TOOLCHAIN_GCC_ARM</includepath>'.
% Change to
% '<includepath>$(MBED_LIBRARY_ROOT_DIR)/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_MICRO</includepath>'
% to use the Arm Microlib library.
% * Any '<linkobjectpath>' that refers to the wrong compiler, such as: 
% '<linkobjectpath>$(CMSIS_ROOT_DIR)/CMSIS/Lib/GCC</linkobjectpath>'  
% Change to 
% '<linkobjectpath>$(CMSIS_ROOT_DIR)/CMSIS/Lib/ARM</linkobjectpath>' 
% to use Arm Compiler 5.
% * Any '<define>' that refers to the wrong compiler, such as:
% '<define>TOOLCHAIN_GCC</define>' or '<define>TOOLCHAIN_GCC_ARM</define>'.
%
%
% If a newer version of a library is required, such as the MbedOS or CMSIS
% libraries as referred to above, download the most recent package version
% for your hardware and point this .xml file at the new folder by adding a token. 
% At the bottom of the .xml file there are tokens listed which are
% evaluated at runtime to a specific path. Add a new token or edit an existing one
% with a hardcoded path to the correct folder. As an example, change:
%    '<token Name="CMSIS_ROOT_DIR" Value="codertarget.stmnucleo.internal.getTpPkgRootDir('CMSIS')"/>'
% to:
%    '<token Name="CMSIS_NEW_ROOT_DIR" Value="C:/Program Files/CMSIS-library-for-MATLAB/CMSIS"/>'
%
% Then change the paths using the "CMSIS_ROOT_DIR" token to use the updated
% "CMSIS_NEW_ROOT_DIR" token.
%
%
%
% One way to effectively make changes and check their results is to set up a
% PIL model with your hardware board and Arm Compiler toolchain selected,
% and try to run a simulation. This will trigger compilation, which will
% either work or throw errors which can be used to pinpoint what specific
% changes need to be made. 
%
% A key point to note is that as changes are made to the .xml file, they
% don't take effect unless the MATLAB command 'sl_refresh_customizations'
% is called. It is best to change the .xml file & libraries, call the
% 'sl_refresh_customizations' function in MATLAB, and simulate the model. 
%
%
%
% Copyright 2018 Arm Holdings