├── README.md ├── build-cnc.sh ├── build.sh ├── clean.sh └── makeimage.sh /README.md: -------------------------------------------------------------------------------- 1 | # Xenomai + Raspberry Pi + Linux CNC 2 | 3 | These scripts sort of mostly help you automatically build the real-time Xenomai kernel and Linux CNC for the Raspberry Pi. They have been tested on Debian Wheezy. 4 | 5 | Run build.sh and then makeimage.sh this will give you a file that you can dd onto your SD card. 6 | 7 | ## Files 8 | 9 | * build.sh - The main build script 10 | * build-cnc.sh - This step takes a while and gave me a few troubles so it is currently separated out. The build.sh script calls it. 11 | * clean.sh - Attempts to reset things so that you can start fresh. 12 | * makeimage.sh - Builds an image file that you can write to an SD card. 13 | -------------------------------------------------------------------------------- /build-cnc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo cp -a xenomai-2.6.1 rootfs/usr/src 3 | 4 | if [ ! -d emc2-dev ]; then 5 | git clone -b rtos-integration-preview3 --depth 1 git://git.mah.priv.at/emc2-dev.git 6 | fi 7 | sudo cp -a emc2-dev rootfs/usr/src/ 8 | 9 | sudo chroot rootfs < /etc/ld.so.conf.d/xenomai.conf 15 | ldconfig -v 16 | 17 | make clean 18 | rm -r rpi 19 | 20 | cd ../emc2-dev/src 21 | ./autogen.sh 22 | ./configure --prefix=/usr/local --with-platform=raspberry --disable-build-documentation --with-kernel=/boot/config-3.2.27-xenomai+ 23 | make 24 | make install 25 | 26 | make clean 27 | exit 28 | EOF 29 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | # Fetch cross compile tools 2 | if [ ! -f master.tar.gz ]; then 3 | wget --no-check-certificate https://github.com/raspberrypi/tools/archive/master.tar.gz 4 | tar xzf master.tar.gz 5 | fi 6 | 7 | # Fetch 3.2.27 kernel 8 | if [ ! -d linux-rpi-3.2.27 ]; then 9 | git clone -b rpi-3.2.27 --depth 1 git://github.com/raspberrypi/linux.git linux-rpi-3.2.27 10 | fi 11 | 12 | # Fetch firmware 13 | if [ ! -d firmware ]; then 14 | git clone https://github.com/raspberrypi/firmware.git 15 | fi 16 | 17 | if [ ! -f xenomai-2.6.1.tar.bz2 ]; then 18 | wget http://download.gna.org/xenomai/stable/xenomai-2.6.1.tar.bz2 19 | tar xjf xenomai-2.6.1.tar.bz2 20 | fi 21 | 22 | if [ ! -d patch ]; then 23 | mkdir patch 24 | wget http://www.cim.mcgill.ca/~ian/rpi-linux-3.2.21-xenomai-2.6.1.patch -P patch 25 | wget http://dl.dropbox.com/u/17024524/linuxcnc/rpi-3.2.27-xenomai.patch -P patch 26 | 27 | # Apply 3.2.27 patch 28 | patch -p0 < patch/rpi-3.2.27-xenomai.patch 29 | 30 | # Apply Xenomai 2.6.1 patch 31 | xenomai-2.6.1/scripts/prepare-kernel.sh --arch=arm --linux=linux-rpi-3.2.27 --adeos=xenomai-2.6.1/ksrc/arch/arm/patches/ipipe-core-3.2.21-arm-1.patch 32 | 33 | # Apply Rasbperry Pi Xenomai patch 34 | (cd linux-rpi-3.2.27; patch -p1 < ../patch/rpi-linux-3.2.21-xenomai-2.6.1.patch) 35 | fi 36 | 37 | 38 | # Create build directory 39 | if [ ! linux-rpi-3.2.27/build ]; then 40 | mkdir linux-rpi-3.2.27/build 41 | 42 | # Download and use minimal configuration file 43 | wget http://dl.dropbox.com/u/17024524/linuxcnc/config.rpi-3.2.27-xenomai%2B -O linux-rpi-3.2.27/build/.config 44 | cd linux-rpi-3.2.27 45 | make mrproper 46 | make ARCH=arm O=build oldconfig 47 | 48 | # Compile 49 | make ARCH=arm O=build CROSS_COMPILE=../../tools-master/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/arm-bcm2708hardfp-linux-gnueabi- 50 | 51 | # Install modules 52 | make ARCH=arm O=build INSTALL_MOD_PATH=dist modules_install 53 | 54 | # Install headers 55 | make ARCH=arm O=build INSTALL_HDR_PATH=dist headers_install 56 | find build/dist/include \( -name .install -o -name ..install.cmd \) -delete 57 | fi 58 | 59 | # Install qemu tools 60 | sudo apt-get install qemu qemu-user qemu-user-static binfmt-support debootstrap 61 | 62 | if [ ! -d rootfs ]; then 63 | sudo debootstrap --foreign --no-check-gpg --include=ca-certificates --arch=armhf wheezy rootfs http://reflection.oss.ou.edu/raspbian/raspbian/ 64 | sudo cp $(which qemu-arm-static) rootfs/usr/bin 65 | sudo chroot rootfs/ /debootstrap/debootstrap --second-stage --verbose 66 | fi 67 | 68 | sudo sh -c 'echo rpi-linuxcnc >rootfs/etc/hostname' 69 | sudo sh -c 'echo -e 127.0.0.1\\trpi-linuxcnc >> rootfs/etc/hosts' 70 | sudo sh -c 'cat> rootfs/etc/network/interfaces < rootfs/etc/fstab < /etc/apt/sources.list.d/raspbian.list 91 | 92 | apt-get update 93 | apt-get install -y --no-install-recommends locales sudo xauth bc openssh-server ntp gettext autoconf \ 94 | libpth-dev gcc g++ make git libncurses5-dev libreadline-gplv2-dev tcl8.5-dev tk8.5-dev bwidget \ 95 | blt libxaw7-dev libglu1-mesa-dev libgl1-mesa-dev libgtk2.0-dev python python-dev python-support \ 96 | python-tk python-lxml libboost-python-dev yapps2-runtime libtk-img python-imaging python-imaging-tk \ 97 | python-xlib python-gtkglext1 python-configobj python-glade2 python-numpy build-essential 98 | apt-get clean 99 | 100 | addgroup xenomai 101 | addgroup root xenomai 102 | 103 | adduser rpi --gecos "RaspberryPi,,," --disabled-password 104 | echo "rpi:pitime" | chpasswd 105 | usermod -a -G xenomai,sudo,staff,kmem rpi 106 | 107 | cat >/etc/udev/rules.d/xenomai.rules<mnt/boot/config.txt<mnt/boot/cmdline.txt< /dev/' 45 | --------------------------------------------------------------------------------