Cube firmware updating and communication

From Take-Air Wiki
Jump to navigation Jump to search

Introduction

To communicate with the Cube, the Open.OC 2 board has a permanent UART connection between the Jetson (/dev/ttyTHS2) and the Cube (SERIAL2). This link can -among other things- be used to transfer telemetry data, send flight commands to the Cube, and upload the Cube firmware.

In this guide we describe how to communicate with the Cube through Mavlink using mavproxy, and how to flash the firmware of the Cube. The firmware on the Cube can be updated in two ways: Via a direct USB connection to a PC or through the Jetson module over UART. This guide describes both methods. When updating through USB, the process is the same as one would do on the default Pixhawk carrier board and this method is therefore compatible with any autopilot software. For the UART method we describe how to do the update for Ardupilot.

Connectors.png

Mavlink communication with the Cube (mavproxy)

The Cube must be configured to communicate over Mavlink (either v1 or v2) over SERIAL2. By default, Ardupilot has this configured at a baud rate of 57600bps.

If not done yet, mavproxy must be installed. It is recommended to use a virtual environment (such as virtualenv) to keep installed packages disentangled.

  1. Remove modemmanager:
    sudo apt remove modemmanager
  2. Install dependencies:
    sudo apt install python3-pip libxslt1-dev
  3. Install mavproxy (it may take a few long minutes):
    pip3 install PyYAML mavproxy
  4. Set up PATH:
    echo "export PATH=$PATH:$HOME/.local/bin" >> ~/.bashrc
  5. Reload bashrc:
    source ~/.bashrc
  6. Make sure the user has access to the serial ports:
    sudo usermod -aG dialout <<USERNAME>>
  7. Reboot the Jetson:
    sudo reboot 0
  8. After reboot, log in again. You can now start mavproxy (adapt baudrate if necessary):
    mavproxy.py --master=/dev/ttyTHS2 --baudrate=57600

When connected successfully you should see messages from the Cube coming in. If you wish to forward the data over -for example- UDP you can do so using:

   mavproxy.py --master=/dev/ttyTHS2 --baudrate=57600 --out=udp:<<IP>>:<<PORT>>

This can be used to connect ground control software.

For a full guide on mavproxy, see: https://ardupilot.org/mavproxy/

Firmware update over USB (through host PC)

Imporant: To update over USB you must use the "USB"-connector on the board (see diagram and printing on the board itself, not to be confused with "USB-0"), and not the USB port of the Cube itself.

  1. Connect your PC to the cube through the "USB"-connection (not "USB-0") using the provided JST-GH-USB cable.
  2. Power on the board, your PC should recognize the Cube
  3. Use a standard installation method (using for example Mission Planner, APMPlanner, or QGroundControl) to install the firmware:
    Ardupilot: Mission Planner instructions, APM Planner instructions, QGroundControl instructions
    PX4: QGroundControl instructions

Firmware update over UART (through Jetson)

This method can be done 'in situ': It does not require opening the drone to install a cable to the carrier board. Instead, the update is done over the integrated UART-connection between the Jetson module and the Cube. To use this method, it is required that the currently running firmware on the Cube is configured to communicate over Mavlink on SERIAL2. To verify this you can use mavproxy to connect to the Cube from the Jetson (see above for mavproxy instructions).

  1. Connect to your Jetson (through e.g. Wi-Fi, ethernet, serial) and open a session (ssh or a terminal in remote desktop)
  2. Get the uploader script from the ardupilot repository:
    wget "https://github.com/ArduPilot/ardupilot/raw/master/Tools/scripts/uploader.py"
  3. Make the uploader script executable:
    chmod +x ./uploader.py
  4. Download the desired firmware, for example from: [1]:
    e.g.: wget "https://firmware.ardupilot.org/Copter/latest/CubeOrange/arducopter.apj"
  5. Run the uploader. If necessary, adapt the flightstack baudrate to the value at which mavlink is set up for SERIAL2 on the Cube:
    python3 ./uploader.py ./arducopter.apj --port=/dev/ttyTHS2 --baud-flightstack=57600