LinuxCNC on Ubuntu 12.04LTS

Recent developments has made it possible to run LinuxCNC on the latest LTS release of Ubuntu. This is experimental work, so not recommended for controlling a real machine just yet. The main obstacle for moving LinuxCNC from 10.04LTS to a more recent distribution has been the RTAI real-time kernel, which has not been kept up-to-date with development of the normal Linux kernel. Fortunately there are alternatives such as Xenomai or RT_PREEMPT.

Here is a step-by-step description of the install/build process, if you want to experiment with this.

  1. Download and install a normal 32-bit 12.04LTS Ubuntu (ubuntu-12.04.1-desktop-i386.iso). Note that the 64-bit version is not supported for the steps that follow further down. I could not get Ubuntu's startup-disk-creator to work, so I used unetbootin to write the ISO-file to a USB-stick.
  2. It's possible to compile the xenomai-kernel from scratch, along with the runtime etc., but I used pre-compiled deb-packages by Michael Haberler from here: http://static.mah.priv.at/public/xenomai-debs/
  3. Install the xenomai kernel:
    sudo dpkg -i linux-headers-3.2.21-xenomai+_0.1_i386.deb
    sudo dpkg -i linux-image-3.2.21-xenomai+_0.1_i386.deb
  4. make sure it will show up as a GRUB-entry when booting:
    sudo update-initramfs -c -k 3.2.21-xenomai+
    sudo update-grub
  5. reboot. uname -r should now show: 3.2.21-xenomai+
  6. now install the xenomai runtime:
    sudo dpkg -i libxenomai1_2.6.1_i386.deb
    sudo dpkg -i libxenomai-dev_2.6.1_i386.deb
    sudo dpkg -i xenomai-runtime_2.6.1_i386.deb

This installs the xenomai system on top of which a recently available version of LinuxCNC can be built. There are probably many ways to now obtain the tools/dependencies that are required. I used the following:

  1. sudo apt-get install synaptic
    sudo apt-get install git
  2. Now using synaptic, install the following packages (I found these are required for a minimal linuxcnc build):
    build-essential
    autoconf
    libpth-dev
    libglib2.0-dev
    libgtk2.0-dev
    tcl-dev
    tk-dev
    bwidget
    libreadline-dev
    python-tk
    python-dev
    libgl1-mesa-dev
    libglu1-mesa-dev
    libxmu-dev
  3. Get Michael's version of LinuxCNC that can be compiled for Xenomai:
    git clone git://git.mah.priv.at/emc2-dev emc2-dev
    cd emc2-dev
    git branch --track rtos origin/rtos-integration-preview1
    git checkout rtos
  4. Configure and build for Xenomai:
    cd src
    ./configure --with-threads=xenomai-user --enable-run-in-place
    make
    sudo make setuid
  5. Test:
    . ./scripts/rip-environment
    latency-test

This new version of LinuxCNC can be built without a real-time kernel (previously called "simulator" or "sim") or with any of the real-time kernel alternatives: RTAI, Xenomai, RT_PREEMPT. It should be possible to compare real-time performance in the form of latency-numbers with different hardware and kernels.

20 thoughts on “LinuxCNC on Ubuntu 12.04LTS”

  1. and these may also be required for the doc-build:
    dvipng texlive-extra-utils texlive-latex-recommended texlive-fonts-recommended ghostscript imagemagick texlive-lang-french texlive-lang-german texlive-lang-spanish texlive-lang-polish texlive-font-utils asciidoc (>= 8.5) source-highlight dblatex (>= 0.2.12) xsltproc groff libgnomeprintui2.2-dev texlive-lang-cyrillic

  2. further (optional) dependencies:
    xemc-GUI: libxaw7-dev,
    printing from classicladder: libgnomeprinting-2.2-dev
    keystick-GUI: libncurses-dev

    1. No, the xenomai-kernel should boot quite normally and you should see a normal Ubuntu startup sequence, desktop etc.
      If you can get your machine to boot from HDD you can edit the GRUB configuration so it boots to a stable kernel.
      If nothing else helps you can boot from a LiveCD or USB stick and try to edit the GRUB settings or even do a complete reinstall.

      Is this a very new or very old motherboard/cpu? I guess that xenomai kernel is built on top of a standard 3.2.21-kernel, so it might be worth testing if a standard 3.2.21-kernel (or any 3.2 series) installs and boots OK.
      Michael H might know more about what drivers or options are disabled in the xenomai kernel wrt. a standard kernel - maybe something is missing in xenomai and that is causing your problems.

  3. hm, nor sure why you are having problems. Did you do an md5sum check on your iso-download? Can you do a memcheck test on your machine to see that the hardware is ok?

  4. i did everything that. installed from alternate cd, deinstalled unity and gnome* - nothing helps, it just hangs without logic in not predicted moments. 12.10 is perfect when installed. i'll try to find some ways or wait 12.04.2 ))

  5. Hi Anders, thanks for the instructions!

    Probably the other commenters with boot problems are having trouble with the kernel config, which we have found has turned off some drivers needed for some systems require to boot.

    There's a new wiki page on LinuxCNC.org that explains how to build a kernel yourself, or else install pre-built packages. The config file is based on the Ubuntu Precise kernel config. These packages should support just about any hardware that the normal Ubuntu Precise kernel supports.

    See the page here: http://wiki.linuxcnc.org/cgi-bin/wiki.pl?XenomaiKernel

    John/Zultron

  6. Thanks for the instructions. I managed to install linuxcnc but when i try to test my axis using stepconf i get the following error
    Stepconf encountered an error. The following information may be useful in troubleshooting:

    Traceback (most recent call last):
    File "./stepconf", line 1738, in on_xaxistest_clicked
    def on_xaxistest_clicked(self, *args): self.test_axis('x')
    File "./stepconf", line 2107, in test_axis
    if not self.check_for_rt(): return
    File "./stepconf", line 1282, in check_for_rt
    elif hal.is_rt and not hal.kernel_version == actual_kernel:
    AttributeError: 'module' object has no attribute 'kernel_version'

    halmodule.cc contains the following line

    #ifdef RTAPI_KERNEL_VERSION
    PyModule_AddStringConstant(m, "kernel_version", RTAPI_KERNEL_VERSION);

    My kernel is
    root@Mpoha> uname -a
    Linux Mpoha 3.2.21-xenomai+ #1 SMP PREEMPT Tue Oct 30 19:01:33 UTC 2012 i686 i686 i386 GNU/Linux

  7. Hi Andreas,

    You don't strictly need stepconf to run linuxcnc. It's a good idea to learn what goes into the INI and HAL files anyway and not blindly trust stepconf.

    I'm not sure why exactly you see that problem. Stepconf may be written in a way that assumes an RTAI system.

    There are about three good ways to report problems like these:
    - the mailing-list: https://lists.sourceforge.net/lists/listinfo/emc-users
    - the forum: http://www.linuxcnc.org/index.php/english/forum/index
    - on IRC: #LinuxCNC and #LinuxCNC-devel on irc.freenode.net

    Anders

  8. hi dudes,
    thank's for this page, it has been the only valid way to install linuxcnc on xubuntu 12.04
    BUT... i've the followin' problem:
    i click on the con, program start and i can select the configuration options
    linuxcnc logo with penguin, version etc. appear and... a linuxcnc error window open and program exit.
    the error message is:
    Print file information:
    RUN_IN_PLACE=no
    LINUXCNC_DIR=
    LINUXCNC_BIN_DIR=/usr/bin
    LINUXCNC_TCL_DIR=/usr/lib/tcltk/linuxcnc
    LINUXCNC_SCRIPT_DIR=
    LINUXCNC_RTLIB_DIR=/usr/lib/linuxcnc/modules
    LINUXCNC_CONFIG_DIR=
    LINUXCNC_LANG_DIR=/usr/share/linuxcnc/tcl/msgs
    INIVAR=inivar
    HALCMD=halcmd
    LINUXCNC_EMCSH=/usr/bin/wish8.5
    LINUXCNC - 2.5.2-193-g6de7f0d
    Machine configuration directory is '/home/incisoria/linuxcnc/configs/cooltool-1'
    Machine configuration file is 'Basic540_4axes.ini'
    INIFILE=/home/incisoria/linuxcnc/configs/cooltool-1/Basic540_4axes.ini
    PARAMETER_FILE=stepper.var
    TASK=milltask
    HALUI=
    DISPLAY=axis
    Starting LinuxCNC...
    Starting LinuxCNC server program: linuxcncsvr
    Loading Real Time OS, RTAPI, and HAL_LIB modules
    Starting LinuxCNC IO program: io
    Shutting down and cleaning up LinuxCNC...
    Killing task linuxcncsvr, PID=7315
    Removing HAL_LIB, RTAPI, and Real Time OS modules
    Removing NML shared memory segments
    Cleanup done

    Debug file information:
    Can not find -sec MOT -var MOT -num 1
    Can not find -sec IO -var IO -num 1
    Can not find -sec LINUXCNC -var NML_FILE -num 1
    Can not find -sec EMC -var NML_FILE -num 1
    hal_parport: dlopen: /usr/lib/linuxcnc/modules/hal_parport.so: cannot open shared object file: No such file or directory
    S4_pinout.hal:6: /usr/bin/rtapi_app exited without becoming ready
    S4_pinout.hal:6: insmod failed, returned -1
    7315
    PID TTY STAT TIME COMMAND
    Stopping realtime threads
    Unloading hal components

    could somebody pleeeeeease help me?
    thanks

  9. Lucio,
    You should try running linuxcnc in sim-mode. Does that work? That would indicate a problem with the parport driver.

    In general it's best to post all your configuration files and your error output on either the linuxcnc form or the linuxcnc mailinglist. My experience is that there is usually someone there who knows how to solve your problem and can help you.

    AW

  10. Hi there, linux n00b here, I had great luck with your instructions up to #4. It reads:
    Configure and build for Xenomai:
    cd src
    ./configure --with-threads=xenomai-user --enable-run-in-place
    make
    sudo make setuid

    BUT I think it should read:
    Configure and build for Xenomai:
    cd src
    sh autogen.sh
    ./configure --with-threads=xenomai-user --enable-run-in-place
    make
    sudo make setuid

  11. I installed 12.04.2, but according to latency-test outputs, it doesnt meet real-time requirements.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.