4. Ethernet Device Assigment

Hint

All user inputs should be done in a Terminal, or in case a file is edited in an editor.

4.1. Device identification

There are several ways to detect the desired network adapter(s), which should be assigned to the rtos part. This tutorial use as simple way to detect the desired network adapter. In our test case we need at least 2 network adapter, which are not connected at this stage.

Hint

In our example the PC has 3 network adapters. 1 connected to the company network and 2 not-connected anywhere. This 2 adapters will be used later by the EC-Master and will be connected to the EtherCAT slaves.

List all available adapters:

ifconfig -a

The output will be similar to the following output. The adapter, which is connect to the company network will contain a <link> entry. This adapter will be ignored. The other 2 adapters are desired. The lo with inet 127.0.0.1 is the localhost, which isn’t desired also.

enp0s25: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet 172.17.10.45  netmask 255.255.0.0  broadcast 172.17.255.255
    inet6 2a02:590:801:2c00:6fef:fc8f:977f:aa12  prefixlen 64  scopeid 0x0<global>
    inet6 fe80::ce1d:c9c9:aa11:fa9  prefixlen 64  scopeid 0x20<link>
    inet6 2a02:590:801:2c00:bd83:9c95:38f0:6305  prefixlen 64  scopeid 0x0<global>
    ether 00:19:99:de:98:cf  txqueuelen 1000  (Ethernet)
    RX packets 48668  bytes 60096879 (60.0 MB)
    RX errors 0  dropped 2  overruns 0  frame 0
    TX packets 28112  bytes 33952890 (33.9 MB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    device interrupt 20  memory 0xfbb00000-fbb20000

enp1s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
    ether 00:15:17:8a:bd:d9  txqueuelen 1000  (Ethernet)
    RX packets 0  bytes 0 (0.0 B)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 0  bytes 0 (0.0 B)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    device interrupt 16  memory 0xfba40000-fba60000

enp2s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
    ether 00:19:99:e0:e6:73  txqueuelen 1000  (Ethernet)
    RX packets 0  bytes 0 (0.0 B)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 0  bytes 0 (0.0 B)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    device interrupt 18  memory 0xfb900000-fb920000

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
    inet 127.0.0.1  netmask 255.0.0.0
    inet6 ::1  prefixlen 128  scopeid 0x10<host>
    loop  txqueuelen 1000  (Local Loopback)
    RX packets 207  bytes 16390 (16.3 KB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 207  bytes 16390 (16.3 KB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

In this example the name of the desired network adapters are enp1s0 and enp2s0.

4.2. Device assignment

In the previous section the detected name [DETECTED_NAME_1] of the adapter is enp1s0. This name will be given as first parameter of the ./addeth.sh shell script. The second parameter (mandatory) is the rtos device name. Third parameter is a sequential number for each assigned device, starting with 1.

cd /hv/config
sudo ./addeth.sh enp1s0 rtos_eth1 1

generic:

sudo ./addeth.sh [DETECTED_NAME_1] rtos_eth 1

The same must be done for the second network card (device) also. The the detected name [DETECTED_NAME_2] of the adapter is enp2s0:

sudo ./addeth.sh enp2s0 rtos_eth2 2

generic:

sudo ./addeth.sh [DETECTED_NAME_2] rtos_eth2 2

Important

The script creates 2 files located in /hv/config: rtos_eth1.sh, rtos_eth1.config respective rtos_eth2.sh, rtos_eth2.config.

Hint

The RTOS device name is mandatory. This parameter must be a unique name that is used to identify the device. This name will also be used in filenames that are created by the addeth.sh script. In this tutorial the default name used is rtos_eth1, respective rtos_eth2.

Caution

If devices with same name are assigned to the same Rtos the names of the keys in rtos_eth1.sh, rtos_eth1.config, etc. must be altered!

4.3. Adjust generated rtos_eth2.config

sudo gedit /hv/config/rtos_eth2.config

Replace all occurences of Rtos in the section labels [..\Rtos\..] with Rtos2. Finally it should looks like that: [..\Rtos2\..]

Example:

  • Old:
    [Devices\Rtos\Intel Corporation 82574L Gigabit Network Connection\IoPort\1]
      "Address"=hex:00,d0,00,00,00,00,00,00
      "Length"=dword:20
    
  • New:
    [Devices\Rtos2\Intel Corporation 82574L Gigabit Network Connection\IoPort\1]
      "Address"=hex:00,d0,00,00,00,00,00,00
      "Length"=dword:20
    

4.4. Adjust the hypervisor partitioning script /hv/config/hvpart.sh

The device assignment scripts <RTOS device name>.sh usually shall be executed automatically on system startup. To accomplish this, add the respective <RTOS device name>.sh calls into the file /hv/config/hvpart.sh. In our tutorial we use rtos_eth1, respectivly rtos_eth2 as the unique <RTOS device name>, as mentioned earlier.

gedit /hv/config/hvpart.sh

The hvpart.sh file should contain at least the following strings after editing: source /hv/config/rtos_eth1.sh add and source /hv/config/rtos_eth2.sh add

The example below shows, how the devices with the unique names rtos_eth1, respective rtos_eth2 are assigned.

#!/bin/bash
source /hv/config/rtos_eth1.sh add
source /hv/config/rtos_eth2.sh add

4.5. Reboot system

Please reboot the system to make the change effective.

sudo reboot now