Cube firmware updating and communication
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 Cube 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.
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.
- Remove modemmanager:
sudo apt remove modemmanager
- Install dependencies:
sudo apt install python3-pip libxslt1-dev
- Install mavproxy (it may take a few long minutes):
pip3 install PyYAML mavproxy
- Set up PATH:
echo "export PATH=$PATH:$HOME/.local/bin" >> ~/.bashrc
- Reload bashrc:
source ~/.bashrc
- Make sure the user has access to the serial ports (replace <<USERNAME>> by your username):
sudo usermod -aG dialout <<USERNAME>>
- Reboot the Jetson:
sudo reboot
- 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>>- <<IP> is your computer IP, <<PORT>> is the port that the ground control software is listening to (usually 14550).
- This can be used to connect ground control software such as Mission Planner, QGroundControl, etc.
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, not to be confused with "USB-0"), and not the USB port of the Cube itself.
- Connect your PC to the cube through the "USB"-connector (not "USB-0") using the provided JST-GH-USB cable.
- Power on the board and enable the voltage regulator for the Cube (if they are not by default), your PC should recognize the Cube.
- Use a standard installation method (using for example Mission Planner, APMPlanner, or QGroundControl) to install the firmware:
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).
ArduPilot Firmware
- Please first install mavproxy using the previous instructions. It will install some libraries required for the following steps.
- Connect to your Jetson (through e.g. Wi-Fi, ethernet, serial) and open a session (SSH or a terminal in remote desktop)
- Get the uploader script from the ArduPilot repository:
wget "https://github.com/ArduPilot/ardupilot/raw/master/Tools/scripts/uploader.py"
- Make the uploader script executable:
chmod +x ./uploader.py
- Download the desired firmware, for example from: [1]:
- e.g.: Cube Black:
wget "https://firmware.ardupilot.org/Copter/stable/CubeBlack/arducopter.apj"
- e.g.: Cube Black:
- 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
PX4 Firmware
- Please first install mavproxy using the previous instructions. It will install some libraries required for the following steps.
- Connect to your Jetson (through e.g. Wi-Fi, ethernet, serial) and open a session (SSH or a terminal in remote desktop)
- Get the uploader script from the PX4 repository:
wget "https://raw.githubusercontent.com/PX4/PX4-Autopilot/master/Tools/px_uploader.py"
- Make the uploader script executable:
chmod +x ./px_uploader.py
- Download the desired firmware, for example from: [2]:
- e.g.: Cube Black:
wget "https://github.com/PX4/PX4-Autopilot/releases/download/v1.12.3/px4_fmu-v3_default.px4"
- e.g.: Cube Black:
- Run the uploader. If necessary, adapt the flightstack baudrate to the value at which mavlink is set up for SERIAL2 on the Cube:
python3 ./px_uploader.py --port /dev/ttyTHS2 --baud-flightstack 57600 px4_fmu-v3_default.px4
- By default, PX4 does not communicate over TELEM2 (/dev/ttyS2 on the Cube Black). To enable it without modifying the autopilot parameters, create a file on the SD card in
/etc/extras.txt. Content should be:mavlink stop-allmavlink start -d /dev/ttyS2 -b 57600 -r 20000 -m onboard