# HOWTO BUILD A COOLCNC DEVELOPMENT ENVIRONMENT
#
# coolcnc is a puppybased linuxdistribution that can reproduce itself,
# runs on most x86 hardware and has realtimecapabilities utilizing rtai.
# so what can you do with it ?
# you can run your own realtime tasks on it. or you you could use it to run
# emc2 the enhanced machine controller and its beatuiful gui axis.
#
# prerequisites: this howto assumes that you have a linuxsystem up and running.
# the tools required besides are: bzip2, wget and qemu (0.8.X). for better
# performance i recomend the usage of the qemu acceleration module.
# you may also think about using a squashfs & unionfs equipped kernel
# for reducing the compiletime. a minihowto on this issue is includet
# at the bottom of this document. with some minor changes it should
# be no problem to adopt this howto for native install (no chroot, no qemu).
# as a matter of fact all you need to do is skip some lines of this howto :)
# as for hardware requirements, a fast processor enough ram reduces the
# time needed for compiling. +2500MB of free harddiskspace is required.
#
# you also need to switch to the root user or else some steps will not work
# and you have to manually do them via sudo !!!
#
# why do it: with a system setup the way explained below you are able to easily
# create custom emc2 equipped puppy linux distributions. you also are able
# to create your own special and or general purpose puppys.
#
# WARNING !!! THE PROCEDURES BELOW SHOULD BE UNDERSTOOD
# BEFORE BEEING UTILIZED.
# THIS HOWTO IS _NOT CREATED TO BE COPY AND PASTE PROOF_.
# THERE IS NO ERROR CHECKING OR OTHER SECURITYFEATURE INCLUDET
# STOPING YOU FROM _WHIPING OUT YOUR HARDDISK_ OR WORSE !!!
# THE AUTHOR IS NOT IN ANY WAY RELIABLE FOR ANY DAMAGE DONE
# BY FOLLOWING OR NOT FOLLOWING THE RECOMENDATIONS THIS
# HOWTO OFFERS.
# Big Thanks go to Raeed: for getting me onto this.
# The EMC developers: this is some serious nice software you got :)
# The axis team: eyecandy that works :) im loving it(tm) :)
# The people @ #emc: for support whenever needed and not kicking me
# out of the channel :)
# All those Linuxhackers for making the World a better place to live.
# Special thanks go to Alex Joni and The Cooltool for hosting
# and other favors.
# not to forget Big Mama Thornton, George Benson, Robertos Funkmix
# and all the other nice music that helped me to keep sane :)
# at first lets get the actual puppy livecd:
wget -c http://ftp.nluug.nl/ftp/pub/os/Linux/distr/puppylinux/puppy-1.0.7-mozilla.iso
# create a harddiskimage for storing the puppy hd install
qemu-img create coolcnc.0.2.img 2500M
# kqemu speeds up qemu alot
modprobe kqemu
# boot into puppy using qemu:
qemu -hda coolcnc.0.2.img -cdrom puppy-1.0.7-mozilla.iso -boot d -m 128
# INSIDE QEMU
# you are asked some simple questions like keyboardlayout and mousetype.
# answer them correctly and choose xfvb as X server. choose a screensize
# to work with and configure the network.
#
# on the bootprompt choose "4" and press [enter]
# select your desired keyboardlayout <OK> [enter]
# choose "ps/2" as mousetype to make it work with qemu
# we go with Xvesa server (the xorg server doesnt seem to
# work well with qemu)
#
# select your desired videomode and press <OK>
# go to Start->Setup->Ethernet/network Wizard and configure your networkinterfacecard
# with qemu thats eth0 and AUTO/DHCP
# setup puppy on your harddiskimage:
# open a terminal and execute cfdisk
# create a primary partition spanning the whole disk
# set the bootable flag -> write -> exit
#
# go to Start->Setup->Install Puppy hard drive
# choose "2" [enter]
# a new install [enter]
# "/dev/hda1" [enter]
# yes you are shure "y" [enter]
# cdrom is inserted [enter]
#
# now you have to type anything but space :) type "n" [enter]
# another trap : press "y" [enter] or else grub would not be configured
# choose "simple" [OK] -> [OK] -> "/dev/hda1" is [OK]
# we want to install into the MBR [OK]
#
# THATS IT :) you may shutdown qemu now
#--------------------------------------------------------------------------------------------#
# you can access the created filesystem from your Linuxsystem via loopbackmount:
lomount -diskimage coolcnc.0.2.img -partition 1 /coolcncmount
# lets get the puppy developementtools/header filesystemimage
cd /coolcncmount
wget --passive-ftp http://ftp.nluug.nl/ftp/pub/os/Linux/distr/puppylinux/usr_devx.sfs
mkdir /coolcncmount/.usr_devx
# if your kernel supports unionfs and squashfs you can easily build a chrooted environment.
losetup /dev/loop3 /coolcncmount/usr_devx.sfs
mount -r -t squashfs -o noatime /dev/loop3 /coolcncmount/.usr_devx
mount -t unionfs -o dirs=/coolcncmount/usr=rw:/coolcncmount/.usr_devx=ro none /coolcncmount/usr
mount -o bind /dev /coolcncmount/dev
mount -o bind /proc /coolcncmount/proc
cp /etc/resolv.conf /coolcncmount/etc/resolv.conf
cd /coolcncmount
chroot .
# you may have to repeat the "chroot ."
# youre ready to utlilze the full power of your hardware for compiling
# instead of the rather slow emulation. if you dont have a suitable kernel
# running right now, nevermind, we are going to build a kernel anyways
# you can customize it if desired and also install it on your HOSTSYSTEM.
# if you run a kernel that does not support squashfs/unionfs
# you have to use qemu. you should unmount /coolcncmount before booting
# or else filesystemcorruption may follow
umount /coolcncmount
qemu -hda coolcnc.0.2.img -cdrom puppy-1.0.7-mozilla.iso -boot c -m 128
# the following commands are to be executed from within the qemu COOLCNC-
# environment or a proper setup chroot environment !!!
# first lets get to the homedirectory
cd /root
# get puppy unleashed core (for building puppy from scratch) you can skip these steps
# for now if you want to. they can be done later. its a rather heavy download of
# aproximatly 300MB. you dont need this if you just want to take a look at the rtai'd puppy.
wget -c http://ftp.nluug.nl/ftp/pub/os/Linux/distr/puppylinux/puppy-unleashed-core-1.0.7.tar.gz
mkdir /root/puppy
cd /root/puppy
tar -xvzf /root/puppy-unleashed-core-1.0.7.tar.gz
cd /root
mkdir package_tarballs
cd package_tarballs
# get puppy unleashed packages
wget -m -nd -np http://ftp.nluug.nl/ftp/pub/os/Linux/distr/puppylinux/pupget_packages-1/
# unpack the packages into the unleashed package directory
cd /root/puppy/puppy-unleashed/packages
for package in `find /root/package_tarballs`; do tar -xvzf $package; done
# congratulations you have now finished setting up a puppy breeding environment
# now lets build a rtai patched kernel, emc2 and a axis packages for it
# QEMU: please verify that /usr_devx.sfs gets recognized and mounted.
# lets see if puppy automagically detects the usr_devx.sfs and mounts it at reboot.
# you can check if everything is ok by issuing the following command. watch out for lines
# telling about /dev/loop3 ....... 100% /.usr_devx
unionct /usr --list
# should output something like:
# /usr (rw)
# /.usr_devx (r-)
# if you are working within a chroot the us_devx.sfs should be allready mountet.
# verify it the same way as described above (note: when run outside the chroot
# you get to see the full path /coolcncmount/usr (rw) , /coolcncmount/.usr_devx (r-)
# building a 2.4.31 kernel
# now lets get the kernelsource
cd /usr/src
wget -c http://www.fht.lkams.kernel.org/pub/linux/kernel/v2.4/linux-2.4.31.tar.bz2
# get unionfs, squashfs, ntfs patches/tools and adeos
wget --passive-ftp ftp://unionfs-mirror.linux-live.org/unionfs/unionfs-1.0.9.tar.gz
wget http://ovh.dl.sourceforge.net/sourceforge/squashfs/squashfs2.2-r2.tar.gz
wget http://www.goosee.com/puppy/development/linux-2.4.29-ntfs-2.1.6b.patch.gz
wget -c http://download.gna.org/adeos/patches/attic/v2.4/i386/candidates/adeos-linux-2.4.31-i386-r18c1.patch
# unpack the kernelsource and the patches and apply them to the source
rm linux
rm -rf linux-2.4.31
tar -xvjf linux-2.4.31.tar.bz2
ln -s linux-2.4.31 linux
tar -xvzf unionfs-1.0.9.tar.gz
tar -xvzf squashfs2.2-r2.tar.gz
gzip -d linux-2.4.29-ntfs-2.1.6b.patch.gz
cd linux
patch -p1 < /usr/src/squashfs2.2-r2/linux-2.4.31/squashfs2.2-patch
patch -p1 < /usr/src/adeos-linux-2.4.31-i386-r18c1.patch
patch -p1 < /usr/src/linux-2.4.29-ntfs-2.1.6b.patch
# copy the original puppy config into place remove some lines and add adeos support
cat ../linux-2.4.29/config-2july05-2.4.29-pup1.0.4 | grep -v CONFIG_MODVERSIONS > .config
echo "#changed for meeting the needs of rtai and to require no userinteraction
CONFIG_BLUEZ_HCIUART_H4=m
CONFIG_SCSI_SATA_QSTOR=m
CONFIG_MODVERSIONS=n
CONFIG_ADEOS=m
CONFIG_ADEOS_PROFILING=n
CONFIG_ADEOS_CORE=y
CONFIG_IPIPE=n
CONFIG_IPIPE_STATS=n
CONFIG_SQUASHFS_EMBEDDED=n" >> .config
# if youd like to have any other things configured run make config or menuconfig now
# also if you have too much ram and or cpu/s you could add
# MAKE = make -j2 to the Makefile
# ready to build a kernel ? lets go :)
make oldconfig
make dep
make clean
make bzImage
make modules
# puppys xargs (which is just another part of busybox) lacks the -i option
# so we have to get GNU findutils first, compile it and copy xargs into
# our PATH in order to let make modules_install finish its job.
cd /usr/src
wget http://ftp.gnu.org/pub/gnu/findutils/findutils-4.2.27.tar.gz
tar -xvzf findutils-4.2.27.tar.gz
cd findutils-4.2.27
./configure
make
cp xargs/xargs /bin/xargs
# now the modules should install into /lib/modules/2.4.31
# the kernel and System.map gets copied to /boot
cd /usr/src/linux
make modules_install
cp arch/i386/boot/bzImage /boot/vmlinuz-2.4.31
cp System.map /boot/System.map-2.4.31
rm /lib/modules/2.4
ln -s /lib/modules/2.4.31 /lib/modules/2.4
# now lets compile the unionfs module and copy it into place
# uname -r is removed because of some issues when compiling
# in a chrooted environment and the HOSTS kernel is not a
# 2.4.31 version kernel.
cd unionfs-1.0.9
echo "EXTRACFLAGS=-DNODEBUG
LINUXSRC=/usr/src/linux-2.4.31" > fistdev.mk
cat Makefile | sed 's/`uname\ \-r`/2.4.31-adeos/g' | sed 's/uname\ \-r/2.4.31/g' | \
sed 's/^KERNELVERSION.*/KERNELVERSION=2.4/' > Makefile_
mv Makefile_ Makefile
make
make install
# we got all modules together, lets install the kernel for testing
echo "title COOLCNC (on /dev/hda1)
root (hd0,0)
kernel /boot/vmlinuz-2.4.31 root=/dev/hda1 ro vga=normal" >> /boot/grub/menu.lst
# boot qemu and choose COOLCNC when entering the grub bootmenu
# at the first boot with the new kernel the modules dependencyfile must be
# created by opening a terminal and entering depmond -a
# after the next reboot the usr_devx should be mounted correctly
# and we can continue to install rtai and emc. for this we need
# to run the rtaikernel we compiled earlier. you got two choices.
# use a qemu session (slow)
qemu -hda coolcnc.0.2.img -cdrom puppy-1.0.7-mozilla.iso -boot c -m 256
# i recommend installing the kernel on the host too and use a chrooted environment.
# dont forget to do a depmod -a ! you will not be able to compile
# if usr_devx is not mounted and stacked over your /usr directory!
# next stop rtai, emc2, python, axis, mesa
wget http://download.gna.org/rtai/stable/v3/rtai-3.2.tar.bz2
wget http://www.python.org/ftp/python/2.4.2/Python-2.4.2.tgz
wget http://surfnet.dl.sourceforge.net/sourceforge/mesa3d/MesaLib-6.4.1.tar.bz2
wget http://surfnet.dl.sourceforge.net/sourceforge/mesa3d/MesaGLUT-6.4.1.tar.bz2
wget http://surfnet.dl.sourceforge.net/sourceforge/tcl/tcl8.4.12-src.tar.gz
wget http://surfnet.dl.sourceforge.net/sourceforge/tcl/tk8.4.12-src.tar.gz
wget http://unpy.net/cgi-bin/viewcvs.cgi/axis/axis.tar.gz?tarball=1
mv axis.tar.gz\?tarball\=1 axis.tar.gz
# now some unionfstricks. its easy to create packages if you use unionfs to keep data separated.
mkdir /.coolcnc
dd if=/dev/zero of=/coolcnc.sfs bs=1M count=256
mkfs.ext2 -F /coolcnc.sfs
mount -o loop /coolcnc.sfs /.coolcnc
# lets direct all following writeoperations to /.coolcnc
unionctl /usr --add --before /usr --mode rw /.coolcnc
unionctl /usr --mode /usr ro
# unionctl /usr --list should now tell you something like this
# /.coolcnc (rw)
# /usr (r-)
# /.usr_devx (r-)
# if youd like to you can put those lines into /etc/rc.d/rc.local
# they will be executed with every subsequent boot.
echo "mount -o loop /coolcnc.sfs /.coolcnc
unionctl /usr --add --before /usr --mode rw /.coolcnc
unionctl /usr --mode /usr ro" >> /etc/rc.d/rc.local
# time to get rtai and emc on the road :)
# first lets compile rtai
cd /usr/src
echo "root ALL=(ALL) ALL" > /etc/sudoers
chmod 0440 /etc/sudoers
tar -xvjf rtai-3.2.tar.bz2
rm linux ; ln -s linux-2.4.31 linux
cd rtai-3.2
./configure
make install
cd /usr/src
rm -rf rtai-3.2
# emc2 depends on tcl/tk
cd /usr/src
tar -xvzf tcl8.4.12-src.tar.gz
tar -xvzf tk8.4.12-src.tar.gz
cd /usr/src/tcl8.4.12/unix
./configure
make
make install
cd /usr/src
cd /usr/src/tk8.4.12/unix
./configure
make
make install
cd /usr/src
export LD_LIBRARY_PATH=/usr/local/lib
# lets add /usr/local/lib as librarypath to our .bashrc
echo "LD_LIBRARY_PATH=/usr/local/lib" >> /root/.bashrc
# now emc2 is ready to get leeched and compiled :)
# sourceforge cvs is sometimes under heavy load. at leat
# it looks like that because the checkout may take multiple
# runs before it works.
touch /root/.cvspass
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/emc login
cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/emc co emc2
cd emc2/src
./configure
make
#cleanup
rm -rf /usr/src/tk8.4.12
rm -rf /usr/src/tcl8.4.12
# now lets see if emc2 works
cd ..
scripts/emc
# i dont like the look of the fonts
# do the following for more readable fonts
# if youd like emc to talk to you in a language other then english
# you have to set your LANG environment variables correctly.
# german for example could be selected by executing:
LANG=de
# no lets get axis dependencies fullfilled
cd /usr/src
tar -xvzf Python-2.4.2.tgz
cd Python-2.4.2
./configure
make
make install
# make some space or else we will run out during the next compiles
cd /usr/src
rm -rf Python-2.4.2
# for the pretty 3d look axis depends on opengl
# lets use Mesa and Glut
tar -xvjf Mesa-6.4.1.tar.bz2
cd Mesa-6.4.1
make linux-x86
cp -auv lib/* /usr/local/lib
cd /usr/src
tar -xvjf MesaGLUT-6.4.1.tar.bz2
cd Mesa-6.4.1
make linux-x86
cp -auv lib/* /usr/local/lib
cd /usr/src
rm -rf /usr/src/Mesa-6.4.1
# now to axis
tar -xvzf axis.tar.gz
cd axis
EMCROOT=/usr/src/emc2 python setup.py install --force
rm -rf /usr/src/Mesa-6.4.1
# now you could change the DISPLAY variable in the emc2 inifile
# you are using for your machine to DISPLAY = axis to give it
# a testrun.
# you have finished installing rtai,emc2 and axis on
# your puppy. now lets get to the breeding part.
# ...to be continued
# this version reflects the progress of this howto on january 10th 2006