[FE training-materials-updates] Real-time updates
Michael Opdenacker
michael.opdenacker at free-electrons.com
Fri May 20 06:44:56 CEST 2016
Repository : git://git.free-electrons.com/training-materials.git
On branch : master
Link : http://git.free-electrons.com/training-materials/commit/?id=eda984ac53a0a78d45919ce46050fb975dc7f119
>---------------------------------------------------------------
commit eda984ac53a0a78d45919ce46050fb975dc7f119
Author: Michael Opdenacker <michael.opdenacker at free-electrons.com>
Date: Fri May 20 06:44:56 2016 +0200
Real-time updates
- Now that we're using 4.6, we can test PREEMPT_RT
on the Xplained board (doesn't add much time to the labs)
- Minor updates to the slides (supported versions,
CONFIG_PREEMPT_RT_FULL instead of CONFIG_PREEMPT_RT)
- Remove obsolete file
Signed-off-by: Michael Opdenacker <michael.opdenacker at free-electrons.com>
>---------------------------------------------------------------
eda984ac53a0a78d45919ce46050fb975dc7f119
agenda/sysdev-agenda.tex | 5 +-
agenda/sysdev-fr-agenda.tex | 4 +-
...in-wrapper-fix-paths-if-executable-was-re.patch | 56 -------------------
labs/sysdev-real-time/sysdev-real-time.tex | 63 +++++++++++++++-------
slides/sysdev-realtime/sysdev-realtime.tex | 8 +--
5 files changed, 55 insertions(+), 81 deletions(-)
diff --git a/agenda/sysdev-agenda.tex b/agenda/sysdev-agenda.tex
index 2407a3b..8850930 100644
--- a/agenda/sysdev-agenda.tex
+++ b/agenda/sysdev-agenda.tex
@@ -463,8 +463,9 @@ Embedded Linux system development training\\
{Lab - Linux latency tests}
{
\begin{itemize}
- \item Tests performed on the Xplained ARM board
- \item Latency tests on standard Linux.
+ \item Tests performed on the Xplained ARM board.
+ \item Latency tests on standard Linux, with preemption options.
+ \item Latency tests using the \code{PREEMPT_RT} kernel patchset.
\item Setting up Xenomai.
\item Latency tests with Xenomai.
\end{itemize}
diff --git a/agenda/sysdev-fr-agenda.tex b/agenda/sysdev-fr-agenda.tex
index 9e9701c..5572cae 100644
--- a/agenda/sysdev-fr-agenda.tex
+++ b/agenda/sysdev-fr-agenda.tex
@@ -487,8 +487,10 @@ embarqué}
{TP - Tests de latence Linux}
{
\begin{itemize}
- \item Tests sur la carte ARM Xplained
+ \item Tests sur la carte ARM Xplained.
\item Mesure de latence sur Linux standard.
+ \item Mesure de latence sur un noyau Linux
+ incluant les patches \code{PREEMPT_RT}.
\item Mise en place de Xenomai.
\item Mesures de latence avec Xenomai.
\end{itemize}
diff --git a/lab-data/embedded-linux/realtime/rttest/data/buildroot-2013.02-ext-toolchain-wrapper-fix-paths-if-executable-was-re.patch b/lab-data/embedded-linux/realtime/rttest/data/buildroot-2013.02-ext-toolchain-wrapper-fix-paths-if-executable-was-re.patch
deleted file mode 100644
index cbd142e..0000000
--- a/lab-data/embedded-linux/realtime/rttest/data/buildroot-2013.02-ext-toolchain-wrapper-fix-paths-if-executable-was-re.patch
+++ /dev/null
@@ -1,56 +0,0 @@
-From 51698d4f81138f0b2ab33a069af9a7346f199094 Mon Sep 17 00:00:00 2001
-From: Patrick Ziegler <patrick.ziegler at fh-kl.de>
-Date: Wed, 29 May 2013 11:41:19 +0200
-Subject: [PATCH] ext-toolchain-wrapper: fix paths if executable was resolved
- by PATH
-
-If ext-toolchain-wrapper or any symbolic link to it was resolved by PATH,
-the wrapper takes the working directory to calculate the relative paths.
-
-Now '/proc/self/exe' is used to resolve the absolute path to the toolchain
-directory if the wrapper was called neither with a relative nor an absolute
-path.
-
-Signed-off-by: Patrick Ziegler <patrick.ziegler at fh-kl.de>
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
----
- .../toolchain-external/ext-toolchain-wrapper.c | 16 ++++++++++++++--
- 1 file changed, 14 insertions(+), 2 deletions(-)
-
-diff --git a/toolchain/toolchain-external/ext-toolchain-wrapper.c b/toolchain/toolchain-external/ext-toolchain-wrapper.c
-index 9a2fc70..e71a90a 100644
---- a/toolchain/toolchain-external/ext-toolchain-wrapper.c
-+++ b/toolchain/toolchain-external/ext-toolchain-wrapper.c
-@@ -61,7 +61,7 @@ int main(int argc, char **argv)
- char *relbasedir, *absbasedir;
- char *progpath = argv[0];
- char *basename;
-- int ret;
-+ int ret, i, count = 0;
-
- /* Calculate the relative paths */
- basename = strrchr(progpath, '/');
-@@ -77,7 +77,19 @@ int main(int argc, char **argv)
- absbasedir = realpath(relbasedir, NULL);
- } else {
- basename = progpath;
-- absbasedir = realpath("../..", NULL);
-+ absbasedir = malloc(PATH_MAX + 1);
-+ ret = readlink("/proc/self/exe", absbasedir, PATH_MAX);
-+ if (ret < 0) {
-+ perror(__FILE__ ": readlink");
-+ return 2;
-+ }
-+ for (i = ret; i > 0; i--) {
-+ if ('/' == absbasedir[i]) {
-+ absbasedir[i] = '\0';
-+ if (3 == ++count)
-+ break;
-+ }
-+ }
- }
- if (absbasedir == NULL) {
- perror(__FILE__ ": realpath");
---
-1.7.9.5
-
diff --git a/labs/sysdev-real-time/sysdev-real-time.tex b/labs/sysdev-real-time/sysdev-real-time.tex
index 3476d32..311a58a 100644
--- a/labs/sysdev-real-time/sysdev-real-time.tex
+++ b/labs/sysdev-real-time/sysdev-real-time.tex
@@ -9,7 +9,8 @@ After this lab, you will:
\item Be able to build a real-time application against the standard
POSIX real-time API, and against Xenomai's POSIX skin.
\item Have compared scheduling latency on your system, between a
- standard kernel and a kernel with Xenomai.
+ standard kernel, a kernel with \code{PREEMPT_RT} and a kernel
+ with Xenomai.
\end{itemize}
\section{Setup}
@@ -28,7 +29,7 @@ supports Xenomai.
Let's build this with Buildroot.
-Reuse and extract the Buildroot 2014.11 sources. Configure Buildroot
+Reuse and extract the Buildroot 2016.02 sources. Configure Buildroot
with the following settings, using the \code{/} command in \code{make
menuconfig} to find parameters by their name:
@@ -41,12 +42,11 @@ with the following settings, using the \code{/} command in \code{make
\item In \code{Toolchain}:
\begin{itemize}
\item \code{Toolchain type}: \code{External toolchain}
- \item \code{Toolchain}: \code{Sourcery CodeBench ARM 2013.11}
+ \item \code{Toolchain}: \code{Sourcery CodeBench ARM 2014.05}
\end{itemize}
\item In \code{System configuration}:
\begin{itemize}
- \item \code{/dev management}: \code{Dynamic using devtmpfs only}
- \item in \code{getty options}, \code{TTY port}: \code{ttyS0}
+ \item in \code{Run a getty (login prompt) after boot}, \code{TTY port}: \code{ttyS0}
\end{itemize}
\item In \code{Target packages}:
\begin{itemize}
@@ -60,13 +60,23 @@ with the following settings, using the \code{/} command in \code{make
\item In \code{Real-Time}, enable \code{Xenomai Userspace}:
\begin{itemize}
\item Enable \code{Install testsuite}
- \item Make sure that \code{POSIX skin library} is enabled.
+ \item Make sure that \code{POSIX skin library} and
+ \code{Native skin library}\footnote{Needed by
+ the Xenomai testsuite.} are enabled.
\end{itemize}
\end{itemize}
\end{itemize}
Now, build your root filesystem.
+If you are running an x86 64 bit distribution, Buildroot should ask
+you to install 32 bit compatibility packages to be able to execute the
+Sourcery CodeBench external toolchain:
+
+\begin{verbatim}
+sudo apt-get install libc6-i386 lib32stdc++6 lib32z1
+\end{verbatim}
+
At the end of the build job, extract the
\code{output/images/rootfs.tar} archive in the \code{nfsroot}
directory.
@@ -80,7 +90,7 @@ cp data/* nfsroot/root
\section{Compile a standard Linux kernel}
-Reusing the kernel we previously compiled, make sure that you disable
+Reusing the 4.6 kernel we previously compiled, make sure that you disable
\code{CONFIG_PROVE_LOCKING}, \code{CONFIG_DEBUG_LOCK_ALLOC},
\code{CONFIG_DEBUG_MUTEXES} and \code{CONFIG_DEBUG_SPINLOCK}.
@@ -104,8 +114,7 @@ Let's configure our \code{PATH} to use this toolchain:
\scriptsize
\begin{verbatim}
-export
-PATH=$HOME/embedded-linux-labs/realtime/rttest/buildroot-XXXX.YY/output/host/usr/bin:$PATH
+export PATH=$HOME/embedded-linux-labs/realtime/rttest/buildroot-YYYY.MM/output/host/usr/bin:$PATH
\end{verbatim}
\normalsize
@@ -122,6 +131,9 @@ Execute the program on the board. Is the clock resolution good or bad?
Compare it to the timer tick of your system, as defined by
\code{CONFIG_HZ}.
+Copy the results in a file, in order to be able to compare them
+with further results.
+
Obviously, this resolution will not provide accurate sleep times, and
this is because our kernel doesn't use high-resolution timers. So
let's enable the \code{CONFIG_HIGH_RES_TIMERS} option in the kernel
@@ -156,11 +168,22 @@ spinlocks).
Run the simple tests again with this new preemptible kernel and compare
the results.
+\section{Compiling and testing the PREEMPT_RT kernel}
+
+Download the latest \code{PREEMPT_RT} kernel patch and apply it to
+your kernel sources.
+
+Configure your kernel with \code{CONFIG_PREEMPT_RT_FULL} and boot it.
+
+Repeat the tests and compare the results again. You should see a massive
+improvement in the maximum latency.
+
\section{Testing Xenomai scheduling latency}
Stay in \code{$HOME/embedded-linux-labs/realtime/rttest}.
-Download the latest 2.6.x release of Xenomai, and extract it.
+Download the latest 2.6.x release of Xenomai (that's what our version of
+Buildroot supports by default), and extract it.
As you can see in the \code{ksrc/arch/arm/patches} directory,
the most recent Linux kernel version supported by Xenomai for ARM is
@@ -188,23 +211,27 @@ enabled, taking your time to read their description:
\item \code{CONFIG_XENO_HW_UNLOCKED_SWITCH}
\end{itemize}
-In order to build our application against the Xenomai libraries, we
-will need {\em pkg-config} built by Buildroot. So go in your Buildroot
-source directory, and force Buildroot to build the host variant of
-{\em pkg-config}:
+Compile your kernel, using the same Sourcery CodeBench compiler
+as earlier in the lab\footnote{Your own toolchain is too recent
+for the 3.14 kernel, which doesn't support compiling with gcc5 yet. The
+Sourcery CodeBench gcc version is 4.8.x.}.
+
+While the kernel compiles, we can start to build our application against
+the Xenomai libraries. We will need {\em pkg-config} built by Buildroot.
+So go in your Buildroot source directory, and force Buildroot to build
+the host variant of {\em pkg-config}:
\begin{verbatim}
-cd $HOME/embedded-linux-labs/realtime/rttest/buildroot-2014.11/
+cd $HOME/embedded-linux-labs/realtime/rttest/buildroot-YYYY.MM/
make host-pkgconf
\end{verbatim}
-Compile your kernel, and in the meantime,
-compile \code{rttest} for the Xenomai POSIX skin:
+We can now compile \code{rttest} for the Xenomai POSIX skin:
\scriptsize
\begin{verbatim}
cd $HOME/embedded-linux-labs/realtime/rttest/nfsroot/root
-export PATH=$HOME/embedded-linux-labs/realtime/rttest/buildroot-2014.11/output/host/usr/bin:$PATH
+export PATH=$HOME/embedded-linux-labs/realtime/rttest/buildroot-YYYY.MM/output/host/usr/bin:$PATH
arm-none-linux-gnueabi-gcc -o rttest rttest.c \
$(pkg-config --libs --cflags libxenomai_posix)
\end{verbatim}
diff --git a/slides/sysdev-realtime/sysdev-realtime.tex b/slides/sysdev-realtime/sysdev-realtime.tex
index 6726634..a99f648 100644
--- a/slides/sysdev-realtime/sysdev-realtime.tex
+++ b/slides/sysdev-realtime/sysdev-realtime.tex
@@ -446,7 +446,7 @@
\frametitle{{\tt CONFIG\_PREEMPT\_RT} (1)}
\begin{itemize}
\item The PREEMPT\_RT patch adds a new level of preemption, called
- \code{CONFIG_PREEMPT_RT}
+ \code{CONFIG_PREEMPT_RT_FULL}
\item This level of preemption replaces all kernel spinlocks by
mutexes (or so-called sleeping spinlocks)
\begin{itemize}
@@ -465,7 +465,7 @@
\begin{frame}
\frametitle{{\tt CONFIG\_PREEMPT\_RT} (2)}
\begin{itemize}
- \item With \code{CONFIG_PREEMPT_RT}, virtually all kernel code
+ \item With \code{CONFIG_PREEMPT_RT_FULL}, virtually all kernel code
becomes preemptible
\begin{itemize}
\item An interrupt can occur at any time, when returning from the
@@ -509,7 +509,7 @@
some adaptations
\end{itemize}
\item Not all releases of the Linux kernel are supported.
- Currently: 3.0, 3.2, 3.4, 3.6, 3.8, 3.10, 3.12, 3.14, 3.18, 4.0, 4.1
+ Most recent: 3.4, 3.6, 3.8, 3.10, 3.12, 3.14, 3.18, 4.0, 4.1, 4.4, 4.6
\item Quick set up:
\begin{itemize}
\item Download the latest PREEMPT\_RT patch\\
@@ -526,7 +526,7 @@
\begin{itemize}
\item In the kernel configuration, be sure to enable
\begin{itemize}
- \item \code{CONFIG_PREEMPT_RT}
+ \item \code{CONFIG_PREEMPT_RT_FULL}
\item High-resolution timers
\end{itemize}
\item Compile your kernel, and boot
More information about the training-materials-updates
mailing list