Ethercat installation from repositories - how to step by step
13 Mar 2022 11:12 - 26 Aug 2023 06:05 #237098
by rodw
UPDATE: 26 August 2023 do include deb files for the linuxcnc-ethercat driver
Ethercat installation instructions from repositories that are maintained by the IgH Etherlabmaster team
If installing on a new PC, Grab my Linucnc live installler which includes the required third party repositories pre installed.
drive.google.com/file/d/16nprK_5HeURoNGd.../view?usp=drive_link
This will let you install all required software with one line of code and skip most steps that follow
open the spoiler if you wish to do it manually
Open a terminal and type the followingFetch the GPG key
## for Bookworm Debian 12
Create an ethercat sources file
Paste in the following, save and exit geanyupdate the sources list
If you have UEFI (Secure boot) on your PC with the preempt_rt kernel (installed with linuxcnc) you need to do a bit more work
If you have Secure Boot enabled (can be checked with mokutil --sb-state), some extra steps may be needed. AFAIK, the DKMS modules are signed with a generated key (/var/lib/dkms/mok.pub), this key needs to be enrolled as a Machine Owner Key (MOK).on the General settings tab add the following to the kernel parametersreboot and enter these commands. Do not forget the passwordreboot again. This time the MOK Management Utility is used to enroll the key into the EFI environment.
Select enrol MOK from this menu, enter your password and answer the questions. (Some help prompts are displayed at the top of the screen)
After that, a SecureBoot-Enabled PREEMPT_RT Kernel is able to load DKMS modules.
Install the headers and the ethercat master
Install the repository and driver
If you want to build the linuxcnc-ethercat driver yourself, open the spoiler and follow the instructions
clone my repository
Check the NIC you are using for ethercatSave the MAC address of the NIC to be used for ethercat
Update the ethercat config file to use that MAC addressset your Master0 device to your MAC address and device modules to generic. Make these edits
NOte at this stage only the generic driver is available under the 6.1 kernelsave and close geany
Note, we have found in some circumstances ethercat master wants to use the first NIC listed in ip a if multiple NIC's are installed
If you experience problems after installation is complete, swap your network cables around and edit the MAC address in ethercat.conf
Enter these commands to start the ethercat service.Ethercat should be running. If the above command is not found, you have a problem
You can list the slaves if you type
If you are using cia402 compatible drives:so to test its working from Linuxcnc
If you don't have an xml config file yet (preferred), download an ethercat config file of mine from
github.com/rodw-au/linuxcnc-cia402/blob/main/ethercat-conf.xml
in that folder type:You should see this and hopefully a few other pins displayed
To ensure the ethercat port has permissions on startup. Create a udev rule
Add the following:
Save and exit, then type
and reboot your computer.
Without this, on a restart, you always needed to chmod the ethercat port.
Let us know how you get on.
Ethercat installation instructions from repositories that are maintained by the IgH Etherlabmaster team
If installing on a new PC, Grab my Linucnc live installler which includes the required third party repositories pre installed.
drive.google.com/file/d/16nprK_5HeURoNGd.../view?usp=drive_link
This will let you install all required software with one line of code and skip most steps that follow
sudo apt install ethercat-master libethercat-dev linuxcnc-ethercat
Warning: Spoiler!
Open a terminal and type the following
sudo apt install geany curl git grub-customizer
## for Bookworm Debian 12
sudo mkdir -p /usr/local/share/keyrings/
wget -O- https://build.opensuse.org/projects/science:EtherLab/signing_keys/download?kind=gpg | gpg --dearmor | sudo dd of=/usr/local/share/keyrings/science_EtherLab.gpg
Create an ethercat sources file
sudo geany /etc/apt/sources.list.d/science_EtherLab.sources
Paste in the following, save and exit geany
Types: deb
Signed-By: /usr/local/share/keyrings/science_EtherLab.gpg
Suites: ./
URIs: http://download.opensuse.org/repositories/science:/EtherLab/Debian_12/
sudo apt update
If you have UEFI (Secure boot) on your PC with the preempt_rt kernel (installed with linuxcnc) you need to do a bit more work
If you have Secure Boot enabled (can be checked with mokutil --sb-state), some extra steps may be needed. AFAIK, the DKMS modules are signed with a generated key (/var/lib/dkms/mok.pub), this key needs to be enrolled as a Machine Owner Key (MOK).
sudo grub-customizer
efi=runtime
sudo mokutil --import /var/lib/dkms/mok.pub
input password:
input password again:
Select enrol MOK from this menu, enter your password and answer the questions. (Some help prompts are displayed at the top of the screen)
After that, a SecureBoot-Enabled PREEMPT_RT Kernel is able to load DKMS modules.
Install the headers and the ethercat master
sudo apt install -y linux-headers-$(uname -r)
sudo apt install ethercat-master libethercat-dev
Install the repository and driver
curl -s https://packagecloud.io/install/repositories/rodw-au/rodw-au/script.deb.sh | sudo bash
sudo apt install linuxcnc-ethercat=0.9.4
sudo apt update
If you want to build the linuxcnc-ethercat driver yourself, open the spoiler and follow the instructions
Warning: Spoiler!
clone my repository
git clone https://github.com/rodw-au/linuxcnc-ethercat
cd linuxcnc-ethercat
git checkout adapt_debian
sudo apt install dpkg-dev linuxcnc-uspace, ethercat-master and libethercat-dev
dpkg-buildpackage -us -uc
cd ..
sudo dpkg -i linuxcnc-ethercat(tab)
Check the NIC you are using for ethercat
ip a
Update the ethercat config file to use that MAC address
sudo geany /etc/ethercat.conf
NOte at this stage only the generic driver is available under the 6.1 kernel
MASTER0_DEVICE="xx:aa:yy:zz:bb:cc"
DEVICE_MODULES="generic"
Note, we have found in some circumstances ethercat master wants to use the first NIC listed in ip a if multiple NIC's are installed
If you experience problems after installation is complete, swap your network cables around and edit the MAC address in ethercat.conf
Enter these commands to start the ethercat service.
sudo systemctl enable ethercat.service
sudo systemctl start ethercat.service
sudo systemctl status ethercat.service
sudo chmod 666 /dev/EtherCAT0
You can list the slaves if you type
ethercat slaves
If you are using cia402 compatible drives:
cd ~/dev
git clone https://github.com/dbraun1981/hal-cia402
cd hal-cia402
sudo halcompile --install cia402.comp
If you don't have an xml config file yet (preferred), download an ethercat config file of mine from
github.com/rodw-au/linuxcnc-cia402/blob/main/ethercat-conf.xml
in that folder type:
halcmd loadusr -W lcec_conf ethercat-conf.xml
halcmd show pin lcec
Component Pins:
Owner Type Dir Value Name
4 u32 OUT 0x00000001 lcec.conf.master-count
4 u32 OUT 0x00000004 lcec.conf.slave-count
To ensure the ethercat port has permissions on startup. Create a udev rule
sudo geany /etc/udev/rules.d/99-ethercat.rules
Add the following:
KERNEL=="EtherCAT[0-9]", MODE="0777"
Save and exit, then type
sudo udevadm control --reload-rules
and reboot your computer.
Without this, on a restart, you always needed to chmod the ethercat port.
Let us know how you get on.
Last edit: 26 Aug 2023 06:05 by rodw. Reason: Update to clarify how to instal on different versions of Debian
The following user(s) said Thank You: tommylight, bkt, Niko, uur.ersan, sqmathlete, marq_torque, anfänger, Tady, medicusdkfz, soungoulian and 8 other people also said thanks.
Please Log in or Create an account to join the conversation.
17 Mar 2022 21:31 - 10 Mar 2023 21:54 #237567
by rodw
Replied by rodw on topic Ethercat installation from repositories - how to step by step
It should not be necessary to continue on this thread as the instructions above have been updated in October and November 2022 to include further ammendments.
Checked in March 2023 and confirmed its still working correctly.
A slight update. Sometimes the ethercat master gets confused about the kernel version and looks in the wrong folder.
This can happen if you install preempt_rt or upgrade your copy of Linux to a later version
So we can use uname -r to get the exact kernel running when we install the headers
Install the headers and the ethercat master
Checked in March 2023 and confirmed its still working correctly.
A slight update. Sometimes the ethercat master gets confused about the kernel version and looks in the wrong folder.
This can happen if you install preempt_rt or upgrade your copy of Linux to a later version
So we can use uname -r to get the exact kernel running when we install the headers
Install the headers and the ethercat master
sudo apt install -y linux-headers-$(uname -r)
sudo apt-get install ethercat-dkms libethercat libethercat-dev ethercat-master
ip a
Last edit: 10 Mar 2023 21:54 by rodw.
Please Log in or Create an account to join the conversation.
30 Apr 2022 22:03 #241740
by rodw
Replied by rodw on topic Ethercat installation from repositories - how to step by step
One more update to ensure the ethercat port has permissions on startup. Create a udev rule
Add the following:
Save and exit, then type
and reboot your computer.
Without this, on a restart, you always needed to chmod the ethercat port.
sudo nano /etc/udev/rules.d/99-ethercat.rules
Add the following:
KERNEL=="EtherCAT[0-9]", MODE="0777"
Save and exit, then type
sudo udevadm control --reload-rules
and reboot your computer.
Without this, on a restart, you always needed to chmod the ethercat port.
The following user(s) said Thank You: tommylight, foxington
Please Log in or Create an account to join the conversation.
16 May 2022 18:47 #243096
by rodw
Replied by rodw on topic Ethercat installation from repositories - how to step by step
In the two steps above where we wget the security key and edit sources.list, you will see we used Debian_10 (which is buster)
For later Debian distros, If you get security issues, replace Debian_10 as follows
For more info review the repo notes (click on show more):
build.opensuse.org/project/show/home:bon...hes:science:EtherLab
For later Debian distros, If you get security issues, replace Debian_10 as follows
Bullseye: Debian_11
Testing (aka currently Bookworm): Debian_Testing
For more info review the repo notes (click on show more):
build.opensuse.org/project/show/home:bon...hes:science:EtherLab
Please Log in or Create an account to join the conversation.
01 Jul 2022 16:46 #246380
by DmitryKV
Replied by DmitryKV on topic Ethercat installation from repositories - how to step by step
Hello.
Tell me, is there a description of the rules for compiling an xml file or a schema? Intuitively, of course, it is clear what data is described in xml. But if there is a scheme, this would help to avoid mistakes in names. It would be nice to know what names are available for description. For example, there is a line in xml <dcConf assignActivate="300" sync0Cycle="*1" sync0Shift="0"/>
Probably dcConf is Distributed Clocks, very similar. It would be nice if didn't have to guess.
For me, this topic is new, maybe I do not know the obvious things. Please be understanding.
Regards, Dmitry
Tell me, is there a description of the rules for compiling an xml file or a schema? Intuitively, of course, it is clear what data is described in xml. But if there is a scheme, this would help to avoid mistakes in names. It would be nice to know what names are available for description. For example, there is a line in xml <dcConf assignActivate="300" sync0Cycle="*1" sync0Shift="0"/>
Probably dcConf is Distributed Clocks, very similar. It would be nice if didn't have to guess.
For me, this topic is new, maybe I do not know the obvious things. Please be understanding.
Regards, Dmitry
Please Log in or Create an account to join the conversation.
27 Jul 2022 05:27 #248388
by kangkang
Replied by kangkang on topic Ethercat installation from repositories - how to step by step
hello!!
EtherCAT installation is in progress using LinuxCNC 2.8.2 Debian 10 Buster PREEMPT-RT ISO provided on LinuxCNC official website.
EtherCAT was installed by referring to the well described installation process.
After that, the systemctl start ethercat.service command was executed, but an error occurred.
If execute the sudo systemctl status ethercat.service command, the following error message is displayed.
● ethercat.service - EtherCAT Master Kernel Modules
Loaded: loaded (/lib/systemd/system/ethercat.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2022-07-27 14:08:46 KST; 4min 14s ago
Process: 2355 ExecStart=/usr/sbin/ethercatctl start (code=exited, status=1/FAILURE)
Main PID: 2355 (code=exited, status=1/FAILURE)
Jul 27 14:08:46 192 systemd[1]: Starting EtherCAT Master Kernel Modules...
Jul 27 14:08:46 192 ethercatctl[2355]: modprobe: FATAL: Module ec_master not found in directory /lib/modules/4.19.0-17-rt-amd64
Jul 27 14:08:46 192 systemd[1]: ethercat.service: Main process exited, code=exited, status=1/FAILURE
Jul 27 14:08:46 192 systemd[1]: ethercat.service: Failed with result 'exit-code'.
Jul 27 14:08:46 192 systemd[1]: Failed to start EtherCAT Master Kernel Modules.
Is there any way to solve the following error?
Thank you!!
EtherCAT installation is in progress using LinuxCNC 2.8.2 Debian 10 Buster PREEMPT-RT ISO provided on LinuxCNC official website.
EtherCAT was installed by referring to the well described installation process.
After that, the systemctl start ethercat.service command was executed, but an error occurred.
If execute the sudo systemctl status ethercat.service command, the following error message is displayed.
● ethercat.service - EtherCAT Master Kernel Modules
Loaded: loaded (/lib/systemd/system/ethercat.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2022-07-27 14:08:46 KST; 4min 14s ago
Process: 2355 ExecStart=/usr/sbin/ethercatctl start (code=exited, status=1/FAILURE)
Main PID: 2355 (code=exited, status=1/FAILURE)
Jul 27 14:08:46 192 systemd[1]: Starting EtherCAT Master Kernel Modules...
Jul 27 14:08:46 192 ethercatctl[2355]: modprobe: FATAL: Module ec_master not found in directory /lib/modules/4.19.0-17-rt-amd64
Jul 27 14:08:46 192 systemd[1]: ethercat.service: Main process exited, code=exited, status=1/FAILURE
Jul 27 14:08:46 192 systemd[1]: ethercat.service: Failed with result 'exit-code'.
Jul 27 14:08:46 192 systemd[1]: Failed to start EtherCAT Master Kernel Modules.
Is there any way to solve the following error?
Thank you!!
Please Log in or Create an account to join the conversation.
31 Jul 2022 11:56 #248724
by andypugh
Replied by andypugh on topic Ethercat installation from repositories - how to step by step
Do you have anything in /lib/modules with a slightly different name?
Please Log in or Create an account to join the conversation.
31 Jul 2022 19:56 #248747
by rodw
Replied by rodw on topic Ethercat installation from repositories - how to step by step
Did you read this post earlier in this thread?
forum.linuxcnc.org/ethercat/45336-etherc...-step-by-step#237567
That should fix it.
forum.linuxcnc.org/ethercat/45336-etherc...-step-by-step#237567
That should fix it.
Please Log in or Create an account to join the conversation.
02 Sep 2022 17:28 #251037
by CORBETT
Replied by CORBETT on topic Ethercat installation from repositories - how to step by step
Rod,
Things have changed in the last year or so... Yesterday was my birthday so I decided to do a full EtherCAT build from scratch. Put on Buster 10, then RIP of LCNC, Started to build the EC-Debianize and then found that the Mercurial servers were not there.... Got confused..
Then looked up that it has migrated to Gitlab.
So, I decided to follow your path and it was seamless, very easy. Put the master on in no time and have slaves recognized. Will build the driver tonight.
Anyway, will be hard not to do a
sudo update-ethercat-config
after adding the hardware address... it's burned in my brain LOL
Robert
Things have changed in the last year or so... Yesterday was my birthday so I decided to do a full EtherCAT build from scratch. Put on Buster 10, then RIP of LCNC, Started to build the EC-Debianize and then found that the Mercurial servers were not there.... Got confused..
Then looked up that it has migrated to Gitlab.
So, I decided to follow your path and it was seamless, very easy. Put the master on in no time and have slaves recognized. Will build the driver tonight.
Anyway, will be hard not to do a
sudo update-ethercat-config
after adding the hardware address... it's burned in my brain LOL
Robert
The following user(s) said Thank You: rodw
Please Log in or Create an account to join the conversation.
- sqmathlete
- Offline
- Premium Member
-
Less
More
- Posts: 118
- Thank you received: 16
02 Oct 2022 17:23 #253270
by sqmathlete
Replied by sqmathlete on topic Ethercat installation from repositories - how to step by step
Hi Rod,
I followed these instructions several times and, everything worked perfectly. Tried to install today and I get an error saying that no public key is available. Any idea if something has something changed? This is a fresh install of the Debian buster Linuxcnc iso.
Kind regards,
Dan
I followed these instructions several times and, everything worked perfectly. Tried to install today and I get an error saying that no public key is available. Any idea if something has something changed? This is a fresh install of the Debian buster Linuxcnc iso.
Kind regards,
Dan
Please Log in or Create an account to join the conversation.
Time to create page: 0.118 seconds