Ethercat build from source - full instructions
THESE ARE MY BASIC INSTRUCTIONS TO HELP WITH DOING A CLEAN SOMEWHAT MINIMAL SOURCE BUILD OF LINUXCNC WITH ETHERCAT AND SASCHA ITTNER’S DRIVER. THIS WILL WORK FOR 32BIT OR 64BIT, SO IF YOU HAVE AN OLDER SETUP THAT STILL NEEDS 32BIT IT WILL WORK.
ALSO, TO CLARIFY… THIS IS FOR SETTING UP A SYSTEM FOR A DEDICATED CNC MACHINE. THEREFORE, I DO NOT INSTALL SYNAPTIC, OR MANY OTHER PACKAGES. THIS DOES NOT EVEN HAVE A WEB BROWSER, BUT IT IS NOT COMPLETELY STRIPPED OUT. *NOTE*, BOOKWORM INSTALLS WAY MORE PACKAGES THAN BULLSEYE FOR THE GUI, SO WILL CHECK THAT OUT LATER WHEN I HAVE TIME. PLUS, THINGS CONSTANTLY CHANGE, SO WILL TRY TO KEEP THIS UPDATED.
I LIKE ALL OF MY MACHINE SETUPS TO BE MINIMAL AS POSSIBLE, WITH STABILITY AND RELIABILITY BEING THE MAIN GOAL. MY PERSONAL SETUPS HAVE EVEN LESS PACKAGES THAN THESE INSTRUCTIONS AS I USE A VERY MINIMAL GUI. PLUS, I LOVE HOW CLEAN THE ETHERCAT BUILDS HAVE BECOME…. MUCH EASIER THAN 8-10 YEARS AGO UNDER LINUXCNC 2.5 & 2.6. EVERYTHING WAS RTAI & 32BIT BACK THEN BUT PREEMPT-RT BECAME STABLE & EVERYTHING ADVANCED TO 64BIT. LINUXCNC HAS CAME A LONG WAY SINCE THE DAYS OF EMC, THE BDI DISC ALONE WAS A GAME CHANGER (I NEVER GOT A WORKING SYSTEM BEFORE BDI)…
AS ALWAYS, I LIKE TO SAY THANKS TO EVERYONE THAT HAS HELPED CONTRIBUTE TO LCNC OVER THE LAST 20 OR SO YEARS OF WATCHING THIS… IT IS AWESOME AT THIS POINT. SO, IF YOU HAVE CONTRIBUTED IN THE PAST, THEN SUPER THANKS TO YOU!!!
THERE ARE 5 MAIN PARTS TO PUTTING A SYSTEM TOGETHER.
1) INSTALL LINUX DEBIAN OS WITH RT KERNEL
2) BUILD LINUXCNC FROM SOURCE (RIP BUILD)
3) BUILD IgH ETHERCAT FROM SOURCE
4) BUILD SASCHA ITTNER’s DRIVER
5) XML AND CONFIGURE LINUXCNC
ALL OF THIS IS USING THE OFFICIAL REPOSITORIES AND NOT FROM ANY THIRD-PARTY SETUP.
PART 1 INSTALLING DEBIAN 11 OR ABOVE
IF YOU ALREADY HAVE YOUR DEBIAN OS SETUP AND A RT KERNEL PATCHED THAT YOU LIKE, THEN YOU CAN SKIP ON DOWN TO PART 2A AND START THE BUILD. IF YOU WANT TO FULLY BUILD FROM SCRATCH WITH A MODERATELY STRIPPED OUT OS, THEN FOLLOW BELOW.
START BY GETTING A LINUX COMPUTER AND DOWNLOADING THE ISO IMAGE. JUST DO A SEARCH ON INTERNET FOR DOWNLOADING BULLSEYE 11 AND YOU WILL FIND THE LINUX DOWNLOAD CD IMAGE PAGE. DOWNLOAD THE “net” INSTALLL ISO, NOW YOU ARE READY TO BURN THE ISO TO A JUMP DRIVE.
BEFORE INSTALLING THE USB DRIVE, DO A “lsblk” TO SEE YOUR MAIN HDD DEVICE NAME. USUALLY WILL SHOW UNDER /sda1/
lsblk
NOW INSTALL THE USB DRIVE AND CHECK AGAIN TO SEE WHAT THE USB STICK DRIVE NUMBER IS. MOST ALWAYS IT WILL SHOW UNDER /sdb1/
lsblk
THEN MOVE TO THE “Downloads” FOLDER WHERE YOUR ISO IS LOCATED.
cd Downloads
THEN CHECK TO SEE IF THE ISO IS IN THE FOLDER YOU ARE IN
ls
YOU SHOULD SEE THE OUTPUT WITH SOMETHING SIMILAR TO THE FOLLOWING, THIS EXAMPLE IS DEBIAN 10 BUSTER 64BIT NET INSTALL ISO:
debian-10.8.0-amd64-netinst.iso
IF THE ISO IS THERE, THEN YOU ARE READY TO BURN TO USB STICK USING DD. THE DEBIAN 11 ISO IMAGE NAME WILL BE SIMILAR TO WHAT IS BELOW. JUST MAKE SURE THE CORRECT ISO NAME IS USED. THE EXAMPLE BELOW IS DEBIAN 11 BULLSEYE 32BIT NET INSTALL. JUST REPLACE THE “GREEN” SECTION WITH YOUR ISO NAME.
sudo dd bs=4M if=Debian-10.11.0-i386-netinst.iso of=/dev/sdb oflag=sync
AFTER “DD” IS FINISHED, THEN THE USB STICK IS READY TO INSTALL DEBIAN ON THE TARGET CNC COMPUTER.
YOU NEED INTERNET AT THIS POINT, AND WIRED ETHER IS A MUST FOR THESE INSTRUCTIONS. IF YOU HAVE A WIRELESS MIFI WITHOUT ANY TYPE OF WIRED CONNECTION, LET ME KNOW AND I WILL TELL YOU WHAT YOU NEED TO MAKE THIS WORK.
UNLESS SOMETHING HAS CHANGED IN THE LAST FEW YEARS, LINUXCNC ONLY USES “1” CPU CORE… LCNC CHANGES CONSTANTLY, SO IF THIS IS DIFFERENT LET ME KNOW SO I CAN REVISE THIS. BEFORE INSTALLING THE OS, I LIKE TO GO AHEAD AND SET THE NUMBER OF CORES TO “1” IN BIOS BEFORE STARTING THE BUILD SO I DON’T FORGET… PLUS C-STATES, LEGACY, AND FEW OTHER THINGS IN THE BIOS WHILE THERE.
NOW GO TO THE COMPUTER YOU ARE INSTALLING THE SYSTEM ON, THEN STARTUP AND HIT F2 TO GET IN THE BIOS SETUP
f2
WHEN YOU GET INTO THE BIOS SCREEN, FIND WHERE THE CPU NUMBER OF CORES SECTION IS LOCATED AND SET IT TO “1” CORE, THIS IS USUALLY UNDER “Performance” THEN “Multi Core Support”. THEN SAVE AND EXIT.
DURING RE-BOOT HIT F12 TO GET THE BOOT LIST SCREEN. THEN CHOOSE THE “USB Storage Device” UNDER LEGACY BOOT.
f12
WHEN INSTALLING THE OS, SCROLL DOWN TO THE “Advanced options” – THEN SCROLL DOWN TO “Expert install” AND START THE INSTALL.GO THROUGH AND DO THE BASIC INSTALL, BUT DURING THE SECTION FOR “Set up Users and passwords” MAKE SURE TO CHOOSE “No” WHEN IT ASK FOR “Allow login as root”. CHOOSE “No” AND JUST SKIP THROUGH THIS PART SO YOU HAVE “sudo” RIGHTS. IN OTHER WORDS, DO NOT SETUP A “root” ACCOUNT.DURING THE “Configure the package manager” SECTION, WHEN IT ASK “Use non-free firmware” CHOOSE “Yes”, AND WHEN IT ASK “Use non-free software” CHOOSE “Yes”, AND WHEN IT ASK “Enable source repositories in APT” CHOOSE IT.DURING THE “Select and Install software” SECTION, CHOOSE “No automatic updates” WHEN PROMPTED. THEN, WHEN “tasksel” COMES UP, UNCHECK ALL OF THE BOXES FOR “Debian desktop environment”, “GNOME”, AND “standard system utilities”. THIS GIVES A NICE MINIMAL INSTALL WITH ONLY 9 PACKAGES OTHER THAN THE BASE SYSTEM. NO DESKTOP OR GUI… BUT YOU WILL INSTALL THAT VERY SOON.
ONCE YOU HAVE DEBIAN INSTALLED AND HAVE BOOTED UP THE COMPUTER AGAIN, BRING THE MACHINE UP TO DATE WITH THE LATEST PACKAGES. (FOR BUSTER AND OLDER YOU MAY NEED TO DO “apt-get” FOR EVERYTHING BELOW.)
sudo apt update
sudo apt dist-upgrade
INSTALL THE PREEMPT-RT KERNEL AND MODULES
(USE THIS FOR 64 BIT) sudo apt install linux-image-rt-amd64
(USE THIS FOR 32 BIT) sudo apt install linux-image-rt-686-pae
NEXT INSTALL THE KERNEL HEADERS
(USE THIS FOR 64 BIT) sudo apt install linux-headers-rt-amd64
(USE THIS FOR 32 BIT) sudo apt install linux-headers-rt-686-pa
AFTER HEADERS FINISH, THEN REBOOT
sudo reboot
ONCE COMPUTER IS BOOTED AND READY, CHECK THAT THE RT KERNEL IS INSTALLED. YOU WILL SEE “PREEMPT_RT” IN PART OF THE FULL NAME.
uname -a
THEN REMOVE THE OLD KERNELS BY FINDING THEIR NAME WITH GREP
dpkg --list | grep linux-image
THEN PURGE EACH OF THEM WITH THE FOLLOWIING
sudo apt --purge remove linux-image-(THE REST OF THE KERNEL NAME FROM GREP)
THEN REBOOT
sudo reboot
ONCE REBOOTED, THEN ADD THE WINDOW MANAGER AND GUI. MY TWO CHOICES FOR A LIGHTWEIGHT GUI ARE “xfce” AND “lxqt”. FOR THIS INSTALL I AM USING THE BASIC “lxqt-core” VERSION SINCE LINUXCNC IS STARTING TO USE “QT” MORE. “lxqt-core” CAN BE STRIPPED DOWN EVEN FURTHER IF YOU TAKE THE TIME WITH SWITCHES. (664 PACKAGES FOR BULLSEYE / 1,324 FOR BOOKWORM)
sudo apt install sddm lxqt-core
THEN REBOOT TO GET THE GUI UP
sudo reboot
THE LOGIN SCREEN SHOULD COME UP SO THAT YOU CAN LOGIN AND START THE GUI… YOU MAY NEED TO RE-BOOT IN ORDER TO GET THE SDDM PICKER UP SO YOU CAN CHOOSE THE LXQT DESKTOP AND GET THE GUI STARTED (BULLSEYE). YOU MAY WANT TO REBOOT AGAIN TO MAKE SURE ALL IS GOOD AND WORKING WITH LXQT DESKTOP.
ONCE THE GUI IS WORKING, THEN OPEN A COMMAND LINE AND ENABLE AUTOLOGIN USING PICO TO MODIFY THE CONF FILE SO YOU DON’T HAVE TO KEEP LOGGING IN EACH TIME.
sudo pico /etc/sddm.conf
ADD THE FOLLOWING:
[Autologin]
User=robert (PUT YOUR USER NAME, NOT MINE)
Session=lxqt.desktop
Relogin=false
THEN SAVE AND EXIT PICO WITH “ctl o” AND “ctl x”.
ctl o
ctl x
BOOT, LINUX SHOULD START UP WITHOUT HAVING TO LOGIN WITH USERNAME AND PASSWORD. THIS SAVES TIME.
THIS COMPLETES PART 1 OF GETTING THE REALTIME OS READY FOR THE LINUXCNC BUILD
PART 2A - LINUXCNC BUILD FROM SOURCE (RUN IN PLACE)
LinuxCNC 2.9 will only run on Debian 11 or newer
IF YOU DID REBOOT, THEN OPEN A COMMAND LINE WINDOW.
INSTALL THE BUILD PACKAGES
sudo apt install git build-essential
CLONE THE LINUXCNC SOURCE CODE
git clone github.com/LinuxCNC/linuxcnc.git linuxcnc-dev
MOVE TO LINUXCNC-DEV FOLDER
cd linuxcnc-dev
CHANGE TO VERSION YOU WANT TO BUILD (FOR ME 2.9= QTDRAGON_HD)
git checkout 2.9
CHANGE TO DEBIAN FOLDER
cd debian
THEN CONFIGURE
./configure uspace
THEN MOVE BACK TO THE LINUXCNC-DEV FOLDER
cd ..
CHECK FOR ANY MISSING BUILD DEPENDENCIES (THER WILL BE SERVERAL PACKAGES TO INSTALL. JUST COPY SELECTION AND PASTE TO SAVE ALL THAT TYPING, OTHERWISE JUST TAKE TIME AND TYPE THEM ALL OUT)
dpkg-checkbuilddeps
COPY/PASTE THE LIST OF BUILD DEPPENDENCIES THEN INSTALL WITH
sudo apt-get install "LIST OF DEPS COPIED FROM DPKG-CHECKBUILDDEPS"
INSTALL ALL OF THE PACKAGES NEEDED, THEN CHECK DEPS AGAIN
dpkg-checkbuilddeps
ONCE ALL THE DEPENDENCIES HAVE BEEN INSTALLED THEN MOVE TO THE SOURCE FOLDER
cd src
THEN AFTER GETTING INTO SRC FOLDER
./autogen.sh
THEN CONFIGURE
./configure --with-realtime=uspace
THEN MAKE
make
ALLOW ACCESS TO HARDWARE
sudo make setuid
SETUP RIP ENVIRONMENT
. ../scripts/rip-environment
START UP LINUXCNC
linuxcnc
WHEN THE LINUXCNC CONFIGURATION BOX APPEARS, THE “axis” SIM WILL ALREADY BE HIGHLIGHTED. CHOOSE THIS HIGHLIGHTED “axis” CONFIG AND ALSO CHECK THE BOX BELOW THAT HAS “Created Desktop Shortcut”. WHEN YOU CLICK “ok” IT WILL TRY TO START UP LINUXCNC BUT IT WILL FAIL IF USING LCNC2.9 OR MASTER AS THE BELOW QTVCP PACKAGES HAVE NOT BEEN INSTALLED YET. DON’T CLOSE OUT THE COMMAND LINE, JUST KEEP GOING BELOW FOR THE SCRIPT.
PART 2B – QTVCP PACAKAGES FOR DRAGONHD – RIP
IF YOU DID CLOSE OUT THE COMMAND LINE FOR SOME REASON, GO RUN THE LINUXCNC SCRIPT TO GET THE FOLDERS OPEN BEFORE STARTING THE QTVCP BUILD.
IF YOUR COMMAND LINE IS STILL OPEN, THEN JUST SKIP DOWN PAST THIS AND START THE QTVCP SCRIPT.
FOR THE LINUXCNC SCRIPT:
MOVE TO THE LINUXCNC SOURCE FOLDER
cd /linuxcnc-dev/src/
RUN THE LINUXCNC SCRIPT
. ../scripts/rip-environment
<<<START HERE FOR THE QTVCP SCRIPT>>>
START THE QTVCP SCRIPT FOR THE INSTALLATION
~/linuxcnc-dev/lib/python/qtvcp/designer/install_script
CHOOSE #2 WHEN PROMPTED FOR THE RIP INSTALL. AFTER THIS IS INSTALLED, LINUXCNC WILL START UP AND WORK.
2
AS A SIDE NOTE, QTDRAGON_HD WILL WORK AT THIS POINT.
THIS COMPLETES PART 2 AND HAS LINUXCNC SETUP READY TO PUT THE ETHERCAT MASTER ON NEXT.
PART 3 GETTING ETHERCAT INSTALLED FROM SOURCE
IF YOU DID CLOSE OUT THE COMMAND LINE FOR SOME REASON, GO RUN THE LINUXCNC SCRIPT TO GET THE FOLDERS OPEN BEFORE STARTING THE QTVCP BUILD.
IF YOUR COMMAND LINE IS STILL OPEN, THEN JUST SKIP DOWN PAST THIS AND START THE ETHERCAT INSTALL.
FOR THE LINUXCNC SCRIPT:
MOVE TO THE LINUXCNC SOURCE FOLDER
cd /linuxcnc-dev/src/
RUN THE LINUXCNC SCRIPT
. ../scripts/rip-environment
<<<START HERE FOR THE ETHERCAT INSTALL>>>
CHANGE BACK TO HOME FOLDER
cd ..
cd ..
ONCE BACK IN THE HOME FOLDER, CLONE THE ETHERCAT REPOSITORY. JUST MAKE SURE YOU ARE IN THE HOME FOLDER AND NOT IN ANOTHER LOCATION SO THAT THE “ethercat-master” FOLDER IS CREATED IN THE CORRECT LOCATION.
git clone gitlab.com/etherlab.org/ethercat.git ethercat-master
CHANGE TO THE ETHERCAT FOLDER
cd ethercat-master
CHANGE TO THE STABLE BRANCH
git checkout stable-1.5
BUILD THE SOFTWARE AS REGULAR USER, NOT AS ROOT
BOOTSTRAP
./bootstrap
GET ETHERNET INFOMATION
sudo lspci -v
Example: My network is Intel Pro/100, Kernel driver in use: e1000e (I USED GENERIC THOUGH)
CONFIGURE TO THE TYPE OF MODULE NEEDED
./configure --sysconfdir=/etc/ --disable-8139too --enable-userlib --enable-generic
THEN MAKE WITH MODULES
make all modules
THEN INSTALL THE SOFTWARE AS ROOT
BECOME ROOT
sudo su
INSTALL THE SOFTWARE AS ROOT
make modules_install install
DEPENDENCY MODULES COMMAND
depmod
EXIT ROOT
exit
THEN GET SERVICE WORKING
GET ETHER ADDRESS – WRITE DOWN OR COPY & PASTE THE MAC ADDRESS
ip a
OPEN PICO AND ADD YOUR ETH0 ADDRESS
sudo pico /etc/ethercat.conf
ONCE THE FILE IS OPEN, SET YOUR MASTER0 DEVICE TO YOUR MAC ADDRESS AND DEVICE MODULES TO GENERIC. SCROLL DOWN UNTIL YOU SEE THESE TWO PARTS. (THEY ARE NOT TOGETHER, BUT SEPARATED THROUGHOUT THE CODE
MASTER0_DEVICE="a1:b2:c3:d4:e5:f6" (WHATEVER YOUR MAC ADDRESS IS)
DEVICE_MODULES="generic"
THEN SAVE AND EXIT PICO WITH “ctl o” AND “ctl x”.
ctl o
ctl x
*SIDE NOTE*: DO NOT DO THE CREATE RULES AS SHOWN ON THE IgH SITE.. IT WILL CAUSE THE SYSTEM TO MASK, DO NOT DO THE FOLLOWING COMMAND, JUST SHOWING YOU WHAT NOT TO DO.
echo KERNEL==\"EtherCAT[0-9]*\", MODE=\"0777\" > /etc/udev/rules.d/99-EtherCAT.rules
AFTER YOU HAVE EXITED PICO AND BACK ON THE COMMAND LINE
YOU MUST DO THE FOLLOWING AND NOT SKIP AS IT SYS-LINKS
ENABLE THE ETHERCAT SERVICE
sudo systemctl enable ethercat.service
START THE ETHERCAT SERVICE
sudo systemctl start ethercat.service
CHECK THE ETHERCAT STATUS
sudo systemctl status ethercat.service
CHANGE PERMISSIONS
sudo chmod 666 /dev/EtherCAT0
CHECK THAT ITS WORKING WITH.
ethercat master
YOU SHOULD SEE NUMBERS IN THE LINES, IF NOT AND IT’S ALL ZERO’S THEN SOMETHING IS NOT LINKED CORRECTLY IN ETHERCAT OR LINUX. MAKE SURE IT SHOWS A CHANGE AFTER DOING THE “ethercat master” COMMAND.
SETUP PERMISSION.
OPEN IN PICO TO GIVE ETHERCAT PORT STARTUP PERMISSION
sudo pico /etc/udev/rules.d/99-ethercat.rules
ONCE THE FILE IS OPEN, ADD THE FOLLOWING:
KERNEL=="EtherCAT[0-9]", MODE="0777"
THEN SAVE AND EXIT PICO WITH “ctl o” AND “ctl x”.
ctl o
ctl x
ONCE BACK ON THE COMMAND LINE, THEN RELOAD THE RULES
sudo udevadm control --reload-rules
THIS COMPLETES PART 3 OF GETTING ETHERCAT INSTALLED AND WORKING
PART 4 - SETUP LINUXCNC-ETHERCAT DRIVER
IF YOU DID CLOSE OUT THE COMMAND LINE FOR SOME REASON, GO RUN THE LINUXCNC SCRIPT TO GET THE FOLDERS OPEN BEFORE STARTING THE QTVCP BUILD.
IF YOUR COMMAND LINE IS STILL OPEN, THEN JUST SKIP DOWN PAST THIS AND START THE ETHERCAT DRIVER BUILD.
FOR THE LINUXCNC SCRIPT:
MOVE TO THE LINUXCNC SOURCE FOLDER
cd /linuxcnc-dev/src/
RUN THE LINUXCNC SCRIPT
. ../scripts/rip-environment
<<<START HERE FOR THE ETHERCAT-DRIVER INSTALL>>>
CHANGE BACK TO HOME FOLDER
cd ..
cd ..
CLONE THE ETHERCAT REPOSITORY. JUST MAKE SURE YOU ARE IN THE HOME FOLDER AND NOT IN ANOTHER LOCATION SO THAT THE “linuxcnc-ethercat” FOLDER IS CREATED IN THE CORRECT LOCATION FOR THESE INSTRUCTIONS.
git clone github.com/sittner/linuxcnc-ethercat.git linuxcnc-ethercat
NOW MOVE TO THE “src” FOLDER IN THE “linuxcnc-ethercat” FOLDER.
cd /linuxcnc-ethercat/src
ONCE YOU ARE IN THE “src” FOLDER, NOW OVERWRITE THE “realtime.mk“ FILE WITH THE CODE THAT “STORMHOLT” PUT ON THE FORUM. OPEN THE FILE WITH PICO.
sudo pico realtime.mk
NOW THAT THE FILE IS OPEN IN PICO, YOU CAN REPLACE EVERYTHING WITH THE FOLLOWING BELOW: UNFORTUNATELY, YOU CAN’T CUT & PASTE IN PICO. I USUALLY GO PREPARE THE “realtime.mk” FILE IN ANOTHER LINUX COMPUTER AND SIMPLY REPLACE HERE. YOU COULD ADD THE “geany” PACKAGE TO DO THIS MUCH SIMPLER, BUT ONCE AGAIN I DON’T ADD EXTRA PACKAGES WHILE TRYING TO KEEP THE SYSTEM MINIMAL FOR A DEDICATED MACHINE.
_________________________________________________________________________________________________
include ../config.mk
include Kbuild
cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
> /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi
.PHONY: all clean install
ifeq ($(BUILDSYS),kbuild)
module = $(patsubst %.o,%.ko,$(obj-m))
ifeq (,$(findstring -Wframe-larger-than=,$(EXTRA_CFLAGS)))
EXTRA_CFLAGS += $(call cc-option,-Wframe-larger-than=2560)
endif
$(module):
$(MAKE) EXTRA_CFLAGS="$(EXTRA_CFLAGS)" KBUILD_EXTRA_SYMBOLS="$(RTLIBDIR)/Module.symvers $(RTAIDIR)/modules/ethercat/Module.symvers" -C $(KERNELDIR) SUBDIRS=`pwd` CC=$(CC) V=0 modules
clean::
rm -f $(obj-m)
rm -f *.mod.c .*.cmd
rm -f modules.order Module.symvers
rm -rf .tmp_versions
else
module = $(patsubst %.o,%.so,$(obj-m))
EXTRA_CFLAGS := $(filter-out -Wframe-larger-than=%,$(EXTRA_CFLAGS))
$(module): $(lcec-objs)
$(CC) -shared -o $@ $(lcec-objs) -Wl,-rpath,$(LIBDIR) -L$(LIBDIR) -llinuxcnchal -lethercat -lrt
%.o: %.c
$(CC) -o $@ $(EXTRA_CFLAGS) -Os -c $<
endif
all: $(module)
clean::
rm -f $(module)
rm -f $(lcec-objs)
install: $(module)
mkdir -p $(DESTDIR)$(RTLIBDIR)
cp $(module) $(DESTDIR)$(RTLIBDIR)/
_________________________________________________________________________________________________
ONCE THE “realtime.mk” FILE HAS BEEN REPLACED WITH THE ABOVE CODE, THEN SAVE AND EXIT PICO WITH “ctl o” AND “ctl x”.
ctl o
ctl x
AFTER SAVING AND EXITING PICO, MOVE TO THE LINUXCNC-ETHERCAT FOLDER
cd ..
MAKE SURE YOU ARE IN THE “linuxcnc-ethercat” FOLDER, THEN MAKE CLEAN
make clean
THEN MAKE THE PACKAGE
make
*NOTE*: IF YOU HAVE A FAIL ON THE MAKE, THEN GO BACK TO THE “linuxcnc-dev/src” FOLDER AND DO THE “. ../scripts/rip-environment” AGAIN AND START LINUXCNC TO GET THE FILES LOADED
THEN DO THE INSTALL
make install
EDIT THE FILE /etc/ld.so.conf AND ADD YOUR PATH
sudo pico /etc/ld.so.conf
ONCE THE FILE IS OPEN IN PICO, ADD THE FOLLOWING DOWN BELOW THE “INCLUDE” LINE
/usr/local/lib
ONCE THE ABOVE HAD BEEN ADDED,
THEN SAVE AND EXIT PICO WITH “ctl o” AND “ctl x”.
ctl o
ctl x
AFTER SAVING AND EXITING PICO, CHANGE TO ROOT
sudo su
LOAD THE LIBRARY
ldconfig -v
EXIT ROOT
exit
EVEN THOUGH IT LOOKS LIKE YOU SHOULD DO SOMETHING ELSE FOR THE INSTALL, YOU ARE FINISHED AND EVERYTHING SHOULD BE WORKING. NOW IT IS TIME TO GO MAKE AN AXIS CONFIG AND ADD THE ETHERCAT XML FILE TO GET IT ALL LINKED AND A WORKING SYSTEM.
THIS COMPLETES PART 4 OF GETTING ETHERCAT DRIVER INSTALLED
PART 5 - SETUP LINUXCNC AND XML
THE FOLLOWING INFO IS MUCH EASIER TO UNDERSTAND IF YOU ARE VERSE WITH LINUXCNC. SHOULD YOU GET LOST OR CONFUSED, DON’T HESISTATE TO REACH OUT TO ONE OF US ON THE FORUM AND WE WILL HELP YOU GET YOUR CONFIG WORKING. WHEN I GET TIME, I WILL MAKE MORE DETAILED INSTRUCTIONS ON HOW TO SET EVERTHING UP FOR THE NON-LCNC USER.
SETTING UP THE XML FILE
THERE ARE SEVERAL EXAMPLES ON THE WEB, BUT YOU SIMPLY PUT THE FOLLOWING CODE IN A PLAIN TEXT FILE AND RENAME IT “ethercat-conf.xml”. THEN PLACE THE XML FILE IN YOUR /linuxcnc-dev/configs FOLDER.<masters>
<master idx="0" appTimePeriod="1000000" refClockSyncCycles="1">
<slave idx="0" name=”D1” type="EK1100"/>
</master>
</masters>
WITH THE ABOVE CODE YOU CAN GET LINUXCNC WITH ETHERCAT TO STARTUP AND WORK EVEN IF YOU DO NOT HAVE A BECKHOFF EK1100 COUPLER OR ANY OTHER ETHERCAT HARDWARE. THIS HELPS YOU LEARN A GOOD BIT BEFORE INVESTING IN HARDWARE.
IF YOU HAVE A EK1100 COUPLER AND OTHER BECKHOFF TERMINALS, YOU WILL NEED TO MAKE YOUR XML MATCH WHAT YOU HAVE FOR THE PHYSICAL HARDWARE. MY RECOMMENDATION IS TO GET EVERYTHING WORKING WITH THE EK1100 ONLY AND THEN ADD 1 TERMINAL SLICE AT A TIME, WHILE RE-WORKING YOUR XML UNTIL YOU GET THE HANG OF GETTING IT WORKING… THEN IN THE FUTURE YOU CAN JUST BUILD THE XML TO WHAT YOU HAVE FOR EQUIPMENT.
ONE THING TO KEEP IN MIND, IF YOU HAVE A “BAD” BECKHOFF TERMINAL PIECE SUCH AS LET SAY A EL2008, WHEN YOU TRY TO START UP LINUXCNC IT WILL FAIL AND DEFINITELY CONFUSE YOU ON WHAT IS WRONG. THAT IS A GOOD REASON TO ADD 1 TERMINAL SLICE AT A TIME IF YOUR PARTS ARE USED FROM EBAY OR OTHER SOURCES, JUST IN CASE YOU HAVE A BAD NON-WORKING PIECE.
SETTING UP LNUXCNC
ONCE YOU HAVE YOUR XML SETUP AND IN PLACE, THEN YOU SIMPLY NEED TO MAKE A LINUXCNC “axis” CONFIG AND ADD THE ETHERCAT CODE TO YOUR “hal” FILE. FOR SIMPLICITY, YOU CAN ALSO ADD THE CODE TO YOUR “postgui.hal” FILE AS THIS WILL WORK AND GET LINUXCNC TO STARTUP.
ONCE YOU FIGURE OUT HOW IT WORKS, YOU CAN MOVE THE CODE TO YOUR MAIN “hal” FILE AS YOU LIKE. WHEN MOVING THE CODE TO YOUR OTHER “hal” FILE, MAKE SURE TO FOLLOW LINUXCNC/C RULES AND PUT THE COMPONENTS AND FUNCTIONS IN THE CORRECT PLACES. DON’T FORGET TO CORRECT THE FILE NAME MARKED IN RED BELOW TO YOUR CORRECT NAME.
loadusr -W lcec_conf /home/NAME/linuxcnc-dev/configs/ethercat-conf.xml
loadrt lcec
addf lcec.read-all servo-thread
addf lcec.write-all servo-thread
net ec-slaves-responding lcec.slaves-responding
net ec-link-up lcec.link-up
net ec-all-op lcec.all-op
ONCE YOU HAVE A CONFIGURATION WORKING WHERE LINUXCNC AXIS STARTS UP WITHOUT FAILING, YOU CAN CHECK TO SEE IF ETHERCAT (lcec) IS WORKING BY CLICKING ON THE “Machine” TAB AT THE TOP, THEN FROM THE DROP DOWN MENU CLICK ON “Show Hal Configuration”, THEN THE “Hal Show” BOX WILL APPEAR. LOOK ON THE LEFT SIDE AND CLICK ON THE “Pins” TAB, WHEN THE LIST DROPS DOWN YOU WILL SEE “lcec”. WHEN YOU CLICK ON “lcec” THE HALSHOW BOX WILL SHOW ALL OF THE ETHERCAT (lcec) PIN INFO. JUST SEEING “lcec” ALONE TELLS YOU THAT YOU HAVE IT FULLY INSTALLED AND WORKING. IF “lcec” IS NOT IN THE “Pins” LIST, THEN YOU HAVE SOMETHING WRONG. FIRST, IF YOU ARE ABLE TO SEE YOUR TERMINALS WITH “ethercat slaves”, THEN IT IS MOST LIKELY THAT THE “linuxcnc-ethercat” BUILD DID NOT FULLY BUILD CORRECTLY, SO JUST GO TRY INSTALLING THAT PART AGAIN AND THEN RE-TRY EVERYTHING. IF IT WAS THE ETHERCAT BUILD, THEN ONCE YOU GET IT BUILT CORRECTLY, LINUXCNC WILL THEN SHOW THE (lcec) UNDER PINS SECTION. THIS IS THE FASTEST WAY TO GET IT ALL DIAGNOSED AND WORKING.
PART 6 - LET’S SEE ETHERCAT WORK IN THE REAL WORLD .
LET’S ADD A REAL PHYSICAL EXTERNAL “EMERGENCY STOP” BUTTON WIRED TO A EL1008 FOR INPUT TO LINUXCNC.
(WITH POWER OFF) ADD THE BECKHOFF EL1008 TERMINAL TO YOUR EK1100 COUPLER. NEXT, WIRE YOUR EMERGENCY STOP BUTTON LOOPED FROM +24v POWER TO THE EL1008 TERMINAL INPUT-1. NEXT YOU NEED TO RE-WORK YOUR XML FILE AND ADD THE EL1008 TERMINAL. MAKE YOUR CODE LOOK LIKE BELOW BY ADDING THE SECTION IN “BLUE” THEN SAVE THE FILE:
<masters>
<master idx="0" appTimePeriod="1000000" refClockSyncCycles="1">
<slave idx="0" name=”D1” type="EK1100"/>
<slave idx="1" name=”D2” type="EL1008"/>
</master>
</masters>
ONCE YOUR XML FILE IS RE-WORKED AND YOU ARE ABLE TO START UP LINUXCNC WITHOUT IT FAILING, THEN YOU ARE READY TO WRITE MORE ETHERCAT CODE TO YOUR “postgui.hal” FILE.
BEFORE GOING TO THE “postgui.hal” FILE, YOU MUST FIND THE FOLLOWING CODE SECTION IN THE “core.hal” FILE OR WHICHEVER “hal” FILE IT IS LOCATED IN.
net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
NOW LET COMMENT OUT THE LINE WITH ADDING # AT THE BEGINNING.
# net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
NOW LET’S WRITE ONE ETHERCAT PIN TO YOUR “postgui.hal” FILE. YOU WILL ONLY ADD ONE LINE TO THE PREVIOUS CODE AND IT MUST BE BELOW ALL OF THE PREVIOUS CODE. MAKE YOUR CODE LOOK LIKE BELOW BY ADDING THE SECTION IN “BLUE” THEN SAVE THE FILE AND START LCNC. DON’T FORGET TO CHANGE THE “NAME” IN RED JUST LIKE YOU DID BEFORE.
loadusr -W lcec_conf /home/NAME/linuxcnc-dev/configs/ethercat-conf.xml
loadrt lcec
addf lcec.read-all servo-thread
addf lcec.write-all servo-thread
net ec-slaves-responding lcec.slaves-responding
net ec-link-up lcec.link-up
net ec-all-op lcec.all-opnet voltage-on iocontrol.0.emc-enable-in lcec.0.D2.din-0
NOW START UP LINUXCNC AND OPERATE THE E-STOP TO SEE IF IT CHANGES ON THE SCREEN. IF EVERYTHING IS CORRECT, YOU SHOULD SEE IT OPERATE IN THE LINUCNC WINDOW. IF IT DOES NOT WORK, TRY USING THE MOUSE AND CLICKING THE E-STOP TO SEE IF IT WORKS. IF IT WORKS BY THE MOUSE AND NOT THE PHYSICAL BUTTON, THEN YOU DID NOT GET THE CODE CORRECT
IF FOR SOME REASON THAT LINUXCNC FAILS TO START, BACKTRACK BY REMOVING THE TERMINAL AND CHANGE YOUR XML BACK TO MAKE SURE YOU CAN GET LINUXCNC TO START AGAIN WITH JUST THE EK1100 COUPLER, IF SO, THEN DOUBLE CHECK THE XML CODE AND THAT YOU SAVED THE FILE… THEN DOUBLE CHECK THAT YOU HAVE A GOOD TERMINAL THAT IS NOT A DEFECTIVE BAD UNIT.
<<<ADDING SOME MORE ETHERCAT PINS>>>
HERE IS SOME EXTRA CODE TO ADD COMBINED HOME/LIMIT SWITCHES TO THAT SAME EL1008 THAT YOU WIRED YOUR E-STOP SWITCH INTO. SAME CONCEPT AS THE E-STOP, JUST LOOP YOUR +24v POWER TO THE SWITCH AND THEN YOU CAN WIRE THEM INTO THE EL1008 INPUT-2 & INPUT-3 CONNECTIONS FOR USING THE CODE BELOW:
net both-home-x => joint.0.neg-lim-sw-in joint.0.home-sw-in <= lcec.0.D2.din-1
net both-home-z => joint.2.pos-lim-sw-in joint.2.home-sw-in <= lcec.0.D2.din-2
<<<ADDING EXTERNAL PENDANT PUSH BUTTONS WITH ETHERCAT>>>
HERE IS SOME EXTRA CODE TO ADD EXTERNAL PHYSICAL PUSH BUTTON SWITCHES FOR YOUR PENDANT TO THAT SAME EL1008 THAT YOU WIRED YOUR E-STOP SWITCH INTO. SAME CONCEPT AS THE E-STOP & LIMIT SWITCHES, JUST LOOP YOUR +24v POWER TO THE SWITCH AND THEN YOU CAN WIRE THEM INTO THE EL1008 INPUT-2 & INPUT-3 CONNECTIONS FOR USING THE CODE BELOW, JUST ADD BELOW ALL THE OTHER CODE IN YOUR “postgui.hal”:
net jog-speed halui.jog-speed
net remote-jog-x-plus halui.jog.0.plus lcec.0.D2.din-3
net remote-jog-x-minus halui.jog.0.minus lcec.0.D2.din-4
<<<ADDING OUTPUT WITH EL2008>>>
DON’T FORGET IF YOU ADD ANOTHER BECKHOFF TEMINAL SUCH AS A EL2008, THEN YOU NEED TO NOT ONLY ADD THE “pins” IN YOUR “hal” FILE, YOU ALSO NEED TO RE-WORK THE “xml” FILE TO ADD THE “slave”.
LET’S ADD A EL2008 AND THEN SET IT UP FOR OUTPUTTING TO A RELAY OR SOME OTHER FUNCTION. YOU WILL NEED TO GO FIND THIS CODE MARKED IN "GREEN" IN YOUR OTHER HAL FILES, AS IF YOU PUT THIS IN YOUR “postgui.hal” IT WILL MOST LIKELY FAIL AS YOU WOULD HAVE THE “net & motion” CODE ALREADY LINKED IN ANOTHER “hal” FILE. SIMPLY ADD THE "lcec" CODE BELOW MARKED IN "BLUE"
net spindle-on <= motion.spindle-on => lcec.0.D3.dout-0
net spindle-cw <= motion.spindle-forward => lcec.0.D3.dout-1
net spindle-ccw <= motion.spindle-reverse => lcec.0.D3.dout-2
net spindle-brake <= motion.spindle-brake => lcec.0.D3.dout-3
NEXT YOU NEED TO RE-WORK YOUR XML FILE AND ADD THE EL2008 TERMINAL. MAKE YOUR CODE LOOK LIKE BELOW BY ADDING THE SECTION IN “BLUE” THEN SAVE THE FILE:
<masters>
<master idx="0" appTimePeriod="1000000" refClockSyncCycles="1">
<slave idx="0" name=”D1” type="EK1100"/>
<slave idx="1" name=”D2” type="EL1008"/>
<slave idx="2" name=”D3” type="EL2008"/>
</master>
</masters>
OK, IF YOU MADE IT TO THIS POINT, THEN CONGRADULATIONS ON GETTING LINUXCNC WITH ETHERCAT WORKING. I LOST PART OF MY LIFE YEARS AGO GETTING THIS ALL FIGURED OUT, HOPEFULLY THESE INSTRUCTIONS WERE NOT TOO CONFUSING AND YOU DID THIS PRETTY QUICK. NOW YOU CAN MOVE ON TO THE NEXT LEVEL WITH LCNC… HAPPY MACHINING!!! (CORBETT)
Please Log in or Create an account to join the conversation.
THEY SHOULD BE THIS EACH TIME
I WILL CORRECT WHEN I HAVE TIME
PLUS THERE ARE OTHER ERRORS SUCH AS THIS
net ec-all-op lcec.all-opnet voltage-on iocontrol.0.emc-enable-in lcec.0.D2.din-0
SHOULD BE THIS:
net ec-all-op lcec.all-op
net voltage-on iocontrol.0.emc-enable-in lcec.0.D2.din-0
Attachments:
Please Log in or Create an account to join the conversation.
Everything has moved forward at a great rate and linuxcnc users have always been working with experimental or out of tree code to use ethercat. That is now stabilising. The good thing is there is a lot of shortcuts available now in terms of installing linuxcnc on Bullseye and Bookworm so compiling from source may not be required but such is the complexity of ethercat, building linuxcnc from source should be a prerequisite!
Here are a few notes to consider
Choosing a version of Debian
The Linuxcnc ISO on the forum is using Debian Buster which is depreciated. (Debian 10). The current version is Debian Bookworm (Debian 12)
Corbett suggests ethercat users use Debian 11 (Bullseye) or above. However until recently, there was no buildbot for Bullseye so this implied Linuxcnc had to be built from source. A simpler approach would be to folow the v 2.9 Getting Linuxcnc documents and install Bookworm (Debian 12). linuxcnc.org/docs/2.9/html/getting-start...etting-linuxcnc.html Then building from source becomes optional but definitely encouraged for anybody considering installing ethercat.
Here is a video tutorial for building linuxcnc
But for the lazy, here are some shortcuts to avoid compiling from source
I already have Debian 11 (or 10) installed
Thats completely fine if you wish to continue using it.
Simply follow Step #9 in the bookworm docs linuxcnc.org/docs/2.9/html/getting-start...an_bookworm_x86_only
and replace the line starting with echo with:
For Buster - Debian 10
sudo echo "deb buildbot2.highlab.com/debian/ buster 2.9-uspace" | sudo tee -a /etc/apt/sources.list.d/linuxcnc.list
For Bullseye - Debian 12
sudo echo "deb buildbot2.highlab.com/debian/ bookworm 2.9-uspace" | sudo tee -a /etc/apt/sources.list.d/linuxcnc.list
[/b]But I want to use Linuxcnc master (V2.10)[/b]
Sure. JUst use master-uspace instead of 2.9-uspace as follows:
sudo echo "deb buildbot2.highlab.com/debian/ bookworm master-uspace" | sudo tee -a /etc/apt/sources.list.d/linuxcnc.list
When done, to get the latest version of linuxcnc you chose, remember to:
sudo apt update
sudo apt upgrade
Why would I install Ethercat from repositories?
Because its easier!
Because after a period of instability, the current method in this thread uses the final etherlabmaster repositories that were released in August 2023. This thread outlines how to install them
forum.linuxcnc.org/ethercat/45336-etherc...-how-to-step-by-step
The etherlabmaster team is exploring submiting these to the Debian repositories
However there are some restrictions where buiding from source is required:
There are no ethercat .debs for arm64 (eg Raspberry pi 4b)
Only the generic network driver is installed. Some higher performance network drivers are available if built from source.(Ethercat uses its own custom network drivers when communicating with slaves)
Regardless of if you build from source or take some of the shortcuts above, the first post here outline in detail how to get ethercat devices working with linuxcnc. Be sure to follow it.
Please Log in or Create an account to join the conversation.
@tommy (or another mod) could you sticky this thread please? It's a gold mine of info!
Please Log in or Create an account to join the conversation.
- tommylight
- Online
- Moderator
- Posts: 19188
- Thank you received: 6429
Done.@tommy (or another mod) could you sticky this thread please? It's a gold mine of info!
Please Log in or Create an account to join the conversation.
Thanks, Tommy, I added some notes in the third post here.
@tommy (or another mod) could you sticky this thread please? It's a gold mine of info!
Done.
Please Log in or Create an account to join the conversation.
- tommylight
- Online
- Moderator
- Posts: 19188
- Thank you received: 6429
Please Log in or Create an account to join the conversation.
- Sakhalin_Cat
- Offline
- Junior Member
- Posts: 22
- Thank you received: 7
My machine for EtherCat has an Intel PRO 1000 network card installed. The card is registered as “generic” in the EtherCat-Master settings. When the LCNC works with the EtherCat driver, short-term freezes constantly appear.
I found a description of this problem on the forums and people refer to the fact that the GENERIC driver does not work quite correctly with the Intel board, and therefore for normal operation it is necessary to use the Intel driver.
I tried to compile the EtherCat-Master driver with the key - ./configure --sysconfdir=/etc/ --enable-userlib --enable-e1000 --enable-e1000e and it didn’t work this for me.
I get the answer: "checking for kernel for e1000 driver... configure: error: kernel 6.1 not available for e1000 driver!"
I built a new kernel where I included the driver inside the kernel and still get this response. I tried to compile by changing kernels and using different ./configure options - the result was negative, I cannot use the e1000 driver.
Please tell me, is it even possible to use the described driver in this version of EtherCat-Master? If possible, please point out my mistake.
Thank you.
-
After carefully studying the source catalog, I realized that EtherCat-Master does not contain ready-made drivers for kernels older than 4.4 for my adapter. And you need to change the Ethernet card to 8139 or write the driver yourself.
Sorry to bother you.
Please Log in or Create an account to join the conversation.
gitlab.com/etherlab.org/ethercat/-/issues/60
I would raise an issue there as I have found them very helpful
Please Log in or Create an account to join the conversation.
- Sakhalin_Cat
- Offline
- Junior Member
- Posts: 22
- Thank you received: 7
Hello.This issue indicates the e1000 is too old for modern kernels
gitlab.com/etherlab.org/ethercat/-/issues/60
I would raise an issue there as I have found them very helpful
Today I specifically purchased a board with an 8139D chip to run the system with it. I was disappointed, because again I could not compile the Etherkat driver for it. This card has support in the source codes - "DEVICE" catalog, but it was not possible to compile the driver. The option to install DKMS via APT also failed to compile the drivers. Only generic driver works.
I cannot write to the authors using the link you suggested, since I cannot register on this site, although I have studied this correspondence very carefully.
Maybe you can raise this issue on GITLAB? Can the authors make a driver for any popular network card that can always be bought in a store so that there is support in modern kernels? The GENERIC driver works, but causes the system to freeze regularly, which does not have a very good effect on operation. I changed several network cards but the result is sad, freezing remains. If you unload the ezerkat driver, the system works stably without any complaints. A special driver for the adapter is required, but there is nowhere to get it. Alas.
Thank you for your attention and understanding.
Please Log in or Create an account to join the conversation.