How do you configure a Pixhawk 5X's ethernet interface with a static IP address?

Hi,

I’m trying to configure the Ethernet interface on my Pixhawk 5X (v1.12.3) to use a static IP address, to communicate with my companion computer. However, the lack of available documentation is hampering my efforts, and was wondering if there’s a guide / tutorial on how to configure this.

Thanks,
Donald

Playing around, I’m able to ping between the two by configuring the following:

  • Setting MAV_1_CONFIG to Ethernet and exposing the following two parameters.
  • Leaving MAV_1_REMOTE_PRT and MAV_1_UDP_PRT as its default value of 0
  • Setting my companion computer to use a 192.168.0.X address
    • (The Pixhawk defaults to a 192.168.0.X address by default)

However, there are still problems:

  • This requires changing the companion computer from its original address of 10.1.1.X, which breaks compatibility with the rest of the system. This is the topology I’m aiming for:

image

  • No MAVLink data is emitted from the Pixhawk despite the successful ping. The only thing coming over to and from the interface are DNS queries

  • The MAVLink interface on the Pixhawk reports no successful TX, only TXError

3 (2)

Additionally would it be possible to connect both the companion computer and QGC to use the same Ethernet network, as depicted in the topology above?

Rather then having a serial line dedicated for QGC, and an Ethernet line dedicated for the companion computer.

Hello,
If not too late you can do that by putting a net.cfg file on the SD card root folder.
Here is an example for my configuration (the content of the net.cfg file)

DEVICE=eth0
BOOTPROTO=static
NETMASK=255.255.255.0
IPADDR=10.0.0.2
ROUTER=10.0.0.1

1 Like

I’ve managed to configure it as follows:

PX4 Ethernet Network

DEVICE=eth0
BOOTPROTO=fallback
NETMASK=255.255.255.0
IPADDR=192.168.0.4 [Chosen Static IP for Pixhawk 5x]
ROUTER=192.168.0.1 [Default Route]
DNS=192.168.0.1 [DNS Server(1)]

  1. Plug Pixhawk 5x with USB cable on system with QGroundControl or PX4-Autopilot.
  2. Use MAVLink Console on QGroundControl or mavlink_shell.py from PX4-Autopiot.
  3. Use the commands as follow:

echo DEVICE=eth0 > /fs/microsd/net.cfg
echo BOOTPROTO=fallback >> /fs/microsd/net.cfg
echo IPADDR=192.168.0.4 >> /fs/microsd/net.cfg
echo NETMASK=255.255.255.0 >>/fs/microsd/net.cfg
echo ROUTER=192.168.0.1 >>/fs/microsd/net.cfg
echo DNS=192.168.0.1 >>/fs/microsd/net.cfg

  1. Remove the USB-Cable.
  2. When the Pixhawk 5x turns on, check with netman show if the configuration was saved.

Raspberry Pi 4 Network

  1. Create file for deactivate Cloud-Init with

sudo nano /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

and write:

network: {config: disable}

  1. Create file for Static-IP with

sudo nano /etc/netplan/01-static-ip.yaml

and write:

network:
  version: 2
  renderer: networkd
  wifis:
    wlan0:
      addresses: [192.168.0.2/24]  #[This is the chosen Static-IP]
      gateway4: 192.168.0.1 [Default Route]    
      nameservers:
        addresses: [192.168.0.1, 8.8.8.8]
      access-points:
        "my_wifi":
          password: "my_password"
      optional: true
  1. Create file for Ethernet Port with

sudo nano /etc/netplan/01-network-manager-all.yaml

and write:

network:
  version: 2
  renderer: NetworkManager
  ethernets:
      eth0:
          addresses:
              - 192.168.0.2/24 #[This is the chosen Static-IP]
          nameservers:
              addresses: [192.168.0.2]
          routes:
              - to: 192.168.0.2
                via: 192.168.0.2
          optional: true
  1. Use command sudo netmann apply

Parameters Configuration

  1. Set parameters as follows:

Parameter Value Description
RTPS_CONFIG 401 Pixhawk Payload Bus
MAV_0_CONFIG 0 Disable Serial Configuration for MAVLink (instance 0)
MAV_1_CONFIG 0 Disable Serial Configuration for MAVLink (instance 1)
MAV_2_CONFIG 1000 Configure Ethernet port
MAV_2_BROADCAST 1 Broadcast HEARTBEAT messages
MAV_2_MODE 2 Send the “normal” set of MAVLink messages (i.e. the GCS set)
MAV_2_RADIO_CTL 0 Disable software throttling of MAVLink traffic
MAV_2_RATE 100000 Maximum sending rate
MAV_2_REMOTE_PRT 14540 MAVLink Remote Port of 14550 (GCS)
MAV_2_UDP_PRT 14540 MAVLink Network Port of 14550 (GCS)

Running

  1. Open MAVLink Console on QGroundControl and use command micrortps_client start -t UDP -i 192.168.0.2 [IP Adress from RPi 4]
    or use mavlink_shell.py and use the same command.

  2. Access the RPi 4 through SSH and type command micrortps_agent start -t UDP

2 Likes

@donald.nguyen Hopefully solved but we added the guide for it: