mcx-rtos v.2022.03 Network Configuration

How to change the network configuration on your controller for MCX-OS image v.2022.03

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
├── 10-igb-quirks.link
├── 25-wifi.network
├── 50-wired.network
└── 51-ethercat.network

The network directory displays the default network configuration for WiFi, Wired and EtherCAT based on Systemd.network.

Wired Network Configuration

How to change the wired network settings:

  1. Navigate to the network directory:

    cd /etc/systemd/network
    
  2. Edit 50-wired.network:

    sudo nano 50-wired.network
    

    Displays the default configuration:

    # Wired network settings
    [Match]
    Name=eth0
    
    [Network]
    DHCP=yes
    IPForward=yes
    
    [Address]
    Label=eth0:0
    Address=192.168.2.100/24
    

    This configuration tries to configure a connection with DHCP and in case there is no DHCP server on your network it configures a static IP.

    You can change the static IP address to what you prefer.

  1. Save the file and reboot your controller:

    sudo reboot
    

Now your wired network settings are changed!

EtherCAT Network Configuration

How to change the etherCAT network configuration:

The network device that is used for etherCAT must be configured as unmanaged such that the regular network driver do not claim the device.

  1. Navigate to the network directory:

    cd /etc/systemd/network
    
  2. Edit 51-ethercat.network:

    sudo nano 51-ethercat.network
    

    Displays the default configuration:

    # EtherCat network settings
    [Match]
    Name=eth1
    
    [Link]
    Unmanaged=yes
    

    Here we reserve device eth1 for etherCAT and make sure it does not get attached to a regular network driver.

  3. Save the file and reboot your controller:

    sudo reboot
    

WiFi Configuration

How to change the wifi configuration:

  1. Navigate to the network directory:

    cd /etc/systemd/network
    
  2. 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   
    
  3. Change the security setting of your WiFi:

    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.

  4. Save the file and reboot your controller:

    sudo reboot
    

EtherCAT Device 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.

  1. Change the EtherCAT network settings:

    sudo nano /etc/ethercat.conf
    

    The important settings in this file are which network adapter to use and which driver to use.

  1. You can select your network adapter by modifying the following line:

    MASTER0_DEVICE="eth1"
    
  2. To select the driver type, change the line:

    DEVICE_MODULES="generic"
    

Refer to the EtherLAB documentation for a description of all available configuration options.

  1. Save the file and reboot your controller:

    sudo reboot
    

cert-gen Configuration

It is possible that due to the network change the communication certificate has become invalid. For security reasons, the certificate is only valid for the ip address and hostname of the controller. MCX-Linux OS provides a certificate renewal service that checks the certificate and renews it if either it has expired or if the host name or ip address has changed.

  1. Stop motorcortex:

    sudo motorcortex stop
    
  2. Edit cert-gen settings:

    sudo nano /usr/share/cert-gen/config.json
    

    Displays the default configuration:

    {
        "days":               365,
        "commonName":         "Motorcortex",
        "organizationalUnit": "Development",
        "organization":	  "",
        "country":            "",
        "locality":           "",
        "province":           "",
        "ip": ["192.168.2.100"],
        "hostname": ["motorcortex"]
    }
    
  3. Change "ip" and "hostname" to the current network settings and save file.

  4. Restart the service to generate the new certificate:

    sudo /etc/init.d/cert-gen restart
    
  5. Start motorcortex:

    sudo motorcortex start