Search:  
Gentoo Wiki

HOWTO_ADEOS-based_RTAI/fusion_on_Gentoo

This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc

Contents

Introduction

This how-to describes how to add real-time capability to Gentoo Linux. Specifically it provides ebuild scripts along with patches for adding ADEOS and RTAI/fusion as Gentoo packages. The ADEOS package is a kernel source package like the many other kernel sources. RTAI/fusion is a set of kernel modules and libraries. The set-up has two parts: first the ADEOS real-time nanokernel hosted by Gentoo Linux; second, the RTAI/fusion kernel modules and libraries for supplying real-time functionality to user-space software.

Version numbers are 2.6r11c1/x86 for ADEOS and 0.8 for RTAI/fusion. The two new packages are

ADEOS' extra little revision component c1 means candidate number 1. However, note that the ebuild's version and revision cannot follow this pattern; Gentoo does not expect and cannot handle revision r11c1. For now, the ebuild skips the c1! Revision numbers without candidate specifications imply the latest candidate if final revision not yet available.

How to install ADEOS sources on Gentoo Linux

Start by copying the ebuild script and associated patch (see below) to your local Portage overlay, typically to /usr/local/portage but whatever your PORTDIR_OVERLAY contains. Use instructions like these or equivalent:

# mkdir -p /usr/local/portage/sys-kernel/adeos-sources/files
# cd path/to/open/gentoo/adeos/
# cp adeos-sources-2.6.11-r11.ebuild /usr/local/portage/sys-kernel/adeos-sources/
# cp adeos-sources-2.6.11-r11.patch /usr/local/portage/sys-kernel/adeos-sources/files/

Of course, you will most likely need root access in order to do this. You can easily test afterward if Portage successfully picks up the new local ebuild using equery w adeos-sources (you will need the gentoolkit package merged in order to run equery).

The answer should be

/usr/local/portage/sys-kernel/adeos-sources/adeos-sources-2.6.11-r11.ebuild

Now, set up the package using ebuild `equery w adeos-sources` digest

Portage will respond by downloading the kernel patch for ADEOS as well as the special genpatches for Gentoo Linux. The ebuild applies the genpatches after the ADEOS patch. The adeos-sources package is now ready for installation. You only need unmask the package and merge it!

For those new to Gentoo, unmasking the package means adding line

sys-kernel/adeos-sources ~x86

to your /etc/portage/package.keywords list. Merging means entering

# emerge adeos-sources

This merges the patched sources to its appropriate subdirectory under /usr/src. For kernel sources, Gentoo does not compile and install the sources, it only puts them in place ready for compiling. So you now need to build the kernel. Gentoo has different ways to accomplish this. One alternative: install directly from the source tree using make install. Another alternative: use Gentoo's genkernel tool. After merging the genkernel package, invoke genkernel using

# genkernel --xconfig --udev --kerneldir=/usr/src/linux-2.6.11-adeos-r11 all

for example. Note you need to specify the kernel directory otherwise it defaults to /usr/src/linux, your default kernel source tree. Emerging does 'not' automatically make the new kernel sources the default ones unless you enable the symlink USE flag. After the emerge, just proceed as any ordinary kernel. Regarding kernel configuration, I have found it best to load a previously-working configuration from /etc/kernels; genkernel copies each configuration here by name at the end of each successful kernel build. Naturally, you will also require a boot loader set up for new kernel.

One final note, do not forget to re-merge extra kernel drivers if your kernel needs them, e.g. ALSA drivers, ATI drivers and so on. You can specify a different kernel source tree for emerge using KERNEL_DIR as follows. KERNEL_DIR overrides the default, /usr/src/linux.

# KERNEL_DIR=/usr/src/linux-2.6.11-adeos-r11/ emerge alsa-driver
# KERNEL_DIR=/usr/src/linux-2.6.11-adeos-r11/ emerge ati-drivers

Carefully watch the console messages when the kernel boots; look for messages not previously encountered. After the kernel and operating system finish booting, check that ADEOS is running by cat'ing /proc/adeos. You should see something like this.

Adeos 2.6r11c1/x86 -- Pipelining: permanent (threaded)

   Linux: priority=100, id=0x00000000, ptdkeys=0/4
        irq0-15: accepted
        irq32: grabbed, virtual

Also, the kernel message log contains the following two entries (though not consecutively).

Adeos 2.6r11c1/x86: Root domain Linux registered.
Adeos: Pipelining started.

ADEOS ebuild script

Note, the script applies an extra patch 'after' the official patch for ADEOS; it fixes LOCALVERSION string.

File: adeos-sources-2.6.11-r11.ebuild
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

ETYPE="sources"
inherit kernel-2
detect_version

# Apply Gentoo patchset 11.12 both base and extras; this patch level
# is the latest available for the 2.6.11 version of the kernel, see
# genpatches at http://distro.ibiblio.org/pub/linux/distributions/gentoo/distfiles
# or other mirror.  The patches fix numerous issues with the vanilla
# kernel.  Apply the patches after applying ADEOS.  See next bit below.
GPV="11.12"
GPV_SRC="mirror://gentoo/genpatches-${KV_MAJOR}.${KV_MINOR}-${GPV}-base.tar.bz2
	mirror://gentoo/genpatches-${KV_MAJOR}.${KV_MINOR}-${GPV}-extras.tar.bz2"

#    _   ___  ___ ___  ___
#   /_\ |   \| __/ _ \/ __|
#  / _ \| |) | _| (_) \__ \
# /_/ \_\___/|___\___/|___/	2.6r11c1/x86
#
# (Adaptive Domain Environment for Operating Systems) KERNEL SOURCES
#
# Or, full Linux kernel sources on top of ADEOS nanokernel!
# See https://gna.org/projects/adeos, http://download.gna.org/adeos.
#
# Note about version and revision numbers: this ebuild's version
# number reflects the Linux kernel version number 2.6.11, and the
# revision number reflects the ADEOS major version number 11, hence r11.
#
# ADEOS' extra little revision component ``c1'' means candidate number 1.
# However, note that the ebuild's version and revision cannot follow
# this pattern; Gentoo does not expect and cannot handle revision
# r11c1.  For now, skip the c1!  Revision numbers without candidate
# specifications imply the latest candidate if final revision not
# yet available.
adeos_patches_uri="http://download.gna.org/adeos/patches"
adeos_linux_patch="adeos-linux-${PV}-i386-${PR}c1.patch" # c1 latest candidate, 16th June, 2005
KERNEL_PATCH_URI="${adeos_patches_uri}/v${KV_MAJOR}.${KV_MINOR}/i386/candidates/${adeos_linux_patch}"
KERNEL_PATCH="${DISTDIR}/${adeos_linux_patch}"
UNIPATCH_LIST="${KERNEL_PATCH} ${FILESDIR}/adeos-sources-${PVR}.patch
	${DISTDIR}/genpatches-${KV_MAJOR}.${KV_MINOR}-${GPV}-base.tar.bz2
	${DISTDIR}/genpatches-${KV_MAJOR}.${KV_MINOR}-${GPV}-extras.tar.bz2"
UNIPATCH_STRICTORDER="yes"

# Linux kernel license: GPL-2!
# ADEOS license: GPL-2 as well!
# See http://download.gna.org/adeos/COPYING.
LICENSE="GPL-2"

# ADEOS has kernel patches for a number of architectures:
#	arm (kernel 2.4 series only)
#	armnommu (kernel 2.4 series only)
#	i386
#	ia64 (kernel 2.6 series only)
#	ppc
# See http://download.gna.org/adeos/patches.
# However, this ebuild only builds the i386 version.
KEYWORDS="~x86"

DESCRIPTION="Linux kernel sources on top of ADEOS nanokernel"
SRC_URI="${KERNEL_URI} ${KERNEL_PATCH_URI} ${GPV_SRC}"
HOMEPAGE="http://www.kernel.org https://gna.org/projects/adeos"
IUSE=""

ADEOS patch

The patch fixes local version string: LOCALVERSION must not default to "-adeos" because Gentoo Portage does not handle local version strings too well yet.

File: adeos-sources-2.6.11-r11.patch
*** linux-2.6.11-adeos-r11/init/Kconfig.orig	Mon May 23 11:16:27 2005
--- linux-2.6.11-adeos-r11/init/Kconfig	Mon May 23 11:18:52 2005
***************
*** 61,67 ****
  
  config LOCALVERSION
  	string "Local version - append to kernel release"
! 	default "-adeos"
  	help
  	  Append an extra string to the end of your kernel version.
  	  This will show up when you type uname, for example.
--- 61,67 ----
  
  config LOCALVERSION
  	string "Local version - append to kernel release"
! 	default ""
  	help
  	  Append an extra string to the end of your kernel version.
  	  This will show up when you type uname, for example.

How to set up the Gentoo ebuild script for RTAI/fusion

Start by creating a subdirectory for the script (see below) somewhere in your local Portage subtree. I recommend subdirectory

/usr/local/portage/rtai/fusion

assuming /usr/local/portage specifies your PORTDIR_OVERLAY. See Gentoo wiki about overlaying local packages. Copy the ebuild script fusion-0.8.ebuild to this subdirectory. Copy the associated patch fusion-0.8.patch to subdirectory files under rtai/fusion. The local Portage tree should appear like this:

/usr/local/portage/rtai/fusion:
drwxr-xr-x  files
-rw-r-----  fusion-0.8.ebuild

/usr/local/portage/rtai/fusion/files:
-rw-r-----  fusion-0.8.patch

Check that Portage can find your ebuild as follows.

# equery w rtai/fusion
/usr/local/portage/rtai/fusion/fusion-0.8.ebuild

Note the answer given specifies the ebuild script for package rtai/fusion. Next, create the package manifest. Type the following; it also downloads the RTAI/fusion tarball from the Internet. Of course, you need Internet access at this point.

# ebuild `equery w rtai/fusion` digest

Finally, you can merge the rtai/fusion package in the normal way but do not forget to specify the right kernel source tree. The 'right' kernel tree is a kernel having real-time support enabled, e.g. a kernel with ADEOS support enabled. If not in /usr/src/linux, you can specify the kernel tree's location using KERNEL_DIR. For example, if you have an ADEOS kernel, use something like this command:

# KERNEL_DIR=/usr/src/linux-2.6.11-adeos-r11 emerge rtai/fusion

Test the installation by running the RTAI/fusion test suite. You can find the tests under /usr/share/fusion. You can run the tests one after the other using

for dir in /usr/share/fusion/testsuite/*
do cd $dir
pwd
./run
done

You will need to hit control-C to terminate the latency tests.

Gentoo USE flags for RTAI/fusion

RTAI/fusion has a number of different options. See IUSE in ebuild. You can enable these in the usual Gentoo USE flag ways.

RTAI/fusion ebuild script

Ebuild script for RTAI/fusion version 0.8, requiring Adeos 2.6r11c1/x86 or above.

File: fusion-0.8.ebuild
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit linux-info eutils

DESCRIPTION="Real-Time Application Interface fusion branch"
HOMEPAGE="http://www.rtai.org/"
SRC_URI="http://download.gna.org/rtai/experimental/${P}.tar.bz2"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="x86"
IUSE="nucleus-debug module-debug user-debug
	native-mps"
# Adeos 2.6r11c1/x86 or above is required to run this software; please upgrade.
DEPEND="sys-kernel/adeos-sources virtual/libc
	sys-devel/automake
	sys-devel/autoconf"
RDEPEND="sys-kernel/adeos-sources virtual/libc"

prefix=/usr

src_unpack() {
	unpack ${A}
	epatch ${FILESDIR}/${P}.patch || die "patch failed"

	# Fix configuration defaults.
	# Correct the version string.  Make it correspond to the package
	# version.  Also correct the installation directory.  Rather than
	# /usr/realtime make it track the installation prefix!
	sed -i \
		-e "s:\(CONFIG_RTAI_VERSION\)=.*:\1=\"${PV} (fusion)\":" \
		-e "s:\(CONFIG_RTAI_INSTALLDIR\)=.*:\1=\"${prefix}\":" \
		${S}/arch/i386/defconfig || die "sed failed"
}

src_compile() {
	libtoolize --copy --force
	scripts/bootstrap

	econf \
		$(use_enable nucleus-debug) \
		$(use_enable module-debug) \
		$(use_enable user-debug) \
		$(use_enable native-mps) \
		--with-linux-dir=${KV_DIR} \
		--with-module-dir=/lib/modules/${KV_FULL} \
		--prefix=${prefix} || die "configure failed"

	emake || die "make failed"
}

src_install() {
	emake install DESTDIR=${D} || die "install failed"

	rm ${D}/${prefix}/source
	rm ${D}/${prefix}/build
}

RTAI/fusion patch

RTAI/fusion patches for Gentoo Linux. Patches include using head -n <N> to output the first <N> lines where <N> specifies an integer. Do not use -<N> because it spits the ugly obsolete warning!

File: fusion-0.8.patch
*** fusion-0.8/configure.in~	Sun May 15 17:53:41 2005
--- fusion-0.8/configure.in	Mon May 23 13:10:14 2005
***************
*** 1136,1143 ****
  
  RTAI_MODULE_EXT=.ko
  RTAI_KBUILD_ENV='src2obj = $(patsubst %.$(1),%.o,$(filter %.$(1),$(call notdir,$(2))))'
! RTAI_KBUILD_TOP="@if test -e $RTAI_LINUX_DIR/Module.symvers; then mv -f $RTAI_LINUX_DIR/Module.symvers $RTAI_LINUX_DIR/__Module.symvers; fi; if test -e $RTAI_LINUX_DIR/vmlinux; then mv -f $RTAI_LINUX_DIR/vmlinux $RTAI_LINUX_DIR/__vmlinux; fi; "
! RTAI_KBUILD_BOTTOM="&& if test -e $RTAI_LINUX_DIR/__Module.symvers; then mv -f $RTAI_LINUX_DIR/__Module.symvers $RTAI_LINUX_DIR/Module.symvers; fi && if test -e $RTAI_LINUX_DIR/__vmlinux; then mv -f $RTAI_LINUX_DIR/__vmlinux $RTAI_LINUX_DIR/vmlinux; fi"
  RTAI_KBUILD_CMD="for src in \$(filter-out FORCE, \$^); do if test \\! -r \`basename \$\$src\`; then \$(LN_S) \$\$src; fi; done; \
                      \$(MAKE) -C $RTAI_LINUX_DIR CROSS_COMPILE=\$(CROSS_COMPILE) CC=$CC ARCH=$RTAI_TARGET_ARCH \
  		    M=\$\$PWD rtai_srctree=\`cd \$(top_srcdir) && pwd\` rtai_srcdir=\`cd \$(srcdir) && pwd\` V=\$(V) modules \
--- 1136,1143 ----
  
  RTAI_MODULE_EXT=.ko
  RTAI_KBUILD_ENV='src2obj = $(patsubst %.$(1),%.o,$(filter %.$(1),$(call notdir,$(2))))'
! RTAI_KBUILD_TOP=""
! RTAI_KBUILD_BOTTOM=""
  RTAI_KBUILD_CMD="for src in \$(filter-out FORCE, \$^); do if test \\! -r \`basename \$\$src\`; then \$(LN_S) \$\$src; fi; done; \
                      \$(MAKE) -C $RTAI_LINUX_DIR CROSS_COMPILE=\$(CROSS_COMPILE) CC=$CC ARCH=$RTAI_TARGET_ARCH \
  		    M=\$\$PWD rtai_srctree=\`cd \$(top_srcdir) && pwd\` rtai_srcdir=\`cd \$(srcdir) && pwd\` V=\$(V) modules \
*** fusion-0.8/GNUmakefile.am~	Sat Apr 16 17:12:44 2005
--- fusion-0.8/GNUmakefile.am	Mon May 23 14:06:23 2005
***************
*** 87,94 ****
  	      $$sudo mknod -m 666 $$f c 150 $$n; \
  	   fi; \
  	done ; \
! 	if test \! -c /dev/rtheap; then \
! 	  $$sudo mknod -m 666 /dev/rtheap c 10 254; \
  	fi
  
  uninstall-local:
--- 87,94 ----
  	      $$sudo mknod -m 666 $$f c 150 $$n; \
  	   fi; \
  	done ; \
! 	if test \! -c $(DESTDIR)/dev/rtheap; then \
! 	  $$sudo mknod -m 666 $(DESTDIR)/dev/rtheap c 10 254; \
  	fi
  
  uninstall-local:
*** fusion-0.8/testsuite/cruncher/GNUmakefile.am~	Sat Apr 16 17:12:50 2005
--- fusion-0.8/testsuite/cruncher/GNUmakefile.am	Mon May 23 16:48:49 2005
***************
*** 1,4 ****
! testdir = $(prefix)/testsuite/cruncher
  
  test_PROGRAMS = cruncher
  
--- 1,4 ----
! testdir = $(pkgdatadir)/testsuite/cruncher
  
  test_PROGRAMS = cruncher
  
*** fusion-0.8/testsuite/latency/GNUmakefile.am~	Sat Apr 16 17:12:50 2005
--- fusion-0.8/testsuite/latency/GNUmakefile.am	Mon May 23 16:50:17 2005
***************
*** 1,4 ****
! testdir = $(prefix)/testsuite/latency
  
  test_PROGRAMS = latency
  
--- 1,4 ----
! testdir = $(pkgdatadir)/testsuite/latency
  
  test_PROGRAMS = latency
  
*** fusion-0.8/testsuite/klatency/GNUmakefile.am~	Sat Apr 16 17:12:50 2005
--- fusion-0.8/testsuite/klatency/GNUmakefile.am	Mon May 23 16:52:28 2005
***************
*** 1,4 ****
! testdir = $(prefix)/testsuite/klatency
  
  modext = @RTAI_MODULE_EXT@
  
--- 1,4 ----
! testdir = $(pkgdatadir)/testsuite/klatency
  
  modext = @RTAI_MODULE_EXT@
  
*** fusion-0.8/testsuite/switch/GNUmakefile.am~	Sat Apr 16 17:12:50 2005
--- fusion-0.8/testsuite/switch/GNUmakefile.am	Mon May 23 16:53:04 2005
***************
*** 1,4 ****
! testdir = $(prefix)/testsuite/switch
  
  test_PROGRAMS = switch
  
--- 1,4 ----
! testdir = $(pkgdatadir)/testsuite/switch
  
  test_PROGRAMS = switch
  
*** fusion-0.8/scripts/rtai-load.in~	Sat Apr 16 17:12:45 2005
--- fusion-0.8/scripts/rtai-load.in	Mon May 23 18:04:41 2005
***************
*** 56,62 ****
  fi
  
  if test $target_name = default; then
!   target_name=`cut -s -d: -f1 $run_info_file | head -1`
    if test "x$target_name" = x; then
       echo "rtai-load: no target defined in $run_info_file"
       exit 2
--- 56,62 ----
  fi
  
  if test $target_name = default; then
!   target_name=`cut -s -d: -f1 $run_info_file | head -n 1`
    if test "x$target_name" = x; then
       echo "rtai-load: no target defined in $run_info_file"
       exit 2
*** fusion-0.8/scripts/rtai-info~	Sat Aug 28 11:45:30 2004
--- fusion-0.8/scripts/rtai-info	Mon May 23 18:04:17 2005
***************
*** 54,60 ****
  -e 's/\.so$//' | awk -F'[.-]'   '{print "Linux C Library        " \
  $(NF-2)"."$(NF-1)"."$NF}'
  
! ldd -v > /dev/null 2>&1 && ldd -v || ldd --version |head -1 | awk \
  'NR==1{print "Dynamic linker (ldd)  ", $NF}'
  
  ls -l /usr/lib/lib{g,stdc}++.so  2>/dev/null | awk -F. \
--- 54,60 ----
  -e 's/\.so$//' | awk -F'[.-]'   '{print "Linux C Library        " \
  $(NF-2)"."$(NF-1)"."$NF}'
  
! ldd -v > /dev/null 2>&1 && ldd -v || ldd --version |head -n 1 | awk \
  'NR==1{print "Dynamic linker (ldd)  ", $NF}'
  
  ls -l /usr/lib/lib{g,stdc}++.so  2>/dev/null | awk -F. \
*** fusion-0.8/scripts/rtai-test.in~	Sat Apr 16 17:12:45 2005
--- fusion-0.8/scripts/rtai-test.in	Mon May 23 18:10:58 2005
***************
*** 37,43 ****
      echo;  date;
      echo running $PWD: $*
      $* &
!     top -bn1c | head -$(( 12 + $workload ))
      wait
  }
  
--- 37,43 ----
      echo;  date;
      echo running $PWD: $*
      $* &
!     top -bn1c | head -n $(( 12 + $workload ))
      wait
  }
  

Feedback

Concerns or Compliments? Please use the Discussion section.

Retrieved from "http://www.gentoo-wiki.info/HOWTO_ADEOS-based_RTAI/fusion_on_Gentoo"

Last modified: Thu, 16 Jun 2005 21:09:00 +0000 Hits: 10,248