[etherlab-dev] compile and use ethercat driver under linux 3.10.33

Jeroen Van den Keybus jeroen.vandenkeybus at gmail.com
Wed Apr 9 14:33:11 CEST 2014


>
> During my tries to get the ethercat driver working, I got stuck on two
> computers.
>

You really need to give more specific information. For starters, which
EtherCAT master version ?

The first is therefore an ARM SoC. What type is the second ?


> The first computer is a raspberry pi. Here, I run a ported kernel
> especially for raspberry pi.
> My problem: I can perfectly do a "./ethercat restart". The ethercat driver
> stops and comes back up.
> This I perfectly see with "lsmod".
>

'restart' is not a valid ethercat command. Nothing of what 'ethercat' does,
influences the kernel drivers and, therefore, cannot be observed by lsmod.

Still, when I try to do "ethercat slaves" for example, the raspberry pi
> immediatly gives me the following line: "IOCTL() version magic difference.
> EtherCAT0:28 ethercat:13".
> The compiling happens on the same target. I don't understand why I have
> this problems.
>
> The second computer gives "Module ec_master not found. Failed".
> What is saw was the fact that I don't have the "ec_master.ko" in the
> /lib/modules/<kernel>/ethercat.
> This ethercat directory is just empty. What can be the problem for this
> problem?
>

Assuming you are building this on a PC, I can suggest the following:

0. First build and test this on a PC platform, so that you know how the
master should behave.
1. Make sure you get the source in a local building directory, not
requiring root access. Avoids contamination of your Linux installation.
2. Do not build kernel-specific Ethernet drivers yet. Instead, use
ec_generic for initial testing and acquaintance. The main reason is that
you do not need a specific kernel version in this case. Any recent kernel
will do.
3. Do not install yet (don't do 'sudo make install' or 'sudo make
modules_install'). Instead, use 'sudo insmod' to try and load the kernel
modules directly without affecting your Linux installation.

For *building*, after unpacking the source, you basically need 4 steps (you
need to be in the toplevel source dir for this, note the $ prompt: none of
this requires root privs):

$ ./bootstrap linux
$ ./configure --disable-8139too  [note: must terminate with:
'config.status: executing libtool commands']
$ make
$ make modules

(by default, ec_generic is enabled (good) but the 8139 is by default
enabled as well (bad) and will fail if your kernel doesn't match any of the
supported versions. By disabling it, any kernel version will do.)

Follow the INSTALL guidelines closely and specifically, check during module
building ('make modules') which kernel build directory was used. For that,
check the 2nd line of the 'make modules' result. It should read like:

make[1]: Entering directory `/home/[username]/work/linux-[version]'

Check that this is indeed the Linux version you intend to use.


To *run the master*, you first need to determine the MAC address of the eth
interface that's going to be managed by the master.

$ /sbin/ifconfig -a

Make note of the relevant MAC address.

Now load the master (still in toplevel source dir !)

$ sudo insmod master/ec_master.ko main_devices=[mac address]

Do yourself a favor and enable ordinary user access to the just-created
device (otherwise you have to always 'sudo ethercat'):

$ sudo chmod 666 /dev/EtherCAT0

Then, and only then, load the Ethernet driver (the correct attachment is
done through the MAC address you specified earlier):

$ sudo insmod devices/ec_generic.ko

Chances are that your network interface isn't up yet. To make certain, do:

$ sudo ifconfig eth[X] up

Now test operation of the system with any and all of:

$ dmesg
$ tool/ethercat master
$ tool/ethercat slave -v


Only after this, I would endeavour building on an embedded platform.


> Can somebody please get me a hand with this. I really have no clues
> anymore.
>

Go and build it. Properly. And step by step.

Good luck,



J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.etherlab.org/pipermail/etherlab-dev/attachments/20140409/521f23d6/attachment-0003.htm>


More information about the Etherlab-dev mailing list