Ethercat HAL driver

More
10 Jan 2019 06:13 - 10 Jan 2019 20:36 #123888 by Hawkeye
Replied by Hawkeye on topic Ethercat HAL driver
Hi @Nico2017,

YES - I will create a quick guide until end of thia week. Do you already have an working Hal-config for ethercat (are you migrating from previous version)?

It took me weeks and several retries to get all steps together. Did you already have a look here?
forum.linuxcnc.org/27-driver-boards/3559...uxcnc-how-to-install

This was helpful but copying files around is not my style..
So, stay tuned :-)




This is my how-to guide on LinuxCNC 2.8 @ Debian 9 Stretch 64 Bit:
!! Before we start, please be adviced that I don't explain every single step in detail.
!! I assume that you are experienced linux user and you know what you are doing.
!! I don't want to discuss why I am installing this or that, and/or doing what I am doing.
!! If you think you can make this better, then simply do it and don't blame on me.
!!
!! Regarding network:
!! - Build-in wifi is used to connect to my network
!! - Lan-Port will be used as ethercat master
!! Ethercat components:
!! - 2x EK1100 (Laptop -> 1. inside cabinet -> 2. mounted on back of Z-axis gantry)
!! - 4x EL4071 (X-Y-Z-A) [A is needed for extruder in 3D-printer mode or rotary axis in mill-mode]
!! - 1x EL3202 (used to get temperature from extruder hotend)
!! - 2x EL1008
!! - 2x EL2008
!! - 1x EL6021 to control 2.2KW spindle (still under development)
!! Objective:
!! - We are using a HP8440P Laptop.
!! - Rather than using LinuxCNC as run in place setup, we are building ".deb"-files and apply them to the operating system.
!!
!! I would like to thank the guys from #linuxcnc-devel@irc.freenode.net - you guys are awesome B)
!! My special thanks are going to :woohoo:
!! - "rmu"
!! - "pcw_home"

!!


01. Get install media from link below and install it on your machine.
http://www.linuxcnc.org/testing-stretch-rtpreempt/linuxcnc-stretch-uspace-amd64-r13.iso
02. Perform basic setup of Operating System
- wifi config
- enable root account
sudo passwd root
- change to user root
su - root
- configure repository list (see wiki.debian.org/SourcesList )
nano /etc/apt/sources.list
- update operating system:
apt-get update && apt-get upgrade -y && apt autoremove
- create "/install" directory (we will store some of install resources)
mkdir /install
cd /install
- install some tools
apt-get install geany \
ufw \
clamav \
clamtk \
git \
curl \
mercurial \
htop \
mplayer \
net-tools
- create "/git" dir and initialize it
mkdir /git
cd /git
git init
- activate firewall
systemctl start ufw
systemctl enable ufw
ufw enable
- determine mac address of lan port
ip link show
- configure lan
"nano /etc/network/interfaces"
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet static

address 10.0.0.1 
netmask 255.255.255.0
"nano /etc/network/interfaces"
auto lo
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet static

address 10.0.0.1 
netmask 255.255.255.0
- avoid wait time due to startup of network services
"nano /lib/systemd/system/networking.service" (change here "TimeoutStartSec=5min" to "TimeoutStartSec=1sec")
- install some reseources required for build process later on
apt-get install docbook-xsl \
dvipng \
graphviz \
groff \
inkscape \
python-lxml \
source-highlight \
texlive-extra-utils \
texlive-font-utils \
texlive-fonts-recommended \
texlive-latex-recommended \
w3c-linkchecker \
xsltproc \
asciidoc-dblatex \
python-dev \
libxmu-dev \
libglu1-mesa-dev \
libgl1-mesa-dev

apt-get install libgtk2.0-dev \
gettext \
intltool \
autoconf \
libboost-python-dev \
netcat \
libmodbus-dev \
libusb-1.0-0-dev \
yapps2 \
tcl8.6-dev \
tk8.6-dev \
libreadline-gplv2-dev \
asciidoc \
devscripts \
build-essential \
lintian \
texlive-lang-cyrillic \
texlive-lang-french \
texlive-lang-german \
texlive-lang-polish \
texlive-lang-spanish \
devscripts \
build-essential \
quilt

03. Remove pre-installed linuxcnc
apt-get purge linuxcnc-doc-en linuxcnc-uspace-dev linuxcnc-uspace

04. Setup LinuxCNC 2.8
cd /git
git clone git://github.com/linuxcnc/linuxcnc.git linuxcnc-dev
cd linuxcnc-dev/debian
./configure uspace
cd ..
dpkg-buildpackage -b -uc
cd /git
apt install ./linuxcnc-doc-en_2.8.0~pre1_all.deb
apt install ./linuxcnc-uspace_2.8.0~pre1_amd64.deb
apt install ./linuxcnc-uspace-dev_2.8.0~pre1_amd64.deb
mkdir /git/linuxcnc-dev/deb/
mv linuxcnc_* /git/linuxcnc-dev/deb/
mv *.deb /git/linuxcnc-dev/deb/
reboot

05. Setup "ec-debianize"
cd /git
git clone https://github.com/sittner/ec-debianize ec-debianize
./get_source.sh
cd etherlabmaster
dpkg-checkbuilddeps
dpkg-buildpackage (the output error "failed to sign .dsc file" is no issue)
sudo dpkg -i /git/ec-debianize/etherlabmaster_1.5.2+20180317hg9e65f7-2_amd64.deb
sudo dpkg -i /git/ec-debianize/etherlabmaster-dev_1.5.2+20180317hg9e65f7-2_amd64.deb
nano /etc/default/ethercat (change mac-address [MASTER0_DEVICE=""] e.g. [MASTER0_DEVICE="11:22:33:44:55:66"])
nano /etc/default/ethercat (change [DEVICE_MODULES=""] to [DEVICE_MODULES="generic"])
sudo update-ethercat-config
usermod -a -G ethercat linuxcnc
reboot

06. Setup "LinuxCNC-Ethercat"
cd /git
git clone http://github.com/sittner/linuxcnc-ethercat.git linuxcnc-ethercat"
nano /git/linuxcnc-ethercat/src/lcec_main.c (add here [#include "rtapi_mutex.h"] below [#include "rtapi_app.h"])
cd /git/linuxcnc-ethercat
make -j4
make install
sudo make install

07. Further things to consider
- if you experience issues when starting linuxcnc (cpu high load), then try to change "BASE_PERIOD=0" within your ini-file (config of your machine)

08. .. this is know the part where I guess I can end this guide now.
.. further steps (setting up ethercat.xml, machine config, ... can be seen within the forum).
.. hope this helped you - thanks for reading.
.. please leave a comment whether you managed it to get your system running.




Best Regards,
Ben
Last edit: 10 Jan 2019 20:36 by Hawkeye.
The following user(s) said Thank You: Nico2017, Matze-K

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

More
10 Jan 2019 22:48 - 14 Jan 2019 05:02 #123929 by Nico2017
Replied by Nico2017 on topic Ethercat HAL driver
Thanks your for those explanations. I have linuxcnc and ethercat up and running but not the linuxcnc-ethercat part as everytime I try a simple config using lcec components it fails to start the configuration. I actually had follow the instructions on the provided link before but there was still an issue at the end.

However you indicate a manual modification during the linuxcnc-ethercat installion that I did not do so it might explain why I have been failling so far. nano /git/linuxcnc-ethercat/src/lcec_main.c (add here [#include "rtapi_mutex.h"] below [#include "rtapi_app.h"])

I will give it a try and le you know. Thanks a lot.

PS: edit, it is working now apparently thanks the manual modification that you indicated during the linuxcnc-ethercat installation. I can now make linuxcnc with ethercat working on either a 32bits or 64bits architecture on a debian rt kernel. This line to be added make it work either for 32 or 64bits.

Thanks again

Nicolas
Last edit: 14 Jan 2019 05:02 by Nico2017. Reason: More precise results

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

More
16 Jan 2019 21:21 #124306 by rwistort
Replied by rwistort on topic Ethercat HAL driver
Hello.
I have the same problem as Nico.
When it gets to
loadrt lcec
it gives
lcec: dlopen: /home/reid/linuxcnc-dev/rtlib/lcec.so: undefined symbol: ecrt_slave_config_sdo
It seems to need the functions defined in libethercat.so, but the reference is somehow missing.
What do I have to do to account for libethercat.so references when lcec runs?

It seems like there ought to be a -lethercat in the CFLAGS of the RT part of the linuxcnc-ethercat build, but I could not get it to work.

My system is
Linux charles1 4.1.42-rt50 #1 SMP PREEMPT RT Fri Aug 18 00:40:02 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux
ec_debianize-master made itself normally.
Master is up and running after a boot, and ethercat command line works fine.
linuxcnc-ethercat seemed to make fine.
linuxcnc-dev is a fork of 2.8

Tantalizingly close is a tough place to be!

Reid

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

More
16 Jan 2019 23:09 #124307 by rwistort
Replied by rwistort on topic Ethercat HAL driver
Forgot to mention that ldd shows that lcec hal module references only a bare-bones set of libs, and libethercat is not among them.
~/linuxcnc-ethercat/src> ldd lcec.so
	linux-vdso.so.1 =>  (0x00007ffe57b91000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fdba3114000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fdba2d4a000)
	/lib64/ld-linux-x86-64.so.2 (0x0000559916b70000)
Hoping that helped...
Reid

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

More
20 Jan 2019 20:16 #124494 by rwistort
Replied by rwistort on topic Ethercat HAL driver
No ideas, hmmm?
I'll give you a hint.


I've attached the verbose output of a clean make of linuxcnc-ethernet. It is way too much information, but it shows that it's a uspace build, and the last line is:
gcc -shared -Bsymbolic -Wl,-rpath,/home/reid/linuxcnc-dev/lib -L/home/reid/linuxcnc-dev/lib -llinuxcnchal -lethercat -Wl,--version-script,lcec.ver -o lcec.so lcec_main.o lcec_class_enc.o lcec_generic.o lcec_ax5200.o lcec_el1xxx.o lcec_el1252.o lcec_el2521.o lcec_el2xxx.o lcec_el2202.o lcec_el31x2.o lcec_el3255.o lcec_el40x1.o lcec_el40x2.o lcec_el41x2.o lcec_el41x4.o lcec_el5101.o lcec_el5151.o lcec_el5152.o lcec_el6900.o lcec_el1904.o lcec_el2904.o lcec_el7041_1000.o lcec_el7211.o lcec_el7342.o lcec_el95xx.o lcec_em7004.o lcec_stmds5k.o lcec_deasda.o -lm
Or, to simplify:
gcc -shared -o lcec.so -lethercat -L/home/reid/linuxcnc-dev/lib ...etc...
Yes, libethercat.so exists in /home/reid/linuxcnc-dev/lib, and
~/linuxcnc-ethercat/src> nm -D lcec.so
                 w __cxa_finalize
                 U ecrt_domain_data
                 U ecrt_domain_process
                 U ecrt_domain_queue
                 U ecrt_domain_reg_pdo_entry_list
                 U ecrt_domain_size
                 U ecrt_master_activate
                 U ecrt_master_application_time
                 U ecrt_master_create_domain
                 U ecrt_master_deactivate
                 U ecrt_master_read_idn
                 U ecrt_master_receive
                 U ecrt_master_sdo_upload
                 U ecrt_master_send
                 U ecrt_master_slave_config
                 U ecrt_master_state
                 U ecrt_master_sync_reference_clock
                 U ecrt_master_sync_slave_clocks
                 U ecrt_release_master
                 U ecrt_request_master
                 U ecrt_slave_config_complete_sdo
                 U ecrt_slave_config_dc
                 U ecrt_slave_config_idn
                 U ecrt_slave_config_pdos
                 U ecrt_slave_config_sdo
                 U ecrt_slave_config_sdo8
                 U ecrt_slave_config_state
                 U ecrt_slave_config_watchdog
                 U free
                 U gettimeofday
                 w __gmon_start__
                 U hal_exit
                 U hal_export_funct
                 U hal_init
                 U hal_malloc
                 U hal_param_new
                 U hal_pin_new
                 U hal_ready
                 w _ITM_deregisterTMCloneTable
                 w _ITM_registerTMCloneTable
                 w _Jv_RegisterClasses
                 U malloc
                 U pow
00000000000053cc T rtapi_app_exit
00000000000065a2 T rtapi_app_main
                 U rtapi_get_time
000000000021a6a0 D rtapi_info_author
000000000021a698 D rtapi_info_description
000000000021a6a8 D rtapi_info_license
                 U rtapi_mutex_get
                 U rtapi_mutex_give
                 U rtapi_print_msg
                 U rtapi_shmem_delete
                 U rtapi_shmem_getptr
                 U rtapi_shmem_new
                 U rtapi_snprintf
                 U rtapi_vsnprintf
                 U __stack_chk_fail
                 U strncpy
~/linuxcnc-ethercat/src> 
Which confirms that the ecrt_* symbols from libethercat did not get folded into lcec.so.

I'm doing something stupid. How do I get these symbols to resolve when hal gets to loadrt lcec?

Thanks,
Reid

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

More
21 Jan 2019 15:07 #124550 by shameless
Replied by shameless on topic Ethercat HAL driver
@rwistort, I replace the src/realtime.mk with the realtime.mk in the 0.9.1 version which is found on the GitHub. It works, you can see libethercat when you ldd lcec.so. But there are other problems.
Regards!

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

More
22 Jan 2019 13:18 #124611 by Grotius
Replied by Grotius on topic Ethercat HAL driver
@Reid,

linuxcnc-dev is a fork of 2.8

I was thinking. Did you copy lcec.conf to your linuxcnc-dev bin directory?

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

More
22 Jan 2019 16:49 #124625 by rwistort
Replied by rwistort on topic Ethercat HAL driver
@Grotius
I use symbolic links in /bin and /rtlib so the binaries are always up to date. lcec_conf loads OK and its 2 pins show up in hal.

@shameless
I copied (just the) realtime.mk file from 0.9.1, and it cleared up the "undefined symbol: ecrt_slave_config_sdo" problem. Thanks!

It went on to complain about "undefined symbol: rtapi_mutex_get". This problem has shown up in this forum (see Rene 6/6/18, Nico 10/24/18, Nico 10/28/18, Hawkeye 1/10/19 step 6). So I added #include rtapi_mutex.h in lcec_main.c and changed permissions to /dev/EtherCAT0, and now both lcec_conf and lcec load, and hal is full of lcec pins to play with.
Woo hoo!

Sadly, my (one and only) servo drive exploded in a flash of sparks and smoke the other day, and I can't play with my new pins until I get it back from warranty repair. SAD!!

I am one of those people who wonders what make is really doing under all those covers, so I tried to figure out what, in the 0.9.1 config.mk, makes the difference.
When it gets right down to issuing a gcc command, the 091 and the latest gcc command for .c -> .o differs by:
common: gcc -o lcec_em7004.o -Os -g -I. -I/home/reid/linuxcnc-dev/src/include -DUSPACE -fno-fast-math -mieee-fp -fno-unsafe-math-optimizations -DRTAPI -D_GNU_SOURCE -Drealtime -D__MODULE__ -I/home/reid/linuxcnc-dev/include -DSIM -fPIC -c lcec_em7004.c
091   : -Os
new   : -Wframe-larger-than=2560
I doubt that this is part of the problem.

The command line for the link step .o -> .so differs by:
common: gcc -shared -o lcec.so -Wl,-rpath,/home/reid/linuxcnc-dev/lib -L/home/reid/linuxcnc-dev/lib -llinuxcnchal -lethercat [object-name-list]
091   : -lrt
new   : -lm  -Bsymbolic -Wl,--version-script,lcec.ver
I could not figure out where, in all of make's mechanics, the "-Bsymbolic -Wl,--version-script,lcec.ver" comes from.
Their presence, though, seems to cause a 2-step link which I am totally unfamiliar with. Something like:
ld -d -r -o lcec.tmp [obj-list]
objcopy -j .rtapi_export -O binary lcec.tmp lcec.sym
(echo '{ global : '; tr -s '\0' < lcec.sym | xargs -r0 printf '%s;\n' | grep .; echo 'local : * ; };') > lcec.ver
gcc -shared -Bsymbolic -Wl,-rpath,/home/reid/linuxcnc-dev/lib -L/home/reid/linuxcnc-dev/lib -llinuxcnchal -lethercat -lm -Wl,--version-script,lcec.ver -o lcec.so [obj-list]
Can anybody out there give us a bird's eye view of what make is trying to do here?

Admit it! We're all a little bit confused and a little bit curious!

Thanks
Reid

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

More
22 Jan 2019 19:10 #124628 by Grotius
Replied by Grotius on topic Ethercat HAL driver
@Reid,

The erhercat master version is selected from the ethercat download site. There are several download options and versions over there available.. Maybe in combination with the ec debianize software it is unclarified to read back the exact source route. Its important to tell some info about sources in readme files. But if it works users will not complain. Its the same story as dist-upgrade.

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

More
23 Jan 2019 09:18 #124650 by shameless
Replied by shameless on topic Ethercat HAL driver
Hi!
I see your post which was sent on 26 Jun 2013, you got your computer worked with the r8169 driver, so was your network card r8169? Cause I got a problem, when I use the r8169 driver to work with my network card(8186/8112/8111), it does work, but when I stop the ethercat, I can't restart the ethercat, for the eth0 lost. And the mac cannot be attached. The only solution to this problem is that reboot the computer.
So is there any better way to solve it?
Thanks very much.

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

Time to create page: 0.116 seconds
Powered by Kunena Forum