Skip to content

Instantly share code, notes, and snippets.

@NeoTech
Last active January 4, 2021 22:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save NeoTech/434c6f93e6c5e2471f8b2505b9d2f56c to your computer and use it in GitHub Desktop.
Save NeoTech/434c6f93e6c5e2471f8b2505b9d2f56c to your computer and use it in GitHub Desktop.
LinuxCNC Machinekit Package Build

Howto build LinuxCNC packages and the support packages for Ethercat HAL driver.

Machinekit is in here because these should also apply for other platforms and in general machinekit is more suited for tinkering than linuxcnc at this point in time. Mainly due to the cleaned up repositories and the seperation between hal and cnc. That is all i will get into the politics of these projects..

To run these you should use Debian Buster 10, and using a realtime kernel. To install a realtime kernel just run this command

sudo apt-get update
sudo apt-get install linux-image-rt-amd64 linux-headers-rt-amd64

Reboot..


Pre install should include.

sudo apt install dpkg-dev devscripts git mercurial dkms quilt mq dh-python rtai-modules-4.19.0-13-rt-amd64 pkg-config libudev-dev libmodbus-dev libusb-1.0-0-dev glib-dev glib libglib2.0-dev/stable libgtk2.0-dev yapps2 python3-yapps intltool/stable libtcl8.6 libtclcl1-dev/stable tcl-dev tk-dev bwidget tclx python-gtk2 libreadline-gplv2-dev python-tk libboost-python-dev/stable libopengl0/stable mesa-dev libegl1-mesa-dev/stable libgl1-mesa-dev/stable libgles2-mesa-dev/stable libglu1-mesa-dev/stable libglw1-mesa-dev/stable libd3dadapter9-mesa-dev/stable libxmu-dev python-yapps asciidoc dblatex docbook-xsl dvipng ghostscript graphviz groff imagemagick inkscape python-lxml source-highlight w3c-linkchecker xsltproc texlive-extra-utils texlive-font-utils texlive-fonts-recommended texlive-lang-cyrillic texlive-lang-french texlive-lang-german texlive-lang-polish texlive-lang-spanish texlive-latex-recommended asciidoc-dblatex libtirpc-dev libreadline-dev cython libxaw7-dev libboost-serialization-dev python-zmq python-setuptools python-protobuf python-simplejson libboost-thread-dev python-pyftpdlib

Linuxcnc Package build, this is needed for HAL drivers and other things you wanna use with machinekit.

cd linuxcnc-dev/src
./autogen.sh
./configure --with-realtime=uspace

The output should read

######################################################################
#                LinuxCNC - Enhanced Machine Controller              #
######################################################################
#                                                                    #
#   LinuxCNC is a software system for computer control of machine    #
#   tools such as milling machines. LinuxCNC is released under the   #
#   GPL.  Check out http://www.linuxcnc.org/ for more details.       #
#                                                                    #
#                                                                    #
#   It seems that ./configure completed successfully.                #
#   This means that RT is properly installed                         #
#   If things don't work check config.log for errors & warnings      #
#                                                                    #
#   Next compile by typing                                           #
#         make                                                       #
#         sudo make setuid                                           #
#          (if realtime behavior and hardware access are required)   #
#                                                                    #
#   Before running the software, set the environment:                #
#         . (top dir)/scripts/rip-environment                        #
#                                                                    #
#   To run the software type                                         #
#         linuxcnc                                                   #
#                                                                    #
######################################################################

Here you can either make it and run it in place.. or go back and start making these into debian packages. To create packages we need to run these commands. (And if you ask me, you should always build packages for ease of maintenance)

cd linuxcnc-dev/debian
./configure uspace
cd ..
dpkg-buildpackage -b -uc

Build the Etherlabmaster-dev package.

This would be required for ethercat support. And to be able to build the ethercat package we will need to build linuxcnc-dev package and install it. These packages are requirements for ethercat packages. And the existing package that are distributed only supporting i386.

This package requires mercurial (hg) and the git command. You need to add this to the mercurial config file. ( ~/.hgrc )

[extensions]
mq =

Once that is done we can get into building the Etherlab master dev packages.

git clone https://github.com/sittner/ec-debianize
cd ec-debianize
./get_source.sh
cd etherlabmaster
dpkg-checkbuilddeps
dpkg-buildpackage
cd ..

Installing Etherlabmaster

  • For it to be able to run, first install the etherlabmaster_1.5.2 package.
  • Then edit /etc/default/ethercat to correspond to the macaddress you wanna use and set it to the generic driver. (this can be changed later)
  • then run the command sudo update-ethercat-config
  • Reboot

Build the linuxcnc-ethercat packages

Install the linuxcnc, linuxcnc-dev that you built previously and issue the following command

git clone https://github.com/sittner/linuxcnc-ethercat.git
cd linuxcnc-ethercat
dpkg-checkbuilddeps
dpkg-buildpackage
cd ..

This should have built the packages and you should be able to issue: sudo dpkg -i linuxcnc-ethercat*deb

At this point you should have a working linuxcnc installation running in "uspace" mode with ethercat support and the necessary hal interface to be able to create your configuration.

This section is broken - dont attempt building these packages.

Build the Machinekit-HAL packages

As you have prob. built the previous linuxcnc packages, you will now be aware that you have most of the support packages you need for building Machinekit HAL. Which means we dont need to utilize the built in docker container builder. Instead we do this:

git clone https://github.com/machinekit/machinekit-hal.git
cd machinekit-hal
debian/bootstrap
debian/configure.py -c
debian/buildpackages.py
cd ..

And now you should see a series of debian packages for machinekit-hal, including the dev package that is not normally ditributed thru their apt repository.

NOTE: If you need to build machinekit for any other architecture, you will need to use the docker image approach using QEMU, this will only function for the architecture that you are on while building it. See this link for details https://www.machinekit.io/docs/developing/machinekit-developing/

Once back into the system you should be able to run the command "ethercat master" and get a non error response. Now you can continue by installing the etherlabmaster-dev* package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment