Ethercat installation from repositories - how to step by step

More
13 Mar 2022 11:12 - 27 Jan 2024 08:16 #237098 by rodw
UPDATE: Following the release Of linuxCNC 2.9.2 install linuxcnc from the downloads page

linuxcnc.org/downloads/

After installation, refer to the brief instructions in your home folder.
Recently the linuxcnc hal ethercat driver has moved and is actively maintained. It is now hosted by iGh on their repository. This repository is installed by the 2.9.2 ISO.

Open a terminal and type the following
sudo apt update
sudo apt install  linuxcnc-ethercat
This should work as all the ethercat stuff is now set as dependencies.
If that fails, try this complete command:
sudo apt install ethercat-master libethercat-dev  linuxcnc-ethercat


If this stil fails you may have UEFI (Secure boot) on your PC with the preempt_rt kernel (installed with linuxcnc) you need to do a bit more work. Open the spoiler:
Warning: Spoiler!


obtain your mac address
ip a
Save the MAC address of the NIC to be used for ethercat
Update the ethercat config file to use that MAC address
sudo geany /etc/ethercat.conf
set 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 Bookworm kernel
MASTER0_DEVICE="xx:aa:yy:zz:bb:cc"
DEVICE_MODULES="generic"
save 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 complere, 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
Ethercat should be running. If the above command is not found, you have a problem
You can list the slaves if you type
ethercat slaves

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.


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
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:
halcmd loadusr -W lcec_conf ethercat-conf.xml
halcmd show pin lcec
You should see this and hopefully a few other pins displayed
Component Pins:
Owner   Type  Dir         Value  Name
     4  u32   OUT    0x00000001  lcec.conf.master-count
     4  u32   OUT    0x00000004  lcec.conf.slave-count


Let us know how you get on.
 
Last edit: 27 Jan 2024 08:16 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 11 other people also said thanks.

Please Log in or Create an account to join the conversation.

More
17 Mar 2022 21:31 - 27 Jan 2024 08:08 #237567 by rodw
UPDATE: Following the release Of linuxCNC 2.9.2 install linuxcnc from the downloads page

linuxcnc.org/downloads/

After installation, refer to the brief instructions in your home folder.
Recently the linuxcnc hal ethercat driver has moved and is actively maintained. It is now hosted by iGh on their repository. This repository is installed by the 2.9.2 ISO.

Open a terminal and type the following
sudo apt update
sudo apt install  linuxcnc-ethercat
This should work as all the ethercat stuff is now set as dependencies.
If that fails, try this complete command:
sudo apt install ethercat-master libethercat-dev  linuxcnc-ethercat


If this stil fails you may have UEFI (Secure boot) on your PC with the preempt_rt kernel (installed with linuxcnc) you need to do a bit more work. Open the spoiler:
Warning: Spoiler!


obtain your mac address
ip a
Save the MAC address of the NIC to be used for ethercat
Update the ethercat config file to use that MAC address
sudo geany /etc/ethercat.conf
set 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 Bookworm kernel
MASTER0_DEVICE="xx:aa:yy:zz:bb:cc"
DEVICE_MODULES="generic"
save 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 complere, 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
Ethercat should be running. If the above command is not found, you have a problem
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
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:
halcmd loadusr -W lcec_conf ethercat-conf.xml
halcmd show pin lcec
You should see this and hopefully a few other pins displayed
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: 27 Jan 2024 08:08 by rodw.
The following user(s) said Thank You: medicusdkfz, foxington, energien

Please Log in or Create an account to join the conversation.

More
30 Apr 2022 22:03 #241740 by rodw
One more update to ensure the ethercat port has permissions on startup. Create a udev rule
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.

More
16 May 2022 18:47 #243096 by rodw
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
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.

More
01 Jul 2022 16:46 #246380 by DmitryKV
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

Please Log in or Create an account to join the conversation.

More
27 Jul 2022 05:27 #248388 by kangkang
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!!

Please Log in or Create an account to join the conversation.

More
31 Jul 2022 11:56 #248724 by andypugh
Do you have anything in /lib/modules with a slightly different name?

Please Log in or Create an account to join the conversation.

More
31 Jul 2022 19:56 #248747 by rodw
Did you read this post earlier in this thread?

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.

More
02 Sep 2022 17:28 #251037 by CORBETT
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
The following user(s) said Thank You: rodw

Please Log in or Create an account to join the conversation.

More
02 Oct 2022 17:23 #253270 by sqmathlete
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

Please Log in or Create an account to join the conversation.

Time to create page: 0.163 seconds
Powered by Kunena Forum