Ethercat installation from repositories - how to step by step

More
13 Mar 2022 11:12 - 22 Mar 2023 12:06 #237098 by rodw
UPDATE: October 2022 to include all steps in the first post (I hope!)
UPDATE: November 2022 to bypass editing realtime.mk which no longer seems to be required imn some instances.
UPDATE: March 2023 to resolve erros when running a live config by editing realtime.mk
Ethercat installation instructions from repositories maintained unofficially by the IgH Etherlabmaster team

This has now also been tested by a few people so here is a nice easy way to install ethercat master without compiling code. So here goes:
Open a terminal and type the following
sudo apt install geany curl git
sudo geany /etc/apt/sources.list
Insert one of these lines at the end of the file
## For buster
deb [allow-insecure=yes] https://download.opensuse.org/repositories/home:/bone11111:/branches:/science:/EtherLab/Debian_10/ ./
## for Bullseye
deb [allow-insecure=yes] https://download.opensuse.org/repositories/home:/bone11111:/branches:/science:/EtherLab/Debian_11/ ./
## for Bookworm
deb [allow-insecure=yes] https://download.opensuse.org/repositories/home:/bone11111:/branches:/science:/EtherLab/Debian_Testing/ ./
Save and close geany

sudo apt update
Enter these commands to create a security key depending on your version of Debian (always run the first line)
KEYRING=/usr/share/keyrings/ethercat.gpg
## For Buster
curl -fsSL https://download.opensuse.org/repositories/home:/bone11111:/branches:/science:/EtherLab/Debian_10/Release.key | gpg --dearmor | sudo tee "$KEYRING" >/dev/null
## For Bullseye
curl -fsSL https://download.opensuse.org/repositories/home:/bone11111:/branches:/science:/EtherLab/Debian_11/Release.key | gpg --dearmor | sudo tee "$KEYRING" >/dev/null
## For Bookworm
curl -fsSL https://download.opensuse.org/repositories/home:/bone11111:/branches:/science:/EtherLab/Debian_Testing/Release.key | gpg --dearmor | sudo tee "$KEYRING" >/dev/null

For more info review the repo notes (click on show more):
build.opensuse.org/project/show/home:bon...hes:science:EtherLab

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
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
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
Now time to install the linuxcnc ethercat driver
You may need to run this command but I didn't with a Debian Sid install. Try it anyway.
sudo apt install expat libexpat1 libexpat1-dev

Now get on with the driver install
mkdir dev
cd dev
git clone https://github.com/sittner/linuxcnc-ethercat.git
cd linuxcnc-ethercat/src

Make and install the ethercat driver. If you get an error here its most likely becasue you have not installed halcompile (in shipped in linuxcnc-uspace-dev)
cd ~/dev/linuxcnc-ethercat
make clean
sudo make install
cd ..

If you have errors at this point, you can try replacing realtime.mk with the revisions on this forum thread:
forum.linuxcnc.org/9-installing-linuxcnc...ve-config-sdo#203252
repeated for convenience here:
Warning: Spoiler!

If the driver builds without errors without using the content of the spoiler above, but subsequently the ethercat hal driver fails when opening a linuxcnc config
with an error something like:
[/code]
lcec: dlopen: /usr/lib/linuxcnc/modules/lcec.so: undefined symbol: ecrt_slave_config_sdo
[/code]
revise the file using the spoiler contents and repeat the install step as follows:
cd ~/dev/linuxcnc-ethercat
make clean
sudo make install
cd ..
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 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: 22 Mar 2023 12:06 by rodw. Reason: Update to clarify how to instal on different versions of Debian
The following user(s) said Thank You: tommylight, bkt, Niko, sqmathlete, anfänger, Tady, medicusdkfz, energien, xwq

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

More
17 Mar 2022 21:31 - 10 Mar 2023 21:54 #237567 by rodw
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
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.
The following user(s) said Thank You: medicusdkfz, 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

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.144 seconds
Powered by Kunena Forum