Partition 1: Partition for building the original kernal to be applied to EMC. |
Partition 1: Partition for building the original kernel to be applied to EMC. |
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 is highly recommended. Once Ubuntu is installed, ignore any prompts to install updates at least until after successfully completing the steps described here.|
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.|
Also you can find kernel source here: http://www.linuxcnc.org/dists/lucid/base/source/|
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:
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.
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
Also you can find kernel source here: http://www.linuxcnc.org/dists/lucid/base/source/
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
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
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
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:
Accept all of the defaults and sit back and wait. This can take a while, especially on slower processors.
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.
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:
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.
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.
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.
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".