[FE training-materials-updates] sysdev-real-time: bump Xenomai, Buildroot and kernel

Thomas Petazzoni thomas.petazzoni at free-electrons.com
Mon Oct 8 12:16:25 CEST 2012


Repository : git://git.free-electrons.com/training-materials.git

On branch  : master
Link       : http://git.free-electrons.com/training-materials/commit/?id=b676e10d8b94412551a84d4926232457b0ff80a2

>---------------------------------------------------------------

commit b676e10d8b94412551a84d4926232457b0ff80a2
Author: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
Date:   Mon Oct 8 12:11:20 2012 +0200

    sysdev-real-time: bump Xenomai, Buildroot and kernel
    
    Bump the Xenomai version to 2.6.1, which allows to bump the kernel to
    3.2.21. Also bump the Buildroot version to 2012.08.
    
    In detail:
    
     * Add a Buildroot patch that bumps Xenomai to 2.6.1. We can't just do
       a simple bump, as we need to remove/add Xenomai patches as well.
    
     * Adjust the Buildroot building instructions (apply the patch, no
       longer needed to specify the number of parallel jobs, no longer
       needed to give a custom Xenomai version)
    
     * Bump kernel version to 3.2.21. Instruct to disable certain options.
    
     * The message "Listening on any address 5566" never appears: we
       redirect the standard output and error output of the doload script
       to /dev/null.
    
     * Do not re-download Xenomai a second time: simply use the sources
       downloaded by Buildroot.
    
     * Use pkg-config (new feature in Xenomai 2.6.1) to build applications
       instead of the custom xeno-config script.
    
     * Writing to /proc/xenomai/latency no longer shows an error.
    
    Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>


>---------------------------------------------------------------

b676e10d8b94412551a84d4926232457b0ff80a2
 .../buildroot-2012.08-bump-xenomai-to-2.6.1.patch  |  271 ++++++++++++++++++++
 labs/sysdev-real-time/sysdev-real-time.tex         |   75 +++---
 2 files changed, 308 insertions(+), 38 deletions(-)

diff --git a/lab-data/realtime/rttest/data/buildroot-2012.08-bump-xenomai-to-2.6.1.patch b/lab-data/realtime/rttest/data/buildroot-2012.08-bump-xenomai-to-2.6.1.patch
new file mode 100644
index 0000000..81c6d9e
--- /dev/null
+++ b/lab-data/realtime/rttest/data/buildroot-2012.08-bump-xenomai-to-2.6.1.patch
@@ -0,0 +1,271 @@
+From 742c60d52f39b2e34a442e75d8fff25c1bb35bfa Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
+Date: Mon, 8 Oct 2012 11:41:44 +0200
+Subject: [PATCH] xenomai: bump to 2.6.1
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
+---
+ package/xenomai/xenomai-fix-lfs-issue.patch |   72 ------------
+ package/xenomai/xenomai-thumb-fix.patch     |  157 +++++++++++++++++++++++++++
+ package/xenomai/xenomai.mk                  |    2 +-
+ 3 files changed, 158 insertions(+), 73 deletions(-)
+ delete mode 100644 package/xenomai/xenomai-fix-lfs-issue.patch
+ create mode 100644 package/xenomai/xenomai-thumb-fix.patch
+
+diff --git a/package/xenomai/xenomai-fix-lfs-issue.patch b/package/xenomai/xenomai-fix-lfs-issue.patch
+deleted file mode 100644
+index 157c8e2..0000000
+--- a/package/xenomai/xenomai-fix-lfs-issue.patch
++++ /dev/null
+@@ -1,72 +0,0 @@
+-From: Gilles Chanteperdrix <gilles.chanteperdrix at xenomai.org>
+-Date: Sat, 5 Nov 2011 20:59:01 +0000 (+0100)
+-Subject: posix: fix compilation for LFS
+-X-Git-Url: http://git.xenomai.org/?p=xenomai-2.6.git;a=commitdiff_plain;h=06ae5c5e47fbfd9d8dbbe6fcf1a1db0c14bad9de;hp=8f6feff876029244dabc1257cdf13209fbd64fb5
+-
+-posix: fix compilation for LFS
+----
+-
+-diff --git a/include/posix/sys/mman.h b/include/posix/sys/mman.h
+-index 455e565..a304755 100644
+---- a/include/posix/sys/mman.h
+-+++ b/include/posix/sys/mman.h
+-@@ -63,17 +63,16 @@ int __real_shm_open(const char *name, int oflag, mode_t mode);
+- 
+- int __real_shm_unlink(const char *name);
+- 
+--#if !defined(_FILE_OFFSET_BITS) || _FILE_OFFSET_BITS != 64
+- void *__real_mmap(void *addr,
+- 		  size_t len,
+- 		  int prot,
+- 		  int flags,
+- 		  int fildes,
+- 		  long off);
+--#else
+--#define __real_mmap __real_mmap64
+--#endif
+--#ifdef _LARGEFILE64_SOURCE
+-+
+-+#if __WORDSIZE == 32
+-+#if defined(_LARGEFILE64_SOURCE) \
+-+	|| defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
+- void *__real_mmap64(void *addr,
+- 		    size_t len,
+- 		    int prot,
+-@@ -82,6 +81,11 @@ void *__real_mmap64(void *addr,
+- 		    long long off);
+- #endif
+- 
+-+#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
+-+#define __real_mmap __real_mmap64
+-+#endif
+-+#endif
+-+
+- int __real_munmap(void *addr, size_t len);
+- 
+- #ifdef __cplusplus
+-diff --git a/include/posix/unistd.h b/include/posix/unistd.h
+-index 49463a0..90cce86 100644
+---- a/include/posix/unistd.h
+-+++ b/include/posix/unistd.h
+-@@ -54,13 +54,17 @@ int ftruncate(int fildes, off_t length);
+- extern "C" {
+- #endif
+- 
+--#if !defined(_FILE_OFFSET_BITS) || _FILE_OFFSET_BITS != 64
+- int __real_ftruncate(int fildes, long length);
+--#else
+-+
+-+#if __WORDSIZE == 32
+-+#if defined(_LARGEFILE64_SOURCE) \
+-+	|| defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
+-+int __real_ftruncate64(int fildes, long long length);
+-+#endif
+-+
+-+#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
+- #define __real_ftruncate __real_ftruncate64
+- #endif
+--#ifdef _LARGEFILE64_SOURCE
+--int __real_ftruncate64(int fildes, long long length);
+- #endif
+- 
+- ssize_t __real_read(int fd, void *buf, size_t nbyte);
+diff --git a/package/xenomai/xenomai-thumb-fix.patch b/package/xenomai/xenomai-thumb-fix.patch
+new file mode 100644
+index 0000000..7c98c2e
+--- /dev/null
++++ b/package/xenomai/xenomai-thumb-fix.patch
+@@ -0,0 +1,157 @@
++From ad3714e925f5c6b4ae0e0d31c4bab7f8c5e659db Mon Sep 17 00:00:00 2001
++From: Gilles Chanteperdrix <gilles.chanteperdrix at xenomai.org>
++Date: Fri, 10 Aug 2012 21:55:41 +0200
++Subject: [PATCH] hal/arm: fix compilation for thumb
++
++---
++ include/asm-arm/atomic.h |    3 ++
++ ksrc/arch/arm/switch.S   |   84 +++++++++++++++++++++++++++------------------
++ 2 files changed, 53 insertions(+), 34 deletions(-)
++
++diff --git a/include/asm-arm/atomic.h b/include/asm-arm/atomic.h
++index 5d55ae8..ae96847 100644
++--- a/include/asm-arm/atomic.h
+++++ b/include/asm-arm/atomic.h
++@@ -183,6 +183,9 @@ xnarch_atomic_cmpxchg(xnarch_atomic_t *ptr,
++ 		"ldrex	%1, [%3]\n"
++ 		"mov	%0, #0\n"
++ 		"teq	%1, %4\n"
+++#ifdef __thumb__
+++		"it	eq\n"
+++#endif
++ 		"strexeq %0, %5, [%3]\n"
++ 		    : "=&r" (res), "=&r" (curval), "+Qo" (ptr->counter)
++ 		    : "r" (&ptr->counter), "Ir" (oldval), "r" (newval)
++diff --git a/ksrc/arch/arm/switch.S b/ksrc/arch/arm/switch.S
++index 83f4746..95c355f 100644
++--- a/ksrc/arch/arm/switch.S
+++++ b/ksrc/arch/arm/switch.S
++@@ -37,6 +37,11 @@
++ 	.endm
++ #endif
++ 
+++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
+++#define ARM(x...)	x
+++#define THUMB(x...)
+++#endif
+++
++ #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 37)
++ #ifdef CONFIG_MMU
++ #define USE_DOMAINS
++@@ -83,18 +88,19 @@
++  * r0 = pointer to union vfp_state, r1 = fpexc
++  */
++ ENTRY(rthal_vfp_save)
++-    VFPFSTMIA	r0, r2			@ save the working registers
++-    VFPFMRX	r2, FPSCR		@ current status
++-    tst		r1, #FPEXC_EX		@ is there additional state to save?
++-    beq 1f
++-    VFPFMRX	r3, FPINST		@ FPINST (only if FPEXC.EX is set)
++-    tst		r1, #FPEXC_FP2V		@ is there an FPINST2 to read?
++-    beq 1f
++-    VFPFMRX	r12, FPINST2	@ FPINST2 if needed (and present)
+++	VFPFSTMIA	r0, r2		@ save the working registers
+++	VFPFMRX		r2, FPSCR	@ current status
+++	tst		r1, #FPEXC_EX	@ is there additional state to save?
+++	beq		1f
+++	VFPFMRX		r3, FPINST	@ FPINST (only if FPEXC.EX is set)
+++	tst		r1, #FPEXC_FP2V	@ is there an FPINST2 to read?
+++	beq		1f
+++	VFPFMRX		r12, FPINST2	@ FPINST2 if needed (and present)
++ 1:
++-    stmia	r0, {r1, r2, r3, r12}	@ save FPEXC, FPSCR, FPINST, FPINST2
++-    mov		pc, lr
++-
+++	stmia		r0, {r1, r2, r3, r12}	@ save FPEXC, FPSCR, FPINST, FPINST2
+++	mov		pc, lr
+++ENDPROC(rthal_vfp_save)
+++	
++ /* Copied from no_old_VFP_process in arch/arm/vfp/vfphw.S
++  * r0 = pointer to union vfp_state
++  * r1 = current cpu
++@@ -102,20 +108,21 @@ ENTRY(rthal_vfp_save)
++ ENTRY(rthal_vfp_load)
++ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) \
++ 	|| defined(CONFIG_VFP_3_2_BACKPORT)) && defined(CONFIG_SMP)
++-    str 	r1, [r0, #VFP_CPU]
+++	str		r1, [r0, #VFP_CPU]
++ #endif
++-    VFPFLDMIA	r0, r2			@ reload the working registers while
+++	VFPFLDMIA	r0, r2		@ reload the working registers while
++ 					@ FPEXC is in a safe state
++-    ldmia	r0, {r1, r2, r3, r12}	@ load FPEXC, FPSCR, FPINST, FPINST2
++-    tst		r1, #FPEXC_EX		@ is there additional state to restore?
++-    beq		1f
++-    VFPFMXR	FPINST, r3		@ restore FPINST (only if FPEXC.EX is set)
++-    tst		r1, #FPEXC_FP2V		@ is there an FPINST2 to write?
++-    beq		1f
++-    VFPFMXR	FPINST2, r12	@ FPINST2 if needed (and present)
+++	ldmia		r0, {r1, r2, r3, r12}	@ load FPEXC, FPSCR, FPINST, FPINST2
+++	tst		r1, #FPEXC_EX	@ is there additional state to restore?
+++	beq		1f
+++	VFPFMXR		FPINST, r3	@ restore FPINST (only if FPEXC.EX is set)
+++	tst		r1, #FPEXC_FP2V	@ is there an FPINST2 to write?
+++	beq		1f
+++	VFPFMXR		FPINST2, r12	@ FPINST2 if needed (and present)
++ 1:
++-    VFPFMXR	FPSCR, r2		@ restore status
++-    mov		pc, lr
+++	VFPFMXR		FPSCR, r2	@ restore status
+++	mov		pc, lr
+++ENDPROC(rthal_vfp_load)
++ #endif
++ 
++ /*
++@@ -144,28 +151,37 @@ ENTRY(rthal_vfp_load)
++  * r0 = previous task_struct, r1 = previous thread_info, r2 = next thread_info
++  */
++ ENTRY(rthal_thread_switch)
++-    add     ip, r1, #TI_CPU_SAVE
++-    ldr     r3, [r2, #TI_TP_VALUE]
++-    stmia   ip!, {r4 - sl, fp, sp, lr}      @ Store most regs on stack
+++	add     ip, r1, #TI_CPU_SAVE
+++	ldr     r3, [r2, #TI_TP_VALUE]
+++ ARM(	stmia	ip!, {r4 - sl, fp, sp, lr} )	@ Store most regs on stack
+++ THUMB(	stmia	ip!, {r4 - sl, fp}	   )	@ Store most regs on stack
+++ THUMB(	str	sp, [ip], #4		   )
+++ THUMB(	str	lr, [ip], #4		   )
++ #ifdef USE_DOMAINS
++-    ldr     r6, [r2, #TI_CPU_DOMAIN]
+++	ldr     r6, [r2, #TI_CPU_DOMAIN]
++ #endif
++ 
++-    clear_exclusive_monitor
++-    set_tls r3, r4, r5
+++	clear_exclusive_monitor
+++	set_tls r3, r4, r5
++ #ifdef USE_DOMAINS
++-    mcr     p15, 0, r6, c3, c0, 0           @ Set domain register
+++	mcr     p15, 0, r6, c3, c0, 0           @ Set domain register
++ #endif
++-    fpu_switch r4
++-    add	    r4, r2, #TI_CPU_SAVE
++-    ldmia   r4, {r4 - sl, fp, sp, pc}       @ Load all regs saved previously
+++	fpu_switch r4
+++ ARM(	add	r4, r2, #TI_CPU_SAVE	   )
+++ ARM(	ldmia	r4, {r4 - sl, fp, sp, pc}  )	@ Load all regs saved previously
+++ THUMB(	add	ip, r2, #TI_CPU_SAVE	   )
+++ THUMB(	ldmia	ip!, {r4 - sl, fp}	   )	@ Load all regs saved previously
+++ THUMB(	ldr	sp, [ip], #4		   )
+++ THUMB(	ldr	pc, [ip]		   )
+++ENDPROC(rthal_thread_switch)
++ 
++ /*
++  * r4 = xnarch_thread_trampoline
++  * r5 = xnarchtcb_t *
++  */
++ ENTRY(rthal_thread_trampoline)
++-    mov     r0, r5
++-    mov     pc, r4
+++	mov	r0, r5
+++	mov	pc, r4
+++ENDPROC(rthal_thread_trampoline)
++ 
++ // vim: ts=4 et sw=4 sts=4
++-- 
++1.7.2.5
++
+diff --git a/package/xenomai/xenomai.mk b/package/xenomai/xenomai.mk
+index 6dbdcea..e425b75 100644
+--- a/package/xenomai/xenomai.mk
++++ b/package/xenomai/xenomai.mk
+@@ -7,7 +7,7 @@
+ 
+ XENOMAI_VERSION = $(call qstrip,$(BR2_PACKAGE_XENOMAI_VERSION))
+ ifeq ($(XENOMAI_VERSION),)
+-XENOMAI_VERSION = 2.6.0
++XENOMAI_VERSION = 2.6.1
+ endif
+ 
+ XENOMAI_SITE = http://download.gna.org/xenomai/stable/
+-- 
+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 a128631..5566750 100644
--- a/labs/sysdev-real-time/sysdev-real-time.tex
+++ b/labs/sysdev-real-time/sysdev-real-time.tex
@@ -27,18 +27,18 @@ supports Xenomai.
 
 Let's build this with Buildroot.
 
-Download and extract the Buildroot 2012.05 sources.
+Download and extract the Buildroot 2012.08 sources. Apply the
+Buildroot patch \code{buildroot-2012.08-bump-xenomai-to-2.6.1.patch}
+from the lab {\em data} directory to your Buildroot sources. It
+upgrades the Xenomai version to 2.6.1, which allows to use the 3.2
+kernel.
 
 Configure Buildroot with the following settings, using the \code{/}
 command in \code{make menuconfig} to find parameters by their name:
 
 \begin{itemize}
 \item \code{Target architecture}: \code{ARM (little endian)} 
-\item \code{Target Architecture Variant}: \code{generic_arm}
-\item In \code{Build options}:
-   \begin{itemize}
-   \item \code{Number of jobs to run simultaneously}: \code{4}
-   \end{itemize}
+\item \code{Target Architecture Variant}: \code{cortex-a8}
 \item In \code{Toolchain}:
    \begin{itemize}
    \item \code{Toolchain type}: \code{External toolchain}
@@ -60,7 +60,6 @@ command in \code{make menuconfig} to find parameters by their name:
    \item In \code{Networking applications}, enable \code{netcat}
    \item In \code{Real-Time}, enable \code{Xenomai Userspace}:
          \begin{itemize}
-         \item \code{Custom Xenomai version}: \code{2.6.0}
          \item Enable \code{Install testsuite}
 	 \item Make sure that \code{POSIX skin library} is enabled.
   	 \end{itemize}
@@ -73,8 +72,8 @@ At the end of the build job, extract the
 \code{output/images/rootfs.tar} archive in the \code{nfsroot}
 directory.
 
-The last thing to do is to add a few files that we will need 
-in our tests:
+The last thing to do is to add a few files that we will need in our
+tests:
 
 \begin{verbatim}
 cp data/* nfsroot/root
@@ -82,8 +81,8 @@ cp data/* nfsroot/root
 
 \section{Compile a standard Linux kernel}
 
-Download the exact Linux 2.6.38.8 version. That's the most recent
-ARM Linux version that Xenomai 2.6.0 supports. You will have trouble
+Download the exact Linux 3.2.21 version. That's the most recent
+ARM Linux version that Xenomai 2.6.1 supports. You will have trouble
 applying Xenomai kernel patches otherwise.
 
 Configure your kernel with the default configuration for the IGEPv2
@@ -97,6 +96,12 @@ In the kernel configuration interface:
       present on the system.
 \item For the moment, remove \code{CONFIG_HIGH_RES_TIMERS},
       to start by testing the kernel without high-resolution timers.
+\item Disable \code{CONFIG_SMP}, as Xenomai 2.6.1 does not support
+  yet multi-processing on OMAP (and the IGEPv2 is anyway a single
+  core processor).
+\item Disable \code{CONFIG_PROVE_LOCKING},
+  \code{CONFIG_DEBUG_LOCK_ALLOC}, \code{CONFIG_DEBUG_MUTEXES} and
+  \code{CONFIG_DEBUG_SPINLOCK}.
 \end{itemize}
 
 Boot the IGEP board by mounting the root filesystem that you built.
@@ -119,7 +124,7 @@ Let's configure our \code{PATH} to use this toolchain:
 
 \begin{verbatim}
 export
-PATH=$HOME/felabs/realtime/rttest/buildroot-2012.05/output/host/usr/bin:$PATH
+PATH=$HOME/felabs/realtime/rttest/buildroot-2012.08/output/host/usr/bin:$PATH
 \end{verbatim}
 
 Have a look at the \code{rttest.c} source file available in \code{root/} in
@@ -149,11 +154,10 @@ Now, do the following tests:
 \item Test the program with nothing special and write down the
   results.
 \item Test your program and at the same time, add some workload to the
-  board, by running \code{/root/doload 300 > /dev/null 2>&1 &} on the board,
-  and using \code{netcat 192.168.0.100 5566} on your workstation when
-  you see the message \code{Listening on any address 5566} in order to
-  flood the network interface of the IGEP board (where 192.168.0.100
-  is the IP address of the IGEP board).
+  board, by running \code{/root/doload 300 > /dev/null 2>&1 &} on the
+  board, and using \code{netcat 192.168.0.100 5566} on your
+  workstation in order to flood the network interface of the IGEP
+  board (where 192.168.0.100 is the IP address of the IGEP board).
 \item Test your program again with the workload, but by running the
   program in the \code{SCHED_FIFO} scheduling class at priority 99,
   using the \code{chrt} command.
@@ -170,12 +174,11 @@ the results.
 
 \section{Testing Xenomai scheduling latency}
 
-Get the latest Xenomai 2.6.x release from its download area at
-\url{http://download.gna.org/xenomai/stable/} and untar Xenomai.
-
 Prepare the kernel for Xenomai compilation:
 \begin{verbatim}
-./scripts/prepare-kernel.sh --arch=arm --linux=/path/to/linux-2.6.38.8
+cd $HOME/felabs/realtime/rttest/buildroot-2012.08/
+./output/build/xenomai-2.6.1/scripts/prepare-kernel.sh \
+   --arch=arm --linux=/path/to/linux-3.2.21
 \end{verbatim}
 
 Now, run the kernel configuration interface, and make sure that
@@ -188,21 +191,26 @@ description:
 \item \code{CONFIG_XENO_HW_UNLOCKED_SWITCH}
 \end{itemize}
 
-Now, you also have to disable \code{CONFIG_ARCH_OMAP2},
-and \code{CONFIG_ARCH_OMAP4}. Xenomai doesn't seem to support
-the OMAP2 and OMAP4 boards, and the kernel won't build
-if you don't disable the above options. 
+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}:
+
+\begin{verbatim}
+cd $HOME/felabs/realtime/rttest/buildroot-2012.08/
+make host-pkg-config
+\end{verbatim}
 
 Compile your kernel, and in the meantime,
 compile \code{rttest} for the Xenomai POSIX skin:
 
+\small
 \begin{verbatim}
 cd $HOME/felabs/realtime/rttest/nfsroot/root
-export DESTDIR=$HOME/felabs/realtime/rttest/buildroot-2012.05/output/staging
-CFL=$($DESTDIR/usr/bin/xeno-config --skin posix --cflags)
-LDF=$($DESTDIR/usr/bin/xeno-config --skin posix --ldflags)
-arm-none-linux-gnueabi-gcc $CFL -o rttest rttest.c $LDF
+export PATH=$HOME/felabs/realtime/rttest/buildroot-2012.08/output/host/usr/bin:$PATH
+arm-none-linux-gnueabi-gcc -o rttest rttest.c $(pkg-config libxenomai_posix)
 \end{verbatim}
+\normalsize
 
 Now boot the board with the new kernel.
 
@@ -212,15 +220,6 @@ Run the following commands on the board:
 echo 0 > /proc/xenomai/latency
 \end{verbatim}
 
-In the current version, you will get the following error:
-
-\begin{verbatim}
-sh: write error: Bad address
-\end{verbatim}
-
-You can check that \code{/proc/xenomai/latency} contains \code{0}. It
-should be safe to ignore this error.
-
 This will disable the timer compensation feature of Xenomai. This
 feature allows Xenomai to adjust the timer programming to take into
 account the time the system needs to schedule a task after being woken



More information about the training-materials-updates mailing list