Skip to main content.

Compiling and Running Xenomai on a TQM5200 Board

Author

This document was written by Detlev Zundel (dzu {at} denx {dot} de).

Context

Although our ELDK contains a Xenomai-enabled kernel and a Xenomai RPM, it is of interest to show how to compile and run Xenomai from freshly built sources.

We will use the ELDK 4.2 as the toolchain and we will install our new copy of Xenomai into its NFS root filesystem to immediately test it out. So a working installation of it is required in /opt/eldk-4.2

As usual for multiuser system, we'll be doing all the compiling below the homedirectory, but any place should do really:

$ cd ~
$ mkdir xenomai-on-tqm5200
$ cd xenomai-on-tqm5200

Getting the sources

Get Xenomai

We'll use a fresh Subversion checkout for this application note, so let's get it.

$ git clone git://git.xenomai.org/xenomai-2.5.git
$ cd xenomai-2.5 

Let's see what the latest tag is:

$ git tag -l | tail -3
v2.5.5
v2.5.5.1
v2.5.5.2

Ok, so we'll use v2.5.5.2 by checking it out into a local branch named just the same:

$ git checkout -b v2.5.5.2 v2.5.5.2

Get Linux kernel

To find out what kernel version is supported with xenomai, we'll take a look at the directory containing the kernel patches:

$ ls ksrc/arch/powerpc/patches/
adeos-ipipe-2.4.25-ppc-DENX-2.2-01.patch  adeos-ipipe-2.6.34.4-powerpc-2.10-05.patch  adeos-ipipe-2.6.35.7-powerpc-2.11-02.patch  README

As we know that tqm5200 is also supported in mainline, we'll go for the 2.6.35.7 version. Although we use the DENX repository, we'll be using an upstream tag, so essentially this will be a mainline linux kernel. But first we need to clone the git repo itself:

$ git clone git://git.denx.de/linux-2.6-denx linux-2.6-xenomai

Bulding the Linux kernel and Xenomai

Prepare Linux kernel

Now we switch to the wanted tag:

$ cd linux-2.6-xenomai
$ git checkout -b v2.6.35.7 v2.6.35.7

Now setup the environment variables neccessary to use the ELDK toolchain:

$ export ARCH=powerpc
$ export PATH=/opt/eldk-4.2/usr/bin:$PATH
$ export CROSS_COMPILE=ppc_6xx-

Now we can configure our kernel tree:

$ make 52xx/tqm5200_defconfig

Now let's patch the kernel with the Xenomai kernel parts:

$ cd ../xenomai-2.5
$ scripts/prepare-kernel.sh --linux=/home/dzu/xenomai-on-tqm5200/linux-2.6-xenomai/ --arch=powerpc

The perpare-kernel.sh script correctly guesses what patch we need, so we simply press Enter to accept the choice:

Adeos patch [default /work/dzu/xenomai-on-tqm5200/xenomai-2.5/ksrc/arch/powerpc/patches/adeos-ipipe-2.6.35.7-powerpc-2.11-02.patch]: 
patching file arch/powerpc/Kconfig
patching file arch/powerpc/boot/Makefile
patching file arch/powerpc/include/asm/exception-64s.h
patching file arch/powerpc/include/asm/ftrace.h
patching file arch/powerpc/include/asm/hw_irq.h
....

Compile Linux Kernel

Now we update our .config by accepting the Xenomai default options and compile the kernel and the FDT blob:

$ cd ../linux-2.6-xenomai
$ yes "" | make oldconfig
$ make -j4 uImage
$ make tqm5200.dtb
$ cp arch/powerpc/boot/images/uImage /tftpboot/dzu/tqm5200/uImage
$ cp arch/powerpc/boot/tqm5200.dtb /tftpboot/dzu/tqm5200/tqm5200.dtb

Compile Xenomai

Having a Xenomai-enabled kernel, we still need the userspace support, especially the libraries:

$ cd ../xenomai-2.5
$ ./configure --host=ppc-linux --prefix=/usr/local/xenomai-2.5.5.2
$ make

Install Xenomai

If you cannot write to the ELDK NFS root directory, you'll need to prepend sudo -E to the following command line. If your sudo is configured to reset PATH to conservative settings you can explicitely pass PATH by prepending sudo -E PATH=$PATH

$ make DESTDIR=/opt/eldk-4.2/ppc_6xx install

Running it

Having prepared the Xenomai enabled kernel and the Xenomai userspace inside the ELDK NFS, we can boot the new kernel and run a simple Xenomai application, namely the version of cyclictest which comes with Xenomai.

Please note that details of booting are beyond the scope of this application note and can be found in the general DULG documentation.

U-Boot 2010.09-00370-ga135ffd (Oct 19 2010 - 14:27:52)

CPU:   MPC5200B v2.2, Core v1.4 at 396 MHz
       Bus 132 MHz, IPB 132 MHz, PCI 66 MHz
Board: TQM5200S (TQ-Components GmbH)
       on a STK52xx carrier board
I2C:   85 kHz, ready
DRAM:  64 MiB
POST memory PASSED
FLASH: 32 MiB
In:    serial
Out:   serial
Err:   serial
Net:   FEC
POST i2c PASSED
POST cpu PASSED
IDE:   Bus 0: ..OK 
  Device 0: Model: HITACHI_DK23DA-20 Firm: 00J2A0A1 Ser#: 12Y0MN
            Type: Hard Disk
            Capacity: 19077.1 MB = 18.6 GB (39070080 x 512)
  Device 1: not available
SRAM:  512 kB
PS/2:  No device found
Kbd:   reset failed, no ACK

Type run flash_nfs to mount root filesystem over NFS

Hit any key to stop autoboot:  0 
=> setenv bootfile dzu/tqm5200/uImage
=> setenv fdt_file dzu/tqm5200/tqm5200.dtb
=> run net_nfs
Using FEC device
TFTP from server 192.168.1.1; our IP address is 192.168.160.4
Filename 'dzu/tqm5200/uImage'.
Load address: 0x400000
Loading: #################################################################
    #################################################################
    #
done
Bytes transferred = 1913339 (1d31fb hex)
Using FEC device
TFTP from server 192.168.1.1; our IP address is 192.168.160.4
Filename 'dzu/tqm5200/tqm5200.dtb'.
Load address: 0x700000
Loading: #
done
Bytes transferred = 4803 (12c3 hex)
## Booting kernel from Legacy Image at 00400000 ...
   Image Name:   Linux-2.6.35.7-dirty
   Created:      2011-02-14  16:16:55 UTC
   Image Type:   PowerPC Linux Kernel Image (gzip compressed)
   Data Size:    1913275 Bytes = 1.8 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 00700000
   Booting using the fdt blob at 0x700000
   Uncompressing Kernel Image ... OK
[    0.000000] Using mpc5200-simple-platform machine description
[    0.000000] Linux version 2.6.35.7-dirty (dzu@pollux.denx.de) (gcc version 4.2.2) #1 Mon Feb 14 17:16:46 CET 2011
[    0.000000] Zone PFN ranges:
[    0.000000]   DMA      0x00000000 -> 0x00004000
[    0.000000]   Normal   empty
[    0.000000] Movable zone start PFN for each node
[    0.000000] early_node_map[1] active PFN ranges
[    0.000000]     0: 0x00000000 -> 0x00004000
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
[    0.000000] Kernel command line: root=/dev/nfs rw nfsroot=192.168.1.1:/opt/eldk/ppc_6xx ip=192.168.160.4:192.168.1.1::255.255.0.0:tqm5200s:eth0:off panic=1 console=ttyPSC0,115200
[    0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Memory: 60740k/65536k available (3772k kernel code, 4796k reserved, 168k data, 250k bss, 164k init)
[    0.000000] Kernel virtual memory layout:
[    0.000000]   * 0xfffdf000..0xfffff000  : fixmap
[    0.000000]   * 0xfdffd000..0xfe000000  : early ioremap
[    0.000000]   * 0xc5000000..0xfdffd000  : vmalloc & ioremap
[    0.000000] SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] Hierarchical RCU implementation.
[    0.000000]    RCU-based detection of stalled CPUs is disabled.
[    0.000000]    Verbose stalled-CPUs detection is disabled.
[    0.000000] NR_IRQS:512 nr_irqs:512
[    0.000000] MPC52xx PIC is up and running!
[    0.000000] clocksource: timebase mult[79364d9] shift[22] registered
[    0.000000] I-pipe 2.11-02: pipeline enabled.
[    0.000000] console [ttyPSC0] enabled
[  130.311698] pid_max: default: 32768 minimum: 301
[  130.316668] Mount-cache hash table entries: 512
[  130.326779] NET: Registered protocol family 16
[  130.350398] DMA: MPC52xx BestComm driver
[  130.354872] DMA: MPC52xx BestComm engine @f0001200 ok !
[  130.361284] mpc52xx-gpt f0000600.timer: can function as watchdog
[  130.412674] bio: create slab <bio-0> at 0
[  130.421005] SCSI subsystem initialized
[  130.428413] usbcore: registered new interface driver usbfs
[  130.434849] usbcore: registered new interface driver hub
[  130.441316] usbcore: registered new device driver usb
[  130.449394] Switching to clocksource timebase
[  130.461470] NET: Registered protocol family 2
[  130.466456] IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
[  130.474342] TCP established hash table entries: 2048 (order: 2, 16384 bytes)
[  130.481839] TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
[  130.488531] TCP: Hash tables configured (established 2048 bind 2048)
[  130.495102] TCP reno registered
[  130.498416] UDP hash table entries: 256 (order: 0, 4096 bytes)
[  130.504519] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[  130.511435] NET: Registered protocol family 1
[  130.516546] RPC: Registered udp transport module.
[  130.521576] RPC: Registered tcp transport module.
[  130.526492] RPC: Registered tcp NFSv4.1 backchannel transport module.
[  130.536618] I-pipe: Domain Xenomai registered.
[  130.541330] Xenomai: hal/powerpc started.
[  130.545657] Xenomai: scheduling class idle registered.
[  130.551036] Xenomai: scheduling class rt registered.
[  130.580765] Xenomai: real-time nucleus v2.5.5.1 (Ghosts) loaded.
[  130.588169] Xenomai: starting native API services.
[  130.593093] Xenomai: starting POSIX services.
[  130.597870] Xenomai: starting RTDM services.
[  130.655565] JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[  130.664878] msgmni has been set to 118
[  130.671314] alg: No test for stdrng (krng)
[  130.675865] io scheduler noop registered
[  130.680030] io scheduler deadline registered
[  130.684803] io scheduler cfq registered (default)
[  131.435447] Serial: MPC52xx PSC UART driver
[  131.440237] f0002000.serial: ttyPSC0 at MMIO 0xf0002000 (irq = 129) is a MPC52xx PSC
[  131.450492] f0002200.serial: ttyPSC1 at MMIO 0xf0002200 (irq = 130) is a MPC52xx PSC
[  131.460513] f0002400.serial: ttyPSC2 at MMIO 0xf0002400 (irq = 131) is a MPC52xx PSC
[  131.497907] brd: module loaded
[  131.515523] loop: module loaded
[  131.520985] ata: MPC52xx IDE/ATA libata driver
[  131.527034] scsi0 : mpc52xx_ata
[  131.532109] ata1: PATA max PIO4 ata_regs 0xf0003a00 irq 135
[  131.545295] fc000000.flash: Found 2 x16 devices at 0x0 in 32-bit bank
[  131.552165] Amd/Fujitsu Extended Query Table at 0x0040
[  131.557551] number of CFI chips: 1
[  131.561757] RedBoot partition parsing not available
[  131.575236] mpc52xx MII bus: probed
[  131.598734] usbmon: debugfs is not available
[  131.603303] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[  131.610897] ppc-of-ohci f0001000.usb: OF OHCI
[  131.615627] ppc-of-ohci f0001000.usb: new USB bus registered, assigned bus number 1
[  131.623671] ppc-of-ohci f0001000.usb: irq 134, io mem 0xf0001000
[  131.688460] hub 1-0:1.0: USB hub found
[  131.692485] hub 1-0:1.0: 2 ports detected
[  131.698270] Initializing USB Mass Storage driver...
[  131.704795] ata1.00: ATA-5: HITACHI_DK23DA-20, 00J2A0A1, max UDMA/100
[  131.711547] ata1.00: 39070080 sectors, multi 0: LBA 
[  131.717086] usbcore: registered new interface driver usb-storage
[  131.723390] USB Mass Storage support registered.
[  131.729086] i2c /dev entries driver
[  131.735960] ata1.00: configured for PIO4
[  131.742622] scsi 0:0:0:0: Direct-Access     ATA      HITACHI_DK23DA-2 00J2 PQ: 0 ANSI: 5
[  131.758312] sd 0:0:0:0: [sda] 39070080 512-byte logical blocks: (20.0 GB/18.6 GiB)
[  131.766851] sd 0:0:0:0: Attached scsi generic sg0 type 0
[  131.775066] sd 0:0:0:0: [sda] Write Protect is off
[  131.780717] rtc-ds1307 0-0068: rtc core: registered ds1307 as rtc0
[  131.787197] rtc-ds1307 0-0068: 56 bytes nvram
[  131.792537] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[  131.804635] TCP cubic registered
[  131.808080] Initializing XFRM netlink socket
[  131.812587] NET: Registered protocol family 17
[  131.820818]  sda:
[  131.828039] rtc-ds1307 0-0068: setting system clock to 2011-02-14 16:44:03 UTC (1297701843)
[  132.531850]  sda1 sda2 sda3 sda4
[  132.542513] sd 0:0:0:0: [sda] Attached SCSI disk
[  133.346963] IP-Config: Complete:
[  133.350208]      device=eth0, addr=192.168.160.4, mask=255.255.0.0, gw=255.255.255.255,
[  133.358499]      host=tqm5200s, domain=, nis-domain=(none),
[  133.364286]      bootserver=192.168.1.1, rootserver=192.168.1.1, rootpath=
[  133.378880] Looking up port of RPC 100003/2 on 192.168.1.1
[  133.386996] Looking up port of RPC 100005/1 on 192.168.1.1
[  133.400322] VFS: Mounted root (nfs filesystem) on device 0:12.
[  133.406494] Freeing unused kernel memory: 164k init
[  134.418108] PHY: f0003000:00 - Link is Up - 100/Full
modprobe: FATAL: Could not load /lib/modules/2.6.35.7-dirty/modules.dep: No such file or directory

modprobe: FATAL: Could not load /lib/modules/2.6.35.7-dirty/modules.dep: No such file or directory

INIT: version 2.86 booting
      Welcome to DENX Embedded Linux Environment
      Press 'I' to enter interactive startup.
Setting clock : Mon Feb 14 17:44:10 MET 2011 [  OK  ]
Building the cache [  OK  ]
Setting hostname tqm5200s:  [  OK  ]
Mounting local filesystems:  [  OK  ]
Enabling /etc/fstab swaps:  [  OK  ]
INIT: Entering runlevel: 3
Entering non-interactive startup
FATAL: Could not load /lib/modules/2.6.35.7-dirty/modules.dep: No such file or directory
Bringing up loopback interface:  [  OK  ]
FATAL: Could not load /lib/modules/2.6.35.7-dirty/modules.dep: No such file or directory
Starting system logger: [  OK  ]
Starting kernel logger: [  OK  ]
Starting rpcbind: [  OK  ]
Mounting NFS filesystems:  [  OK  ]
Mounting other filesystems:  [  OK  ]
Starting xinetd: [  OK  ]

DENX ELDK version 4.2 build 2008-04-01
Linux 2.6.35.7-dirty on a ppc

tqm5200s login: root
Last login: Tue Dec  1 01:02:47 on console
-bash-3.2# /usr/local/xenomai-2.5.5.2/bin/cyclictest -t3
0.12 0.08 0.02 1/32 1175

T: 0 ( 1173) P:99 I: 1000000 C:      42 Min:      51 Act:      56 Avg:      55 Max:      65
T: 1 ( 1174) P:98 I: 1500000 C:      28 Min:      49 Act:      53 Avg:      77 Max:     117
T: 2 ( 1175) P:97 I: 2000000 C:      21 Min:     104 Act:     109 Avg:     115 Max:     142