\newcommand{\superscript}[1]{\ensuremath{^{\textrm{\small#1}}}}
\newcommand{\subscript}[1]{\ensuremath{_{\textrm{\small#1}}}}
+% Supported targets - to be used with \ifx\tgtId\tgtIdXXX
+\def\tgtIdTMSHDK{tms570\_hdk}
+\def\tgtIdRMHDK{rm48\_hdk}
+\def\tgtIdTMSRPP{tms570\_rpp}
+
% Include target specific macros etc.
\input{rpp_simulink_target.tex}
\HRule
\vspace{0.4cm}
{\huge \bfseries Simulink code generation target for Texas~Instruments
- \tgname platform\par}
+ \tgname{} platform\par}
\vspace{0.4cm}
\HRule \\[1.5cm]
cleanup \\ \hline
0.3 & 2015-03-31 & Sojka, Horn & Added sections
- \ref{sec-changing-os}, \ref{sec:adding-new-funct} and \ref{sec:mult-single-thre}, minor updates. \\ \hline
+ \ref{sec-changing-os}, \ref{sec:adding-new-funct} and
+ \ref{sec:mult-single-thre}. Minor
+ updates. \\ \hline
+
+ 0.4 & 2015-04-30 & Sojka, Horn & Added support for TMS570 HDK
+ platform. All RPP software
+ supports multiple
+ platforms by recompilation. \\ \hline
\end{tabularx}
\tableofcontents
\label{chap-introduction}
This text documents software part of Rapid Prototyping Platform (RPP)
-project for Texas Instruments \tgname safety microcontroller. The
+project for Texas Instruments \tgname{} safety microcontroller. The
software consists of code generation target for Simulink Embedded
Coder, a low-level run-time C library and a tool for interactive
testing of hardware and software functionality.
Originally, the RPP project was created for TMS570 microcontroller and
-the port to \tgname was derived from it under a contract with Eaton
+the port to \tgname{} was derived from it under a contract with Eaton
Corporation.
The document contains step-by-step instructions for installation of
\section{Background}
\label{sec-background}
-The Rapid Prototyping Platform is an control unit based on \develkitname
+The Rapid Prototyping Platform is an control unit based on \develkitname{}
development kit from Texas Instruments. Cental to the kit is the
-\mcuname MCU -- an ARM Cortex R4 based microcontroller developed by
+\mcuname{} MCU -- an ARM Cortex R4 based microcontroller developed by
Texas Instruments. This MCU contains several protective mechanisms
(two cores in lockstep, error correction mechanisms for SRAM and Flash
memory, voltage monitoring, etc.) to fulfill the requirements for
\label{sec-hardware-description}
This section provides a brief description of the Texas Instrument
-\develkitname development kit. For a more detailed information refer to
+\develkitname{} development kit. For a more detailed information refer to
\cite{\tghdkman}. The kit is depicted in
Figure~\ref{fig-board_photo}.
\begin{figure}\begin{center}
\noindent
\includegraphics[width=300px]{images/board.png}
- \caption{The \develkitname kit \cite[p. 8]{\tghdkman}}
+ \caption{The \develkitname{} kit \cite[p. 8]{\tghdkman}}
\label{fig-board_photo}
\end{center}\end{figure}
Figure~\ref{fig-blocks} ilustrates the supported peripherals and their
connection to the MCU, expansion connectors and other components on
the development kit. For pinout description of the implemented
-peripherals refer the \tgname HDK User's Guide
+peripherals refer the \tgname{} HDK User's Guide
\cite{\tghdkman}. The main features of supported
peripherals are provided in the following subsections.
version of the library.
\item[7.4.0] Newest version distributed by the Texas Instruments.
\item[7.4.2] Newer version available from FreeRTOS pages. Slightly
-modified to run on \tgname MCU.
+modified to run on \tgname{} MCU.
\end{description}
\noindent
\item GtkTerm 0.99.7-rc1
\item TI Code Composer Studio 5.5.0.00077
\item Matlab 2013b 64b with Embedded Coder
- \item HalCoGen 4.00 (optionally)
- \item Uncrustify 0.59 (optionally, see Section \ref{sec-compilation})
- \item Doxygen 1.8.4 (optionally, see Section \ref{sec-compiling-api-documentation})
- \item Git 1.7.10.4 (optionally)
+ \item HalCoGen 4.00 (optional)
+ \item Uncrustify 0.59 (optional, see Section \ref{sec-compilation})
+ \item Doxygen 1.8.4 (optional, see Section \ref{sec-compiling-api-documentation})
+ \item Git 1.7.10.4 (optional)
\end{itemize}
\subsection{Windows environment}
\item Bray Terminal v1.9b
\item TI Code Composer Studio 5.5.0.00077
\item Matlab 2013b 64b with Embedded Coder
- \item HalCoGen 4.00 (optionally)
- \item Doxygen 1.8.4 (optionally, see Section \ref{sec-compiling-api-documentation})
- \item Uncrustify 0.59 (optionally, see Section \ref{sec-compilation})
- \item Git 1.9.4.msysgit.2 (optionally)
+ \item HalCoGen 4.00 (optional)
+ \item Doxygen 1.8.4 (optional, see Section \ref{sec-compiling-api-documentation})
+ \item Uncrustify 0.59 (optional, see Section \ref{sec-compilation})
+ \item Git 1.9.4.msysgit.2 (optional)
\end{itemize}
\section{Software tools}
are:
\begin{description}
-\item[rpp-lib] Contains the source code of the RPP library, described
- in Chapter \ref{chap-c-support-library}. If you want to make any
- changes in the drivers or RPP API, this library has to be compiled
- and linked with applications in the other two packages. The library compile
- procedure can be found in Section \ref{sec-compilation}.
\item[rpp-simulink] Contains the source code of Matlab Simulink
blocks, demo models and scripts for downloading the generated
- firmware to the target from Matlab/Simulink. Details can be
+ firmware to the target board from Matlab/Simulink. Details can be
found in Chapter \ref{chap-simulink-coder-target}.
The package also contains the binary of the RPP Library and all its
- headers and other files necessary for building and downloading the
- models.
+ headers and other files necessary for building and downloading
+ Simulink models.
\item[rpp-test-sw] Contains an application for interactive testing and
- control of the RPP board over the serial interface. Details can be
+ control of the \develkitname{} board over the serial interface. Details can be
found in Chapter~\ref{chap-rpp-test-software}.
The package also contains the binary of the RPP Library and all
headers and other files necessary for building and downloading the
application.
+\item[rpp-lib] Contains the source code of the RPP library, described
+ in Chapter \ref{chap-c-support-library}. If you want to make any
+ changes in the drivers or the RPP API, this library has to be
+ compiled and linked with applications in the other two packages.
+ Library compilation is described in Section \ref{sec-compilation}.
\end{description}
The following sections describe how to start working with individual
packages.
-\subsection{rpp-lib}
-\label{sec-rpp-lib-installation}
-
-This section describes how to open the rpp-lib project in Code
-Composer Studio and how to use the resulting static library in an
-application. This is only necessary if you need to modify the library
-for some reason.
-
-\begin{enumerate}
- \item Unzip the \texttt{rpp-lib-version.zip} file.
- \item Open the Code Composer Studio (see Section \ref{sec-ti-ccs}).
- \item Import the rpp-lib project as described in
- Section~\ref{sec-openning-of-existing-project}.
- \item Compile the static library using the procedure from Section
- \ref{sec-compilation}. The compiled library \texttt{rpp-lib.lib}
- will appear in the project root directory.
- \item Either copy the compiled library and the content of the
- \texttt{rpp/include} directory to the application, where you
- want to use it or use the library in place, as described in
- Section~\ref{sec:creating-new-project}.
- \begin{itemize}
- \item In the rpp-simulink application the library is located in
- the \texttt{rpp/lib} folder.
- \item In the rpp-test-sw application the library is located in
- the \texttt{rpp-lib} folder.
- \end{itemize}
-\end{enumerate}
-
\subsection{rpp-simulink}
\label{sec-rpp-simulink-installation}
This section describes how to install the rpp-simulink project, which
\begin{enumerate}
\item Unzip the \texttt{rpp-test-sw-version.zip} file.
\item Open the Code Composer Studio (see Section \ref{sec-ti-ccs}).
- \item Follow the procedure for opening the projects in CCS in
- Section \ref{sec-openning-of-existing-project} and open both
- \texttt{rpp-lib} and \texttt{rpp-test-sw} projects.
+ \item Import the \texttt{rpp-test-sw} project as described in
+ Section \ref{sec-openning-of-existing-project}.
\item Right click on the \texttt{rpp-test-sw} project in the
\textsc{Project Explorer} and select \textsc{Build Project}.
\item Follow the instructions in
Section~\ref{sec-running-software-on-hw} to download, debug and
- run the software on the target hardware. If CCS asks you whether
- to proceed with the detected errors in \texttt{rpp-lib} project.
- Ignore them and click the \textsc{Proceed} button to continue.
+ run the software on the target hardware.
+\end{enumerate}
+
+\subsection{rpp-lib}
+\label{sec-rpp-lib-installation}
+
+This section describes how to open the rpp-lib project in Code
+Composer Studio and how to use the resulting static library in an
+application. This is only necessary if you need to modify the library
+for some reason.
+
+\begin{enumerate}
+ \item Unzip the \texttt{rpp-lib-version.zip} file.
+ \item Open the Code Composer Studio (see Section \ref{sec-ti-ccs}).
+ \item Import the rpp-lib project from directory
+ \texttt{rpp-lib-XXX/build/\tgtId} as described in
+ Section~\ref{sec-openning-of-existing-project}.
+ \item Compile the static library by selecting \textsc{Project
+ $\rightarrow$ Build Project} (see Section
+ \ref{sec-compilation} for more information). The compiled
+ library \texttt{rpp-lib.lib} and file
+ \texttt{Makefile.config} will appear in the
+ \texttt{rpp-lib-XXX} directory.
+ \item Either copy the compiled library and the content of the
+ \texttt{rpp/include} directory to the application, where you
+ want to use it or use the library in place, as described in
+ Section~\ref{sec:creating-new-project}.
+ \begin{itemize}
+ \item In the rpp-simulink application the library is located in
+ the \texttt{rpp/lib} folder.
+ \item In the rpp-test-sw application the library is located in
+ the \texttt{rpp-lib} folder.
+ \end{itemize}
\end{enumerate}
\section{Code Composer Studio usage}
\newpage
\subsection{Creating new project}
\label{sec:creating-new-project}
-Follow these steps to create an application for \tgname MCU compiled with
+Follow these steps to create an application for \tgname{} MCU compiled with
CGT.
\begin{compactenum}
-\item Create a new empty CCS project. Select \mcuname device, XDS100v2
+\item Create a new empty CCS project. Select \mcuname{} device, XDS100v2
connection and set Linker command file to
- \texttt{rpp-lib/rpp/\ldscriptname}.
+ \texttt{rpp-lib/build/\tgtId/\ldscriptname}.
\noindent\includegraphics[scale=0.45]{images/base_1.png}
\newpage
\item Add \texttt{\$\{RPP\_LIB\_ROOT\}/rpp-lib.lib} to the list of
linked libraries before the runtime support library
- (\texttt{rtsv7R4\_T\_le\_v3D16\_eabi.lib}).
+ (\texttt{\tgtRtlib}).
\noindent\includegraphics[scale=.45]{images/base_3.png}
\textsc{Resume}.
\item If your application fails to run with a \texttt{\_dabort} interrupt, check
that the linker script selected in step 1 is not excluded from the build.
-You can do this by right clicking on the file \texttt{\ldscriptname}
+You can do this by right clicking the \texttt{\ldscriptname} file
in the \textsc{Project Explorer} and unchecking the \textsc{Exclude from build}
item. The Code Composer Studio sometimes automaticaly excludes this file from
-the build process when creating the new project.
+the build process when creating a new project.
% \item If not already created for another project, create new target
% configuration. Select \textsc{Windows $\rightarrow$ Show View
% $\rightarrow$ Target Configurations}. In the shown window, click
% on \textsc{New Target Configuration} icon and configure XDS100v2
-% connection and \mcuname device as shown below. Click \textsc{Save},
+% connection and \mcuname{} device as shown below. Click \textsc{Save},
% connect your board and click \textsc{Test Connection}.
% \medskip
\item Optionally, you can change debugger configuration by selecting
\textsc{Run $\rightarrow$ Debug Configurations}. In the
\textsc{Target} tab, you can configure not to break at \texttt{main}
- or not to erase the whole flash, but only necessary sectors (see the
+ or not to erase the whole flash, but necessary sectors only (see the
figure below).
\includegraphics[width=\linewidth]{images/debug_conf_flash.png}
\end{compactenum}
-\subsubsection{Steps to configure new POSIX application:}
-Such an application can be used to test certain FreeRTOS features on
-Linux and can be compiled with a native GCC compiler.
-
-\begin{compactenum}
- \item Create a new managed C project that uses Linux GCC toolchain.
- \item Create a source folder \texttt{src}. Link all files from original
-CCS application to this folder.
- \item Create a normal folder \texttt{include}. Create a folder
-\texttt{rpp} inside of it.
- \item Add common \texttt{.gitignore} to the root of that project:
-\lstset{language=}
-\begin{lstlisting}
-Debug
-Release
-.settings/*
-\end{lstlisting}
- \item Add new variable \texttt{RPP\_LIB\_ROOT} and point to this
-repository branch root.\newline{}
-\noindent\includegraphics[width=\linewidth]{images/base_posix_1.png}
- \item Configure compiler to include local includes, CCS application
-includes, OS includes for POSIX and RPP includes, in that order.\newline{}
-\noindent\includegraphics[width=\linewidth]{images/base_posix_2.png}
-\newpage
- \item Add \texttt{rpp} and \texttt{pthread} to linker libraries and add
-\texttt{RPP\_LIB\_ROOT} to the library search path.\newline{}
-\noindent\includegraphics[width=\linewidth]{images/base_posix_3.png}
-\end{compactenum}
+%% Comment this out for Eaton
+% \subsubsection{Steps to configure new POSIX application:}
+% Such an application can be used to test certain FreeRTOS features on
+% Linux and can be compiled with a native GCC compiler.
+
+% \begin{compactenum}
+% \item Create a new managed C project that uses Linux GCC toolchain.
+% \item Create a source folder \texttt{src}. Link all files from original
+% CCS application to this folder.
+% \item Create a normal folder \texttt{include}. Create a folder
+% \texttt{rpp} inside of it.
+% \item Add common \texttt{.gitignore} to the root of that project:
+% \lstset{language=}
+% \begin{lstlisting}
+% Debug
+% Release
+% .settings/*
+% \end{lstlisting}
+% \item Add new variable \texttt{RPP\_LIB\_ROOT} and point to this
+% repository branch root.\newline{}
+% \noindent\includegraphics[width=\linewidth]{images/base_posix_1.png}
+% \item Configure compiler to include local includes, CCS application
+% includes, OS includes for POSIX and RPP includes, in that order.\newline{}
+% \noindent\includegraphics[width=\linewidth]{images/base_posix_2.png}
+% \newpage
+% \item Add \texttt{rpp} and \texttt{pthread} to linker libraries and add
+% \texttt{RPP\_LIB\_ROOT} to the library search path.\newline{}
+% \noindent\includegraphics[width=\linewidth]{images/base_posix_3.png}
+% \end{compactenum}
\subsubsection{Content of the application}
\label{sec-running-software-on-hw}
\subsubsection{Code Composer Studio Project}
\label{sec-ccs-run-project}
-When the application is distributed as a CCS project, you have to open the
+When an application is distributed as a CCS project, you have to open the
project in the CCS as described in the Section
\ref{sec-openning-of-existing-project}. Once the project is opened and built, it
can be easily downloaded to the target hardware with the following procedure:
\begin{enumerate}
- \item Connect the Texas Instruments XDS100v2 USB emulator to the JTAG
-port.
- \item Connect a USB cable to the XDS100v2 USB emulator and the
-development computer.
+\ifx\tgtId\tgtIdTMSRPP
+ \item Connect the Texas Instruments XDS100v2 USB emulator to the JTAG port.
+ \item Connect a USB cable to the XDS100v2 USB emulator and the development computer.
+\else
+ \item Connect the USB cable to the \develkitname{} board.
+\fi
\item Plug in the power supply.
\item In the Code Composer Studio click on the
\textsc{Run$\rightarrow$Debug}. The project will be optionally built and
variant} (ARM, Cortex R, \mcuname, Texas Instruments XDS100v2 USB Emulator)
and select project template to \textsc{Empty Project}. The filled dialog should
look like in Figure~\ref{fig-new-empty-project}
-\item Click on the \textsc{Finish} button and a new empty project will
+\item Click the \textsc{Finish} button and a new empty project will
be created.
\item In the \textsc{Project Explorer} right-click on the project and
select \textsc{Debug as$\rightarrow$Debug configurations}.
\item Click \textsc{New launch configuration} button
\item Rename the New\_configuration to, for example, myConfiguration.
\item Select configuration target file by clicking the \textsc{File
-System} button, finding and selecting the \texttt{\tgconfigfilename} file. The result
+System} button, finding and selecting the \texttt{rpp-lib-XXX/build/\tgtId/\tgconfigfilename} file. The result
should look like in Figure~\ref{fig-debug-conf-main-diag}.
\item In the \textsc{program} pane select the binary file you want to
download to the board. Click on the \textsc{File System} button,
find and select the binary file. Try, for example
\texttt{rpp-test-sw.out}. The result should look like in
Figure~\ref{fig-debug-conf-program-diag}.
- \item You may also tune the target configuration like in the Section
-\ref{sec-target-configuration}.
-\item Finish the configuration by clicking on the \textsc{Apply}
- button and download the code by clicking on the \textsc{Debug}
- button. You can later invoke the download also from the
+\item You may also tune the target configuration as described in
+ Section \ref{sec-target-configuration}.
+\item Finish the configuration by clicking the \textsc{Apply} button
+ and download the code by clicking the \textsc{Debug} button. You can
+ later invoke the download also from the
\textsc{Run$\rightarrow$Debug} CCS menu. It is not necessary to
create more Debug configurations and CCS empty projects as you can
easily change the binary file in the Debug configuration to load a
\item In the dialog window select \textsc{Target} pane.
\item In the \textsc{Flash Settings}, \textsc{Erase Options} select
\textsc{Necessary sectors only}.
- \item Save the configuration by clicking on the \textsc{Apply} button
+ \item Save the configuration by clicking the \textsc{Apply} button
and close the dialog.
\end{enumerate}
\section{Matlab Simulink usage}
\label{sec-matlab-simulink-usage}
-This section describes the basic tasks for working with the RPP code
+This section describes the basics of working with the RPP code
generation target for Simulink. For a more detailed description of the
code generation target refer to
Chapter~\ref{chap-simulink-coder-target}.
\item Create new model or load a demo:
- Demos are located in \texttt{\repo/rpp/demos} or you can start a new
- model and configure target to RPP. For new models see Section
- \ref{sec-crating-new-model} below.
+ Demos are located in \texttt{\repo/rpp/demos}. Creation of new
+ models is described in Section~\ref{sec-crating-new-model} below.
\end{enumerate}
Code $\rightarrow$ Build Model}.
\end{enumerate}
-If you want to run the model on the RPP board, see Section
+To run the model on the \develkitname{} board continue with Section
\ref{sec-running-model-on-hw}.
\subsection{Running models on the RPP board}
\label{sec-running-model-on-hw}
-To run the model on the target RPP hardware you have to enable the download
+To run the model on the \develkitname{} hardware you have to enable the download
feature and build the model by following this procedure:
\begin{enumerate}
\item Open the model you want to run (see
Section~\ref{sec-openning-demo-models} for example with demo
models).
- \item Click on \textsc{Simulation$\rightarrow$Model Configuration
-Parameters}.
-\item In the \textsc{Code Generation$\rightarrow$RPP Options} pane
- check the \textsc{Download compiled binary to RPP} checkbox.
- \item Click the \textsc{OK} button, connect the target HW to the computer
-like in the Section \ref{sec-ccs-run-project} and build the model by \textsc{Code $\rightarrow$ C/C++
-Code $\rightarrow$ Build Model}. If the build
-ends with a success, the download process will start and once the downloading is
-finished, the application will run immediatelly.
+ \item Click on \textsc{Simulation$\rightarrow$Model Configuration
+ Parameters}.
+ \item In the \textsc{Code Generation$\rightarrow$RPP Options} pane
+ check the \textsc{Download compiled binary to RPP} checkbox. Click
+ the \textsc{OK} button
+ \item Connect the target hardware to the computer (see Section
+ \ref{sec-ccs-run-project}) and build the model by \textsc{Code
+ $\rightarrow$ C/C++ Code $\rightarrow$ Build Model}. If the build
+ succeeds, the download process will start automatically and once
+ the downloading is finished, the application will run immediately.
\end{enumerate}
%%\subsubsection{Using OpenOCD for downloading}
\label{sec-configuration-serial-interface}
The main mean for communication with the RPP board is the serial line.
Each application may define its own serial line settings, but the
-following settings is the default one:
+following settings are the default:
\begin{itemize}
\item Baudrate: 115200
\item Flow control: none
\end{itemize}
-Use GtkTerm in Linux or Bray Terminal for accessing the serial
-interface. On \develkitname, the serial line is tunneled over the USB
-cable. % See Section \ref{sec-hardware-description} for reference about
+Use GtkTerm on Linux or Bray Terminal on Windows for accessing the
+serial interface. On \develkitname{}, the serial line is tunneled over
+the USB. % See Section \ref{sec-hardware-description} for reference about
% the position of the serial interface connector on the RPP board.
\section{Bug reporting}
nothing common with the test suite described later in
Chapter~\ref{chap-rpp-test-software} and those two suits are going
to be merged in the future. Also other Hello World applications are
- included as a reference about how to create an \tgname application.
+ included as a reference about how to create an \tgname{} application.
\item[os/] OS layers directory. See
Section~\ref{sec-operating-system-layer} for more information about
currently available operating system versions and
implemented for the simulink target.
\item \textbf{Use OpenOCD to download the compiled binary}: This feature is not yet
-implemented for the \mcuname simulink target.
+implemented for the \mcuname{} simulink target.
\item \textbf{Print model metadata to SCI at start}: if set this option will
print a message to the Serial Communication Interface when the model start