[Home]EMC With Custom Kernel

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

Difference (from prior minor revision) (major diff)

Added: 32a33,34
Also you can find kernel source here: http://www.linuxcnc.org/dists/lucid/base/source/


Removed: 190d191


Contents

1. Overview
2. Getting Started
2.1. Download the kernel and rtai source code
2.2. Install required packages
3. Build the Kernel
3.1. Modify files for compiling the kernel
4. Install the New Kernel
5. Build and Install the RTAI package
5.1. Build the RTAI package
5.2. Install the RTAI package
6. Build and Install EMC packages
6.1. Build the EMC packages
6.2. Copy packages to the intended target
6.3. Install the Packages
7. Notes
7.1. Modify menu.lst
7.2. System Monitor

1. Overview

This tutorial will describe how to build a custom rtai enabled kernel, compile EMC2 to work with that kernel, and finally generate binary packages both for that kernel and EMC. The environment used is a standard install of Ubuntu 8.04 desktop. This tutorial is based on getting EMC to utilize Symetric Multi-Processing (SMP) on processors such as the Intel Atom 330.

If you are just looking for the smp pre-compiled packages, they can be found here:
http://linuxcnc.org/experimental/hardy/smp/

2. Getting Started

It is important to have a machine set up for the desired task. A high capacity drive such as the now relatively inexpensive ones in the 500MB to 1.5 TB capacity will come in handy. The environment used for this tutorial consistend of three bootable partitions as follows:

Partition 1: Partition for building the original kernel to be applied to EMC.
Partition 2: Partition for building the kernel, rtai and EMC.
Partition 3: Partition for binary installation of the built kernel and EMC.

While it is not the purpose of this turorial to show how to modify a kernel for a specific purpose, a kernel must be built with the desired attributes. One good example can be found here:
Debian Lenny Compile RTAI

Use partition #1 to build the custom kernel. Once the kernel is built, save the ".config" file created from building the kernel, it will be required later. To prevent package conflicts, using a fresh install of Ubuntu 8.04 on the second partition is highly recommended. Once Ubuntu is installed, ignore any prompts to install updates at least until after successfully completing the steps described here.

2.1. Download the kernel and rtai source code

Boot to the second partition to build the kernel and header packages, the rtai package, and EMC2 itself. Once running from the second partition, download the kernel, rtai and EMC2 source code into the home folder. Please note, the download locations change with each release. The version for this tutorial is 2.3 which can be downloaded as follows:
wget http://www.linuxcnc.org/hardy/dists/hardy/emc2.3/source/emc2_2.3.0.tar.gz
wget http://www.linuxcnc.org/hardy/dists/hardy/base/source/linux_2.6.24-16.30-linuxcnc.4.tar.gz
wget http://www.linuxcnc.org/hardy/dists/hardy/base/source/rtai_3.6.1-linuxcnc.4.tar.gz
Now extract all three files. The easiest way is from "Places | Home Folder", right click on the files and select "Extract Here". This will create three folders, "emc2-<current version>" i.e. "emc2-2.3.0", "ubuntu-hardy", and "rtai".

Also you can find kernel source here: http://www.linuxcnc.org/dists/lucid/base/source/

2.2. Install required packages

Open a terminal session, or use synaptic to install the following packages. Command line install is shown below.

sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install fakeroot debhelper libpth-dev libgtk2.0-dev kernel-wedge
sudo apt-get install tcl8.4-dev tk8.4-dev bwidget python2.5-dev python-tk python-dev
sudo apt-get install mesa-common-dev libglu1-mesa-dev libgtk2.0-dev libgnomeprintui2.2-dev
sudo apt-get install libncurses5-dev libxaw7-dev gettext libreadline5-dev
sudo apt-get install lyx texlive-extra-utils imagemagick tetex-bin tetex-extra groff

sudo apt-get build-dep linux-image-2.6.24-23-generic

3. Build the Kernel

3.1. Modify files for compiling the kernel

Navigate to the folder ~/ubuntu-hardy/debian/binary-custom.d/
Make a copy of the rtai folder, and rename it to something meaningful such as 'rtaismp'. For the remainder of this tutorial the custom name used will be rtaismp. Substitute whatever name is chosen for your custom kernel where ever rtaismp is used.
Navigate to the just created folder (rtaismp).
Here is where the ".config" file mentioned at the beginning comes in. Copy the ".config" file into this folder. Rename the existing "config.i386" to something else, such as "config-old.i386". Then rename ".config" to config.i386.
Note: If using the file browser, ".config" will be a hidden file. Be sure to turn on "View | Show Hidden Files".

Navigate back to the debian folder, then to rules.d.
Edit the file i386.mk, adding the name of the new rtai folder as follows:
custom_flavours = rt xen openvz rtai 
To
custom_flavours = rt xen openvz rtai rtaismp

Then edit 0-common-vars.mk, again adding the name of the copied rtai folder (rtaismp).
all_custom_flavours = lpia rt lpiacompat xen openvz rtai 
To
all_custom_flavours = lpia rt lpiacompat xen openvz rtai rtaismp

While this should not be necessary, it is suggested to delete the files debian/control.stub and debian/control relative to the top directory (ubuntu-hardy), before doing the next step. Then in the terminal session, and again from the top directory run:
debian/rules debian/control.stub
debian/rules debian/control

Edit build.sh from the base ubuntu-hardy folder, and change the part of the first line as follows.
custom-binary-rtai
         To
custom-binary-rtaismp

Now build the kernel as follows:
./build.sh

Accept all of the defaults and sit back and wait. This can take a while, especially on slower processors.

4. Install the New Kernel

Assuming the processor is compatible with the kernel just built, the packages can be installed to the local machine. Otherwise they need to be copied to the target machine. The package files will be found in the root folder. The instructions below assume installing to the local machine.

Install the kernel and kernel headers as follows:
cd ~/
sudo dpkg -i linux-image-2.6.24-16-rtaismp_2.6.24-16.30.linuxcnc.4_i386.deb
sudo dpkg -i linux-headers-2.6.24-16-rtaismp_2.6.24-16.30.linuxcnc.4_i386.deb

Reboot and select the rtaismp kernel from the grub boot loader if it is not already the default kernel.

5. Build and Install the RTAI package

5.1. Build the RTAI package

From the rtai folder, open the file debian/rules and change the first line as follows:
KERNEL_VER=2.6.24-16-rtai
         To
KERNEL_VER=2.6.24-16-rtaismp

Next, in the same folder, edit the file "control" and change as follows:

Build-Depends: linux-headers-2.6.24-16-rtai
Package: rtai-modules-2.6.24-16-rtai
Depends: linux-image-2.6.24-16-rtai
         To
Build-Depends: linux-headers-2.6.24-16-rtaismp
Package: rtai-modules-2.6.24-16-rtaismp
Depends: linux-image-2.6.24-16-rtaismp

Build RTAI as follows from the base rtai folder:
./build

5.2. Install the RTAI package

Install the rtai package as follows:
cd ~/
sudo dpkg -i rtai-modules-2.6.24-16-rtaismp_3.6.1-linuxcnc.4_i386.deb

And finally do a reboot.

6. Build and Install EMC packages

6.1. Build the EMC packages

From a terminal session goto the root emc folder and enter the following commands:
cd ~/emc2-2.3.0
debian/configure -r
debuild

The last command will take a while.

6.2. Copy packages to the intended target

While the EMC packages can be installed to the current partition, this tutorial will do a binary only install to the third partition. After performing a standard install of Ubuntu 8.04 desktop, copy the following packages to the instance on the third partition.
linux-image-2.6.24-16-rtaismp_2.6.24-16.30.linuxcnc.4_i386.deb
linux-headers-2.6.24-16-rtaismp_2.6.24-16.30.linuxcnc.4_i386.deb
rtai-modules-2.6.24-16-rtaismp_3.6.1-linuxcnc.4_i386.deb
emc2_2.3.0_i386.deb

Optionally copy the packages starting emc2-firmware... as needed if any of the Mesa Hostmot2 drivers are required by the intended configuration.

6.3. Install the Packages

Install the packages in the following order on the target partition.
sudo dpkg -i linux-image-2.6.24-16-rtaismp_2.6.24-16.30.linuxcnc.4_i386.deb
sudo dpkg -i rtai-modules-2.6.24-16-rtaismp_3.6.1-linuxcnc.4_i386.deb

Reboot to the installed (rtaismp) kernel. Then install the EMC packages.
sudo dpkg -i emc2_2.3.0_i386.deb

Install any firmware packages required by the intended configurations and do one final reboot. Once it has rebooted you should be able to run EMC, particularly any of the configurations under "sim".

7. Notes

7.1. Modify menu.lst

If the intent is to install an smp kernel as per these instructions, edit /boot/grub/menu.lst and add "isolcpus=1" to the end of the kernel line of the rtaismp kernel. This will dedicate the second CPU to the real time tasks, resulting in a significant increase in performance.

7.2. System Monitor

The system monitor (System | Administration | System Monitor) can be used to show that 2 CPUs are recognized, however if menu.lst is modified as above, CPU 2 will always show a load of 0%. This is not an indication of a problem other than system monitor does not report properly on a CPU dedicated to real time tasks.


LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions
Last edited February 22, 2014 4:45 am by Belerafon (diff)
Search:
Published under a Creative Commons License