EBC Xenomai

Xenomai is a set of patches for the kernel that allow it to run real-time tasks. This is an adaptation of Bruno Martins' Xenomai on the Beaglebone Black in 14 easy steps that works with the kernel installed in EBC Installing Kernel Source.

Patching the Kernel

 * Install the kernel source (EBC Installing Kernel Source). I'll assume it's in bb-kernel
 * Be sure you have compiled the kernel before applying the patches to be sure it really works.
 * Download the current version of Xenomai. Browse to http://download.gna.org/xenomai/stable/latest/ to see what the latest version is, then

host$ wget http://download.gna.org/xenomai/stable/latest/xenomai-2.6.4.tar.bz2


 * Checkout the the latest kernel

host$ cd bb-kernel/KERNEL host$ uname -a host$ git tags | sort | less Pick the tag that is close to your current version of the kernel. host$ git checkout 3.8.13-bone67 -b xenomai

host$ cd bb-kernel/KERNEL host$ '''patch -p1 < ../../xenomai-2.6.4/ksrc/arch/arm/patches/beaglebone/ipipe-core-3.8.13-beaglebone-pre.patch host$ patch -p1 < ../../xenomai-2.6.4/ksrc/arch/arm/patches/ipipe-core-3.8.13-arm-4.patch host$ patch -p1 < ../../xenomai-2.6.4/ksrc/arch/arm/patches/beaglebone/ipipe-core-3.8.13-beaglebone-post.patch host$ '''cat > thumb.patch diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index e2bc263..6f4d9f0 100644 --- a/arch/arm/kernel/entry-armv.S +++ b/arch/arm/kernel/entry-armv.S @@ -469,6 +469,7 @@ __irq_usr: kuser_cmpxchg_check irq_handler #ifdef CONFIG_IPIPE +THUMB(	it	ne ) bne	__ipipe_ret_to_user_irqs_disabled #endif	/* CONFIG_IPIPE */ get_thread_info tsk @@ -767,6 +768,7 @@ ENTRY(ret_from_exception) disable_irq bl	__ipipe_check_root cmp    r0, #1 +THUMB(	it	ne ) bne	__ipipe_ret_to_user_irqs_disabled @ Fast exit path over non-root domains #endif /* CONFIG_IPIPE */ get_thread_info tsk host$ patch -p1 < thumb.patch
 * Patch the kernel. This assumes bb-kernel and xenomai-2.6.4 are at the same directory level.
 * Then one more patch from, which is shown here.

host$ cd ../../xenomai-2.6.4/scripts host$ ./prepare-kernel.sh --arch=arm --linux=../../bb-kernel/KERNEL/
 * Prepare the kernel

Compile the Kernel
host$ cd ../../bb-kernel Make sure AUTO_BUILD is turned off. host$ vi system.sh Be sure the last line commented out. host$ tools/rebuild.sh Then sit back an wait.
 * 1) AUTO_BUILD=1
 * Build the kernel
 * When the configuration menu comes up
 * Under CPU Power Management --->  CPU Frequency scaling, disable  [ ] CPU Frequency scaling.
 * Under Real-time sub-system  ---> Drivers ---> Testing drivers, enable everything

Setting up the Bone
While you are waiting for the compile to finish, you can set up the Bone.

host$ scp -r xenomai-2.6.4 192.168.7.2:.
 * Copy Xenomai to the Bone. I'm assuming the Bone is at 192.168.7.2.

bone$ cd xenomai-2.6.4 bone$ ./configure CFLAGS="-march=armv7-a -mfpu=vfp3" LDFLAGS="-march=armv7-a -mfpu=vfp3" bone$ make bone$ make install The configure takes about a minute, the make six more minutes and the install another minute.
 * On the Bone

Copy the drives. bone$ cd; mkdir xenomai_drivers; cd xenomai_drivers host$ cd bb-kernel/KERNEL/drivers/xenomai/testing host$ scp *.ko 192.167.7.2:xenomai_drivers

Running Tests
Now, run some tests.

User-mode latency. bone$ /usr/xenomai/bin/latency == Sampling period: 1000 us == Test mode: periodic user-mode task == All results in microseconds warming up... RTT| 00:00:01  (periodic user-mode task, 1000 us period, priority 99) RTH|lat min|lat avg|lat max|-overrun|---msw|---lat best|--lat worst RTD|     3.624|      3.833|     20.458|       0|     0|      3.624|     20.458 RTD|     2.749|      3.749|     22.583|       0|     0|      2.749|     22.583 RTD|     2.749|      4.583|     25.499|       0|     0|      2.749|     25.499 RTD|     2.749|      3.708|     20.541|       0|     0|      2.749|     25.499 RTD|     2.749|      3.749|     21.916|       0|     0|      2.749|     25.499 ^C---|---|---|---||--|- RTS|     2.749|      3.916|     25.499|       0|     0|    00:00:05/00:00:05

In-kernel latency bone$ /usr/xenomai/bin/klatency == Sampling period: 100 us == Test mode: in-kernel periodic task == All results in microseconds warming up... RTT| 00:00:00  (in-kernel periodic task, 100 us period, priority 99) RTH|-lat min|-lat avg|-lat max|-overrun|lat best|---lat worst RTD|     -3.055|      -2.295|       1.903|       0|      -5.885|      11.207 RTD|     -2.430|      -2.298|       1.653|       0|      -5.885|      11.207 RTD|     -2.389|      -2.307|       1.611|       0|      -5.885|      11.207 RTD|     -2.389|      -2.300|       2.236|       0|      -5.885|      11.207 RTD|     -4.306|      -2.192|       3.486|       0|      -5.885|      11.207 RTD|     -2.890|      -2.298|       2.360|       0|      -5.885|      11.207 RTD|     -3.265|      -2.294|       2.694|       0|      -5.885|      11.207 RTD|     -3.057|      -2.295|       2.777|       0|      -5.885|      11.207 RTD|     -3.098|      -2.297|       2.276|       0|      -5.885|      11.207 RTD|     -4.849|      -2.188|       4.276|       0|      -5.885|      11.207 RTD|     -3.153|      -2.272|       2.847|       0|      -5.885|      11.207 RTD|     -2.445|      -2.313|       1.805|       0|      -5.885|      11.207 RTD|     -3.195|      -2.195|       3.721|       0|      -5.885|      11.207 ^CRTD|     -2.404|      -2.312|       2.180|       0|      -5.885|      11.207 ---|||||- RTS|     -5.885|      -2.275|      11.207|       0|    00:00:03/00:00:03

Poke around some bone$ ls /proc/xenomai acct     faults       irq      registry/  schedclasses/  timer affinity heap         latency  rtdm/      stat           timerstat/ apc      interfaces/  lock     sched      timebases      version bone$ ls -F /proc/ipipe Linux version  Xenoma bone$ cat /proc/xenomai/version 2.6.4 bone$ cat /proc/ipipe/version 4