Some notes on getting a Xenomai system running under buildroot.
- Installed Ubuntu 12.04 LTS.
- Downloaded buildroot-2011.11.
- Added build-essential, automake, bison, gawk, perl, zlib devel, ncurses devel, perhaps some other packages NB: If you are missing buildroot dependencies and you find out half-way through a build, rebuild from scratch, or risk getting a non-working system.
Buildroot/Xenomai version selection
The easiest way to do this without having to mess around with grub is to create a bootable CD image. Versions of buildroot up to 2012.08 support this. Choosing Kernel headers 3.4.X and kernel version 3.4.6 allows the ipipe-core-3.4.6-x86-2.patch from Xenomai 2.6.2 to be applied.
- Use 2012.08 Buildroot
- Bump Xenomai version to 2.6.2 (the latest)
- Remove lfs patch from Buildroot/package/xenomai directory as it won't apply to Xenomai 2.6.2.
# make menuconfig
Target Architecture -> i386
Target Architecture Variant -> i486
Toolchain -> Kernel Headers -> 3.4.x #### NB: This means we'll download two kernels, not one!
System Configuration -> Port to run a getty -> tty1
Package selection -> Real-Time -> Xenomai Userspace
Filesystem Images -> iso image
Bootloaders -> syslinux -> Install isolinux
Kernel -> Kernel version -> Same as toolchain kernel
Kernel -> Kernel configuration -> Using a defconfig
Kernel -> Defconfig name -> i386
Kernel -> Linux Kernel extensions -> Adeos/Xenomai real-time patch [*]
*** Now run 'make' to build the toolchain/download the kernel ***
Configure the kernel
# make linux-menuconfig
Filesystems -> Second extended fs support (ANNOYING BUG IN BUILDROOT!!)
Power management and ACPI options -> Power management support -> [ ]
Power management and ACPI options -> CPU Frequency scaling -> [ ]
Real-time sub-system -> machine -> enable fpu support -> [ ]
Due to a bug in VirtualBox, it won't boot the ISO rootfs because it is called rootfs.iso9660. Rename it to rootfs.iso, or make a link, and then VirtualBox will boot OK.
Compiling simple Xenomai example using Xenomai native interface
Get an example
Since we've not really 'installed' Xenomai on this machine, we have to fiddle about. First figure out what flags we need:
# cd ./output/host/usr/i486-unknown-linux-uclibc/sysroot
# ./usr/bin/xeno-config --skin native --cflags
-I/usr/include/xenomai -D_GNU_SOURCE -D_REENTRANT -Wall -pipe -D__XENO__
# ./usr/bin/xeno-config --skin native --ldflags
-lnative -L/usr/lib -lxenomai -lpthread
Use what we found to create a simple makefile, with includes and libs relative to the sysroot location. Put it in a directory beside the buildroot one.
CFLAGS:=-I$(SYSROOT)/usr/include/xenomai -D_GNU_SOURCE -D_REENTRANT -Wall -pipe -D__XENO__
LDFLAGS:=-lnative -L$(SYSROOT)/usr/lib -lxenomai -lpthread
trivial-periodic.c : $(BUILD)/xenomai-2.6.2/examples/native/trivial-periodic.c
cp $< $@
trivial-periodic.o : trivial-periodic.c
$(CC) $(CFLAGS) -o $@ -c $<
trivial-periodic : trivial-periodic.o
$(CC) -o $@ $< $(LDFLAGS)
The file 'trivial-periodic' can be copied into the VM and run. For some reason ldd reports different required libraries to the ones that exist on the target, but it doesn't seem to matter. The binary runs fine. It segfaults after aborting with ctrl-C though.