mcx-rtos v.2022.09 Network Configuration
4 minute read
Network Configuration
This section describes how to configure your wifi
, wired
or etherCAT
network.
Network Directory
Default network files are stored in the following directory:
/etc/systemd/network
├── 25-wifi.network
├── 50-wired.network
├── 51-ethercat.network
└── examples
├── 25-wifi-ap.network
├── 50-wired-dhcp-client-and-static.network
├── 50-wired-dhcp-client.network
├── 50-wired-dhcp-server-and-static.network
├── 50-wired-dhcp-server.network
├── 50-wired-static.network
└── 51-ethercat.network
The network
directory displays the default network configuration for WiFi
, Wired
and EtherCAT
. The examples
folder provides a set of predefined network settings, based on Systemd.network.
Note
When changing the network configuration, it is recommended to use the given examples as a template. Note that the network directory should only contain one set of 25-.. 50-.. and 51-..
files.
Wired Network Configuration
How to change the wired network settings:
-
Navigate to the network directory:
cd /etc/systemd/network
-
Edit
50-wired.network
:sudo nano 50-wired.network
Displays the default configuration:
# Wired network settings [Match] Name=eth0 [Network] DHCP=yes ConfigureWithoutCarrier=yes IgnoreCarrierLoss=yes [Address] Label=eth0:0 Address=192.168.2.100/24
Per default the
eth0
network device is reserved forwired network
. This configuration tries to configure connection with DHCP and in case there is no DHCP server on your network it configures a static IP (192.168.2.100/24
).
Note
Make sure that the network device that you wish to assign to the wired network is not already taken by the EtherCAT Network Configuration).
-
Save the file and reboot your controller:
sudo reboot
Now your wired network settings are changed!
Note
After changing the controller IP address, you need to configure your network again.
EtherCAT Network Configuration
How to change the etherCAT network configuration:
-
Navigate to the network directory:
cd /etc/systemd/network
-
Edit
51-ethercat.network
:sudo nano 51-ethercat.network
Displays the default configuration:
# EtherCAT network settings [Match] Name=eth1 [Network] LinkLocalAddressing=no IPv6AcceptRA=no ConfigureWithoutCarrier=yes #[Link] #Unmanaged=yes
Per default the
eth1
network device is reserved foretherCAT
. You can change the network device assigned to etherCAT network to your own preference.
Note
Make sure that the network device that you wish to assign to the EtherCAT network is not already taken by the wired network configuration).
-
Save the file and reboot your controller:
sudo reboot
Note
The assigned etherCAT network device, must match the assigned network device in the EtherCAT Master Configuration.
WiFi Configuration
How to change the wifi configuration:
-
Navigate to the network directory:
cd /etc/systemd/network
-
Edit the file
25-wifi.network
:sudo nano 25-wifi.network
Displays the default configuration:
# Wifi network settings [Match] Name=wlan0 [Network] Address=192.168.0.1/24 DHCPServer=yes PoolOffset = 10 PoolSize = 40 EmitDNS = yes DNS = 8.8.8.8 8.8.4.4 DefaultLeaseTimeSec = 600 MaxLeaseTimeSec = 7200
-
Change the security setting of your WiFi (only available, if your controller contains WiFi-module):
sudo nano /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
By default the WiFi connection is configured as an Access Point to which an external system can connect using the default passphrase “vectioneer”. The default configuration is shown below.
network={ ssid="mcx-428c36" #psk="vectioneer" psk=373b4c981c2b7c30be346d560b6a7f04c313e7c66e841915db053d9d61a21bd7 mode=2 proto=RSN key_mgmt=WPA-PSK pairwise=CCMP group=CCMP frequency=2437 }
You can change the SSID by modifying the ssid field. You can enter a new passphrase by either putting the literal passphrase (readable) in quotes:
psk="mynewpassword"
Or you can generate a password hash by using the
wpa_passphrase
tool:wpa_passphrase {SSID} {NEWPASSPHRASE}
This outputs a new hashed passphrase section that you can transfer into your configuration file.
-
Save the file and reboot your controller:
sudo reboot
EtherCAT Master Configuration
The EtherCAT master needs to know which network device it will use for EtherCAT. The EtherCAT network device should not be configured for normal networking.
Make changes to the default mcx-rtos etherCAT configuration:
-
Open ethercat.conf in edit mode:
sudo nano /etc/ethercat.conf
Note
Make sure that the network device that you wish to assign to the EtherCAT driver is not already taken by the normal network configuration, see wired network configuration.
-
Modify the network device by changing the following line:
MASTER0_DEVICE="eth1"
The configured MASTERO_DEVICE, needs to match the configured network device in the EtherCAT Network Configuration.
-
Modify the driver type by changing the following line:
DEVICE_MODULES="generic"
Refer to the EtherLAB documentation for a description of all available configuration options.
-
Save the file and reboot your controller:
sudo reboot
Configure etherCAT for CX5140:
-
Open ethercat.conf in edit mode:
sudo nano /etc/ethercat.conf
Note
Make sure that the network device that you wish to assign to the EtherCAT driver is not already taken by the normal network configuration, see wired network configuration.
- Change the default
MASTERO_DEVICE:"eth1"
to registered ccat_netdev network device:
Note
Use following command to find ccat_netdev network device:
dmesg | grep ccat
[ 5.868588] ccat: loading out-of-tree module taints kernel.
[ 8.711092] ccat_netdev: DMA0 mem initialized
[ 8.711104] ccat_netdev: DMA1 mem initialized
[ 8.760589] ccat_netdev: registered eth2 as network device.
MASTER0_DEVICE="eth2"
The configured MASTERO_DEVICE, needs to match the configured network device in the EtherCAT Network Configuration.
-
Save the file and reboot your controller:
sudo reboot