lpglogo1.jpg Glaister Consulting Services canadianflag.jpg

Note to readers:

EMC2 has been renamed to linuxcnc due to some trademark bully issues.
This file is presented for historical purposes. It is now much easier to install and configure linuxcnc. It is truly amazing how this project as progressed over the last 20 years. Enjoy this page as a flashback in linux and realtime machine control history.

How to Get and Build RTLinux kernel and EMC

# This section was written 12-Jan-2001 during the installation on
# a new computer and harddrive. At this point, you should have a standard
# Redhat Linux 6.2 Workstaion installed. You should have a user called cnc.
# It is possible to survive with a 1gb disk, but more is better. To give
# a little breathing room, I removed the emacs editor software using the xrpm
# utility.
# first, lets burn up some web time and get all the software pieces we need

# login as root user as we need to scatter code across the hard drive
[cnc@cnc1 cnc]$ su -
Password: 
[root@cnc1 nist]# cd /usr/src

# get a virgin  version 2.2.14 linux kernel from
# ftp.kernel.org/pub/linux/kernel/v2.2/linux-2.2.14.tar.gz (15.9mb)
[root@cnc1 src]# ncftp  ftp.kernel.org
ncftp / > get pub/linux/kernel/v2.2/linux-2.2.14.tar.gz
ncftp / > bye

# now get the matching version of rtlinux (547kb) (real time patch for linux)
[root@cnc1 src]# ncftp ftp.rtlinux.com
ncftp / > cd pub/rtlinux/v2
ncftp /pub/rtlinux/v2 > get rtlinux-2.2a.tar.gz
ncftp / > bye

# now we need the cvs release of rcs and emc (2 components for gcode system)
# create directories for emc/rcslib project
[root@cnc1 src]# cd /usr/local
[root@cnc1 local]# mkdir nist
[root@cnc1 local]# cd nist

# grab a copy of all the cvs code - just hit 'enter' when asked for password
# this is about 17mb of code
[root@cnc nist]# cvs -d:pserver:anonymous@cvs.EMC.sourceforge.net:/cvsroot/EMC login
(Logging in to anonymous@cvs.EMC.sourceforge.net)
CVS password:
[root@cnc nist]# cvs -z3 -d:pserver:anonymous@cvs.EMC.sourceforge.net:/cvsroot/EMC co -P emc rcslib

# ok, now we need to build all that great software we downloaded
# The first thing we need is to get the kernel and rtlinux patch unpacked
[root@cnc nist]# cd /usr/src
[root@cnc1 src]# tar -xzvf rtlinux-2.2a.tar.gz
[root@cnc1 src]# cd rtlinux-2.2
[root@cnc1 rtlinux-2.2]# tar -xzvf ../linux-2.2.14.tar.gz
[root@cnc1 rtlinux-2.2]# cd linux
[root@cnc1 linux]# patch -p1 < ../kernel_patch
# you should see no errors in the above patching process
# now we are going to configure a kernel
[root@cnc1 linux]# make mrproper
[root@cnc1 linux]# make xconfig
# click on the Code maturity level options button
# click on Y for prompt for development and/or incomplete code/drivers
# click on next
# pick processor family to match your cpu(s)
# click on next
# make sure Y for enable loadable module support
# click next
# click Y for parallel port support and PC style hardware, N to Advanced power management
# click main menu
# click on scsi support
# Y to scsi support, Y scsi disk support Y scsi cd-rom support, Y to SCSI generic support
# click next for SCSI low-level drivers. Say Y to th edriver for your module
# in my case Y to NCR53C8xx and N to SYM53c8xx
# click on main menu and then Ethernet 10/100
# you need to find the driver for your network card and click Y.
# in my case this was DECchip Tulip (dc21x4x) PCI support for SMC EtherPower card
# click on main menu then Filesystems
# Y to dos fat, Y to msdos, Y to vfat, Y to MS Joliet extensions
# click on main menu then nework file systems
# I said y to nfs and smb support because I an on a network with other linux and windows boxes.
# click on main menu and "store configuration file"
# enter filename of 2.2.14.conf so it can be reloaded if we forgot to add something
#then click on save and exit
[root@cnc1 linux]# make dep
[root@cnc1 linux]# cd /usr/include
[root@cnc1 include]# rm -rf asm linux scsi
[root@cnc1 include]# ln -s /usr/src/rtlinux-2.2/linux/include/asm-i386/ asm
[root@cnc1 include]# ln -s /usr/src/rtlinux-2.2/linux/include/scsi scsi
[root@cnc1 include]# ln -s /usr/src/rtlinux-2.2/linux/include/linux linux
[root@cnc1 include]# cd /usr/src/rtlinux-2.2/linux/
[root@cnc1 linux]# make bzImage
# this will take a while to build the real time kernel image (20 minutes on p200)
[root@cnc1 linux]# make modules
[root@cnc1 linux]# make modules_install
# now we move the kernel and symbol table around so we can boot it
[root@cnc1 linux]# cp arch/i386/boot/bzImage /boot/vmlinuz-2.2.14-rtl2.2
[root@cnc1 linux]# cp System.map /boot/System.mapRTL22
[root@cnc1 linux]# rm /boot/System.map
[root@cnc1 linux]# ln -s /boot/System.mapRTL22 /boot/System.map
# we need to edit the boot file so we have an option of which kernel to run
[root@cnc1 linux]# vi /etc/lilo.conf

boot=/dev/sda
map=/boot/System.map
install=/boot/boot.b
prompt
timeout=50
linear
default=linuxRTL22

image=/boot/vmlinuz-2.2.14-rtl2.2
        label=linuxRTL22
        root=/dev/sda5
        read-only

image=/boot/vmlinuz-2.2.14-5.0smp
        label=linux-smp
        initrd=/boot/initrd-2.2.14-5.0smp.img
        read-only
        root=/dev/sda5

image=/boot/vmlinuz-2.2.14-5.0
        label=linux
        initrd=/boot/initrd-2.2.14-5.0.img
        read-only
        root=/dev/sda5

# now run lilo so the additional boot choice is available
[root@cnc1 linux]# /sbin/lilo

# as a backup, we can make a bootable floppy with the rt kernel
# in my case, I had no bios for my scsi controller, so I have to
# boot from floppy and bring up the linux drivers for the card and
# then run from disk. No extra work, it just boots slower and I need
# to remember to leave the boot floppy in the drive.
[root@cnc1 linux]# mkbootdisk 2.2.14-rtl2.2
# dont worry if it complains about a missing ncr53c8xx module, we built it
# into the kernel.

#since our copy of linux is not in the usual directory /usr/src/linux but
# is actually as a sub directory of the rtlinux stuff, we need to set up
# some links for other system builds.
[root@cnc1 linux]# rm /usr/src/linux
[root@cnc1 linux]# ln -s /usr/src/rtlinux-2.2/linux /usr/src/linux
[root@cnc1 linux]# ln -s /usr/src/rtlinux-2.2/linux/include /usr/src/linux/include

# now we can build the rtl modules
[root@cnc1 linux]# cd /usr/src/rtlinux-2.2/
[root@cnc1 rtlinux-2.2]# make
[root@cnc1 rtlinux-2.2]# make install

# make sure we have a path to /sbin
[root@cnc1 rtlinux-2.2]# export PATH=/sbin:/$PATH

#try some of the rtl examples
[root@cnc1 rtlinux-2.2]# cd examples/
[root@cnc1 examples]# cd fp
[root@cnc1 fp]# make
[root@cnc1 fp]# mv rt_process.o fp_tasks.o
[root@cnc1 fp]# cd ../../

# make the 2 scripts for installing and removing rtl executable
[root@cnc1 rtlinux-2.2]# chmod a+x insrtl
[root@cnc1 rtlinux-2.2]# chmod a+x rmrtl

#install rtl modules
[root@cnc1 rtlinux-2.2]# ./insrtl

#check and see what is loaded
[root@cnc1 rtlinux-2.2]# lsmod
Module                  Size  Used by
rtl_fifo                7376   0  (unused)
rtl_posixio             6820   0  [rtl_fifo]
rtl_sched              36668   0  (unused)
rtl_time               14120   0  [rtl_posixio rtl_sched]

[root@cnc1 rtlinux-2.2]# cd examples/fp
[root@cnc1 fp]# make test
# at this point, the test should be running using up lots of cpu time
# I believe it will only print something if there is an error in the floating
# point math units (normally kernel modules are not supposed to use fp but rtlinux
# set it up as it is needed by the emc real time modules.)
# after a couple of minutes, use ^C to stop it
*** [test] Interrupt

[root@cnc1 fp]# rmmod fp_tasks
[root@cnc1 frank]# make
[root@cnc1 frank]# make test
.....output snipped...
FIFO 2: Zappa
FIFO 2: Zappa
FIFO 1: Frank
FIFO 2: Zappa
FIFO 2: Zappa
frank_app: now sending commands to stop RT-tasks

[root@cnc1 frank]# cd ../hello
[root@cnc1 hello]# make
[root@cnc1 hello]# make test
# this one doesnt seem to do anything, but it doesnt crash anything

[root@cnc1 hello]# cd ../measurements/
[root@cnc1 measurements]# make
[root@cnc1 measurements]# make test
... output snipped....
min:     4800, max:    28896
min:     4800, max:    22272
min:     4800, max:    37952
min:     4768, max:    29920
min:     4800, max:    24896
min:     4800, max:    21472
min:     4800, max:    21024
min:     4800, max:    17920
# use ^C to stop.
# the above values show some type of scheduling variation
# my box is a dual 200 PPro
# on a P133 box I got numbers in the range of 16190 and 54528,
# I assume that the closer the numbers, the better the performance
# the max number is about as small as one can go when we set up the PERIOD
# parameter in emc stepper system later in this document.


# the next step is setting up emc/rcs lib

# The Saga of Getting the EMC/RCSLIB CVS Code to Build and Run.
#
# At this point you should have installed Redhat 6.2 and
# patched a 2.2.14 virgin kernel with rtlinux_2_2a.
#
# These builds are from a CVS version taken on Jan 11 2001.
#
# some stats on system (PP200 dual/64mb and 1.2gb of scsi 2 drive)
# if you open this file in an editor, you can cut and paste the commands
# into a terminal window as required... or turn this into a script

[root@cnc1 src]# uname -a
Linux cnc1 2.2.14-rtl2.2 #1 SMP Fri Jan 12 15:28:23 PST 2001 i686 unknown

[root@cnc1 nist]# cd /usr/local/nist

# move correct install file into top directory
[root@cnc1 nist]# cp /usr/local/nist/emc/scripts/generic/installfromsource ./
[root@cnc1 nist]# ./installfromsource

# the emc build fails because of missing directories in the cvs... create them and try again
[root@cnc1 nist]# mkdir /usr/local/nist/emc/plat/linux_2_2_14/include/rs274ngc_new/
[root@cnc1 nist]# mkdir /usr/local/nist/emc/plat/linux_2_2_14/src/rs274ngc_new/
[root@cnc1 nist]# ./installfromsource

# have a cup of coffee, a build takes 10-20 minutes
# now lets see if everything runs by running in simulation mode.
[root@cnc1 nist]# cd emc
[root@cnc1 emc]# ./rs274ngc_new_sim.run

# click on ESTOP/Estop Off, Estop Reset/ Machine on, Manual/Auto
# click on Open.../cds.ngc/Open
# click on View/Backplot
# finally... click on run and watch the gcode roll....

# I must comment on how easy the build was. The cvs version is maturing
# very well and went far quicker than previous attempts.

# now you need to read the emc documentation and set up a real runtime
# environment.

Lawrence Glaister VE7IT
lg@jfm.bc.ca  (Note: email changed to ve7it@shaw.ca)

home.jpg Back to Lawrence's Page