Compiling full LinuxCNC to get realtime components for use with PathPilot 2

More
28 Apr 2018 07:39 #109745 by Stigoe
Since it seems several people are trying to add some of the missing realtime components to PathPilot and haven't been able to replicate what I did and described in another post, I figured I'd create this how-to and include code and screendumps along the way.

Disclaimer: This worked for me. If it doesn't for you, I take no responsibility if it screws up you PathPilot install, kill your house or burn down your cat. You break it, you fix it... :-)

This was done on a Win7 x64 and Oracle VirtualBox, but the type of host-machine shouldn't really matter as it is the VirtualBox running the virtual machine. If you have an unused pc, you could use that. Or you can try doing this on your PathPilot machine, but I didn't want to risk my PP install by doing the compiling on that.

Preparations

First I created a virtual machine, with a fixed drive of 32GB and told VB that it would be a 64-bit linux.
Then I downloaded Linux Mint 17.3 from linuxmint.com and selected Download - All versions - 17.3 - Mate (64-bit).
From what I have read, PP is based on LCNC 2.7.8 pre, so I chose to get LCNC 2.7.8 and this can be had from http://linuxcnc.org/dists/wheezy/2.7-uspace/source/
PP is using kernel 4.11.9-rt7 x86_64 PREEMPT, so go and fetch kernel 4.11.9 and patch 4.11.9-rt7 from kernel.org ( https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.11.9.tar.gz and https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/4.11/older/patch-4.11.9-rt7.patch.gz ), or you could wait until Linux Mint is up and running and just download them in the virtual machine.

First put the Linux Mint .iso in the virtual CD-drive and start up your virtual machine. When Linux Mint is up in it's live version, install Linux Mint and reboot when it's finished installing. After rebooting, install Guest Additions in the virtual machine so that you have access to shared folders and can connect USB-sticks to the virtual machine. When this is done, you may have to reboot the machine before the guest additions will work. When it's done, create a shared folder and put your LCNC and kernel files in this shared folder, or you could just use a USB-stick to transfer the files.

Preparing the kernel

Copy the 3 files to your home directory and chown the 2 kernel files (obviously, replace stig with your login username)
sudo chown stig:stig linux-4.11.9
sudo chown stig:stig patch-4.11.9-rt7.patch.gz

Next unpack the files, copy the patch-file into the Linux kernel directory, cd into Linux-4.11.9 and apply patch
gunzip linux-4.11.9.tar.gz
gunzip patch-4.11.9-rt7.patch.gz
tar -xf linux-4.11.9.tar
cp patch-4.11.9-rt7.patch linux-4.11.9
cd linux-4.11.9
cat patch-4.11.9-rt7.patch | patch -p1

Start Package Manager, go to Settings - Repositories and Enable source code repositories. Close Package Manager.

We will have to install quite a lot of packages to be able to compile the kernel and LCNC, so let's install some of them.
sudo add-apt-repository 'deb http://mirrors.kernel.org/ubuntu precise main universe'
sudo apt-get update
sudo apt-get install libgnomeprintui2.2-dev python-support tcl8.4-dev tk8.4-dev libtk-img-dev libssl-dev dpkg-dev libncurses5-dev

Next, let's configure the kernel.
make menuconfig

Attachment not found



Make sure 64-bit kernel is checked
Select Processor type and features-->Preemption Model---> Fully Preemptible Kernel (RT)-->back to top menu
Select Power management and ACPI option ---> disable suspend to RAM, Hybernation and CPU frequency scaling --> back to top menu
Select Memory Debugging (found under Kernel hacking)--> Check for stack overflows ( already deselect so dont select this -just check)
Save and exit

Unless you really want it, you don't need a kernel built with debug options. This takes a lot longer time and space to build and you need more than a 32 GB drive to complete it.
So to turn off debug kernel,
scripts/config --disable DEBUG_INFO

Next comes the compile of the kernel. This takes quite some time, and if you have several processors available, you can speed up the process by specifying -j<number of processors> after the make command, but since I'm running in a VM with only one processor I just drop the j-option.
make
sudo make modules_install
sudo make install

You may get some errors about ndiswrapper and no support for locate en_US.utf8, but this is nothing to worry about.

After the kernel is installed check that it is in /boot

Attachment not found



Reboot to enable the new kernel. After it has restarted, run "uname -a" to check that you are running the new kernel.

Attachment not found



Compiling LinuxCNC...

Go into build/debian and run "sudo ,/configure uspace" before going back up one step to check for dependencies. bwidget and tclx will not show as dependency, but configure will fail unless they are also installed.
cd build/debian
sudo ./configure uspace
cd ..
dpkg-checkbuilddeps
sudo apt-get install build-essential:native debhelper libudev-dev dvipng texlive-extra-utils texlive-latex-recommended texlive-fonts-recommended imagemagick texlive-font-utils tcl8.6-dev tk8.6-dev libxaw7-dev libreadline-gplv2-dev asciidoc source-highlight dblatex groff python-dev python-tk libglu1-mesa-dev libgl1-mesa-dev libboost-python-dev texlive-lang-cyrillic texlive-lang-french texlive-lang-spanish texlive-lang-german libmodbus-dev libusb-1.0-0-dev graphviz inkscape bwidget tclx
When these are all installed, go into the src-directory and run configure and compile LCNC.
cd src
sudo ./autogen.sh
sudo ./config --with-realtime=uspace
sudo make clean
sudo make

This will also compile all included realtime components.

Next depends on what you want, whether you want just your missing realtime components or if you want the whole installation copied to your PP install. If you want only the missing components, copy them to a USB-stick or some other means to transfer them over and copy them into ~/tmc/rtlib on your PP machine. If you do this, you will have to chown the files to operator:operator.

If you want the whole installation, cd out of build directory, pack up the whole directory and copy it over to your PP machine, where you unpack it to ~/repos/tormach_linuxcnc/ before you rename the build folder to linuxcnc.
# you should be in the build folder now
cd ..
tar -cf lcnc.tar build/
# copy lcnc.tar over to your PP install
# when you have copied it over to ~/repos/tormach_linuxcnc
tar -xf lcnc.tar
mv build linuxcnc

That's all there is to it.
The following user(s) said Thank You: andypugh, dinkata
More
02 May 2018 21:04 #110052 by andypugh
I wonder where the attachments went to?
More
03 May 2018 05:33 - 06 May 2018 07:34 #110090 by Stigoe
Glitch in the forum software? Seems I can't edit the post any more so I can't re-upload them either, other than in a new post.

Edit: Here are the attachments from the first post.
make menuconfig


Check that the kernel is installed


After rebooting, check that you are running the new kernel
Attachments:
Last edit: 06 May 2018 07:34 by Stigoe. Reason: Adding attachments again.
The following user(s) said Thank You: rafferty
More
13 May 2018 12:08 #110666 by rafferty
Just finished the rtlib build using VMware on Mac OS X.

Minor problem was missing autoconf which prevented the sudo ./autogen.sh line running, a quick apt get fixed that.

I'm slowly moving to PP2 but want to look further into the works before going all the way.

Thanks for doing all the hard work.
Moderators: cncbasher
Time to create page: 0.266 seconds
Powered by Kunena Forum