Installing Xenomai

Installing Xenomai

Hardware Notes

Tested on an MSI 945GM3-F LGA 775 Intel 945G Micro ATX Intel Motherboard with an Intel Core 2 Duo E6600 Conroe 2.4GHz LGA 775 65W Dual-Core Processor.

This External PC Hardware also works, but it requires a separate  Atheros driver.

Newer motherboards often have chipsets (especially Ethernet) that are not supported by the drivers included in Ubuntu 7.10. This complicates the installation because instead of simply installing Ubuntu from CD then rebooting and running the Xenomai installer scripts, it requires the following procedure (assuming the Ethernet chipset is unsupported):

Install Ubuntu from CD
Download the correct Ethernet driver source code for your hardware on a separate PC
 (often, the code is either buggy or not available)
Transfer the code to the WAM PC via USB (assuming the USB driver is functioning)
Compile it on the WAM PC
Insmod the kernel module (the driver) in order to gain network access
Continue with the Xenomai installation scripts
When rebooting into a Xenomai-patched kernel, you will need to
 recompile and re-insmod the Ethernet driver to gain network access again
Place the module.ko in the /lib/modules/`uname -r`/kernel/drivers/net directory
Run depmod to update the module list

Processor selection is important for Xenomai. Ideally, the processor(s) should have an APIC to use as a timer source and a TSC for a clock source (look at the CPU flags in "cat /proc/cpuinfo"). These processors have APICs: AMD K7, Intel Pentium 2/3/4/M, Intel Core 2, and Via C7.

Peripherals controlled by Xenomai must not share IRQs with non-realtime components. The CANbus card must have its own, unique, non-shared IRQ. Type "cat /proc/interrupts" to view your hardware interrupts (IRQs) managed by Linux. Type "cat /proc/pcan" to view the CANbus interrupt managed by Adeos/Xenomai. On the MSI board, the CAN card must be installed in slot 3 (nearest the PCIe slot) to obtain a working IRQ. The Linux ACPI code assigns IRQs as the kernel boots, BIOS IRQ settings are ignored. If you know how force ACPI to say "PCI slot 3 = IRQ 5", please let us know, because we are just relying on luck right now. Kernel boot options such as pci=noacpi, acpi_irq_pci=5,10,11, and pnpacpi=off cause Xenomai's xnintr_irq_handler to fail when using the CANbus card, and do not seem to affect the assigned IRQ of the card.

Software Notes

Ubuntu 7.10 uses kernel 2.6.22. Xenomai 2.4.2 supports kernels 20, 23, and 24. Kernel 23 introduced a new CFS process scheduler. Kernel 24 makes improvements to CFS and adds a very interesting memory anti-fragmentation feature. See more details here:  http://kernelnewbies.org/Linux26Changes

Ubuntu 7.10 bugs:

Shutdown does not cleanly unmount ext3 drive, forces inode repair on boot
https://bugs.launchpad.net/ubuntu/+source/prebaseconfig/+bug/9945

Boot order incorrect for ntp, ntpd, dhcdbd. Interface eth0 resets multiple times during boot.
https://bugs.launchpad.net/ntp/+bug/114505
http://ubuntuforums.org/showthread.php?t=647559

AppArmor interferes with cupsys, printing broken

Hardware and BIOS Setup

Install CPU, HD, RAM, CPU fan

Install Peak PCI ISO CAN card (IPEH-002067):  http://tinyurl.com/9ol76t

Connect keyboard, mouse, monitor, Ethernet (IMPORTANT: make sure the machine is connected to your network)

Power on

Edit BIOS:

  • Set time/date
  • Disable "Legacy USB"
  • Boot priority = CD, HD

Install Ubuntu 7.10

Download and burn the "ubuntu-7.10-desktop-i386.iso" CD ISO image from here:  http://old-releases.ubuntu.com/releases/7.10/ubuntu-7.10-desktop-i386.iso

UPDATE: Since these instructions were posted, newer versions of Ubuntu have been released. These instructions DO NOT WORK with newer versions. Until the latest Ubuntu is supported, you should use version 7.10.

Boot from Ubuntu 7.10 CD

Run "Check CD for defects" from the boot menu (takes about 5 minutes), then reboot

Run Memtest86 from boot menu

Wait for first 3 tests to complete successfully (takes about 5 minutes), then reboot

Choose "Start or install" from boot menu

Start the installation by double-clicking the "Install" icon on the desktop

  • Select a language
  • Set time zone
  • Select keyboard type
  • Partition HD (any option is fine)
  • Enter primary user info, Name=Robot Operator, User=robot, Pass=WAM

Reboot after installation, remove CD

Log in (User=robot, Pass=WAM)

Automated Setup

Open this page in a web browser on the new PC (Applications->Internet->Firefox Web Browser)

Download the following two installation scripts to your desktop:

  •  http://web.barrett.com/support/WAM_Installer/xeno-stage1.sh
  •  http://web.barrett.com/support/WAM_Installer/xeno-stage2.sh

Open a terminal window (Applications->Accessories->Terminal) and type the following commands:

cd Desktop
sudo sh xeno-stage1.sh

It will ask you for the password you entered during the Ubuntu CD installation.

This script should take about 45 minutes to execute, depending on the speed of your PC and your network connection.

Reboot, then open a terminal window and type the following commands:

cd Desktop
sudo sh xeno-stage2.sh

This script should take about 5 minutes to execute, depending on the speed of your PC.

Reboot once again (required), then you are ready to run the WAM!

Manual Setup

If the automated setup scripts do not work, you will need to install the system manually by following these instructions carefully.

Bring up this page in a web browser on the new machine (Applications->Internet->Firefox Web Browser):  http://trac.barrett.com/support/wiki/InstallXenomai

Disable "Multicast DNS service discovery" under System->Administration->Services

Open a terminal (Applications->Accessories->Terminal)

The WAM code sends many status/debugging messages to /var/log/syslog through syslogd. However, the automatic log rotation scripts common to many Linux distributions tend to interfere with the real-time operation of the WAM. If you are operating the WAM when crond begins a scheduled log rotation, it may result in a heartbeat error from the PC, which will cause the safety system shut down the WAM. To eliminate this problem, you can disable the log rotation cron task for syslogd with the following commands:

sudo chmod 644 /etc/cron.daily/sysklogd
sudo chmod 644 /etc/cron.weekly/sysklogd

Install the Kernel with Xenomai Patches

Download, unpack, and patch the kernel

wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.24.2.tar.bz2
wget http://download.gna.org/xenomai/stable/xenomai-2.4.2.tar.bz2
tar xvjf linux-2.6.24.2.tar.bz2 (use tab-completion for long file names)
tar xvjf xenomai-2.4.2.tar.bz2
ln -sf linux-2.6.24.2 linux
ln -sf xenomai-2.4.2 xenomai
sudo apt-get update
sudo apt-get install patch libncurses5-dev libc6-dev (may ask for CD)
sudo xenomai/scripts/prepare-kernel.sh --linux=~/linux (accept defaults)

The kernel configuration instructions below use a .config file that assumes a PIII-compatible architecture (with an APIC). If your processor does not have an APIC (if "grep -i apic /proc/cpuinfo" does not show anything), you must use "sudo make menuconfig" below instead of "sudo make oldconfig", then select a processor type that either matches or is a valid subset of your actual processor, plus disable HPET timer support. Xenomai will use the slower PIT for a timer source and emulate a clock off that. Please note that the standard "586/K5/5x86/6x86/6x86MX" processor type DOES NOT support an APIC.

Make and install the kernel:

cd linux
wget -N http://web.barrett.com/support/WAM_Installer/xenomai.config
mv xenomai.config .config
sudo make oldconfig
sudo make
sudo make modules_install
sudo cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.24.2-ipipe
sudo cp -aR /lib/firmware/2.6.22-14-generic /lib/firmware/2.6.24.2-ipipe
sudo update-initramfs -c -k 2.6.24.2-ipipe

Add this new kernel to your bootloader configuration file. Copy the grub entry below (from "title" to "quiet"). Insert this new kernel info above the "BEGIN AUTOMAGIC KERNELS LIST" line, else the system updater will overwrite it. The UUID is unique to your hard drive, yours will be different. Be sure to copy your UUID from one of the default kernel entries near the bottom of the file. Also make sure the "root" line matches one of the default kernel entries near the bottom of the file. Save and close the file when you are done:

sudo gedit /boot/grub/menu.lst (add this kernel)

...
#
# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST

title		Ubuntu 7.10, kernel 2.6.24.2-ipipe
root		(hd0,0)
kernel		/boot/vmlinuz-2.6.24.2-ipipe root=UUID=425fea46-7682-4d02-ae36-577dc1afd2e4 ro quiet splash xeno_nucleus.xenomai_gid=1001
initrd		/boot/initrd.img-2.6.24.2-ipipe
quiet

### BEGIN AUTOMAGIC KERNELS LIST
...

Reboot, log in, open a terminal

Check for APIC, TSC, Xenomai, SMI boot errors. If you find any negative terms like "failed", "missing", or "unsupported", you will need to fix them before continuing.

dmesg |grep -i apic
dmesg |grep -i tsc
dmesg |grep -i xen
dmesg |grep -i smi

Install and Test Xenomai

cd xenomai
./configure
make
sudo make install
cd /usr/xenomai/bin
./xeno-test (observe latencies, typical: avg=5, max=25 microseconds)

Allow non-root hard realtime control. We assume that the new "xenomai" group gets assigned to group id (gid) 1001. If your addgroup command generates a different gid for the xenomai group, you will need to edit the xeno_nucleus.xenomai_gid kernel option in /boot/grub/menu.lst to match the new group id.

sudo addgroup xenomai
sudo usermod -a -G xenomai robot

Install CAN driver

cd
sudo apt-get install g++ (may ask for CD)
wget http://web.barrett.com/support/WAM_Installer/peak-linux-driver.6.5.tar.gz
tar zxvf peak-linux-driver.6.5.tar.gz
cd peak-linux-driver-6.5
make RT=XENOMAI KERNEL_LOCATION=~/linux
sudo make install KERNEL_LOCATION=~/linux

Install and Configure the WAM Control Library

cd
sudo apt-get install subversion doxygen doxygen-doc graphviz graphviz-doc
svn co http://web.barrett.com/svn/btclient/tags/LATEST
mv LATEST btclient
cd btclient
wget http://web.barrett.com/support/WAM_Installer/config.mk

Edit btclient/config.mk to match your hardware (use gedit)

Build the WAM code

sh makeall

Make a link to your WAM configuration file

ln -sf config/WAM7.conf wam.conf

Build the code documentation (view btclient/doc/index.html in a web browser after running doxygen)

cd src
doxygen config.dox

Install OpenSSH Server (Optional)

Install OpenSSH (if you want to log in to the WAM PC over a network)

sudo apt-get install openssh-server

Install and Configure Minicom (Optional)

Install minicom (if you want to use the RS-232 serial port)

sudo apt-get install minicom
sudo ln -s /dev/ttyS0 /dev/modem
sudo ln -s /dev/ttyS0 /lib/udev/devices/modem
sudo minicom -s
  • Serial Device: /dev/modem
  • 9600 8N1
  • No hardware flow control
  • No software flow control
  • Init string: ^M
  • Reset string: ^M
  • Save as dfl

Setting a Static IP Address (Optional)

If you want to assign a static IP address, you will need to append your interfaces file (sudo gedit /etc/network/interfaces):

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.25
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1

Now you need to restart your network services using the following command:

sudo /etc/init.d/networking restart

You need to set up DNS servers manually in resolv.conf file when you are not using DHCP (sudo gedit /etc/resolv.conf):

search domain.com
nameserver xxx.xxx.xxx.xxx

Final Steps

Reboot, log in, open a terminal

Check for CAN driver errors

dmesg |grep -i pcan

你可能感兴趣的:(Installing Xenomai)