Skip to content

Companion 2.1 Linux Build Instructions

johnfwhitmore edited this page Sep 20, 2017 · 7 revisions

Please note that there are build dependencies from OpenTX Companion to the OpenTX firmware. This means that the complete OpenTX code base, not just the Companion part, must be available. It also means that you have to install the OpenTX firmware build chain before you continue.

Additional note: If you are building a new version of the Companion software, you will need to copy the hex file from radio/src to where ever you keep your firmware files to be written to the radio.

Install Build Toolchain

You need to retrieve the following products ...

Retrieve the following packages on Fedora

On Fedora >= 26 the following command retrieves all the needed packages

sudo dnf install git svn qt qt-devel cmake patch xsd gcc-c++ SDL-devel phonon phonon-devel xerces-c-devel PyQt4 python2 avr-gcc

On Fedora >= 22 the following command retrieves all the needed packages

sudo dnf install git svn qt qt-devel cmake patch xsd gcc-c++ SDL-devel phonon phonon-devel

On Fedora < 22

sudo yum install git svn qt qt-devel cmake patch xsd gcc-c++ SDL-devel phonon phonon-devel

Retrieve the following packages on Ubuntu or Mint

On the Debian based distributions, the following command retrieves all the needed packages (note: A few are probably not needed anymore. ruby and libqtwebkit-dev are removal candidates. But they will not hurt) NOTE: QT4 may need to be updated from the link above

sudo apt-get install git subversion gcc-avr avr-libc avrdude build-essential ruby libqtcore4  libqt4-dev qt4-qmake g++ cmake libxerces-c-dev xsdcxx libsdl1.2-dev libusb-1.0-0 libphonon-dev phonon libqtwebkit-dev python-qt4 python-qt4-dev

Install cmake 2.8.12

At the time of writing cmake 2.8.12 is not included in the Debian/Ubuntu/Mint repositories. The Companion build however requires at least this version. It will no doubt be available soon, but until then, you have to build it manually. Start by checking your installed version:

cmake -version

If the result is less than 2.8.12 you need to do the following

wget http://www.cmake.org/files/v2.8/cmake-2.8.12.tar.gz
tar xzf cmake-2.8.12.tar.gz
cd cmake-2.8.12
./configure
make
sudo make install

Check the version again to establish that you have really installed version 2.8.12

cmake -version

Set up the source code tree structure

Navigate to wherever you want to store the source code. Issue the following command (it will take quite a while to complete):

git clone -b 2.1 https://github.com/opentx/opentx

Git has now set up a repository clone in a folder called opentx with content from branch 2.1 of the project.

In the past, the branches were named master and next. They no longer seem to exist in the repository and since we are building the 2.1 version, going with 2.1 branch is a safe choice.

Enter the opentx/companion folder and create a build folder here:

cd opentx/companion
mkdir lbuild

This folder is where you should build Companion. Building here avoids mixing temporary build files with the source code.

Build Companion

In order to be able to build Companion a Makefile has to be created. You have to select if you are going to build a debug or release version.
For a release version you enter:

cd lbuild
cmake ../src

Alternatively, for a debug version you enter:

cd lbuild
cmake  -D CMAKE_BUILD_TYPE=Debug ../src

In either case we are now ready to compile Companion

make clean
make

When the build process completes you will have a binary file named "companion21".

You can start OpenTX Companion in the folder like this:

./companion21

Or do a proper installation like this:

make install

Enable non-root use of USBASP programmer

If you intend to use an USBASP device to communicate to Atmel equiped radios (the 9x and 9XR), you have to enable AVRDUDE to run without root priviliges.
If you do not do this you will always have to run Companion with root priviliges, which is not a good practice.
Plug in the programmer and run

lsusb | grep libusb

You should get a line like this:

Bus 003 Device 002: ID 16c0:05dc VOTI shared ID for use with libusb

Notice the two numbers after ID XXXX:YYYY
In next command replace XXXX and YYYY with the numbers.

sudo echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="XXXX", ATTR{idProduct}=="YYYY", GROUP="adm", MODE="0666"' > /etc/udev/rules.d/10-usbasp.rules

then execute

sudo restart udev

Setup SAM-BA for Sky9x / 9XR-PRO boards on 64bits Fedora

sudo yum install tk libX11.i686 libXScrnSaver.i686 libXft.i686
wget http://downloads.open-tx.org/tools/sam-ba/sam-ba_2.11.zip
unzip sam-ba_2.11.zip
cd sam-ba_cdc_cdc_linux/
./sam-ba 

Joystick support

Companion does support joystick for firmware simulator control.
The latest version of SDL by default uses a device that cannot be calibrated properly by the OS.
To avoid problems use the following command before launching Companion:

export SDL_JOYSTICK_DEVICE=/dev/input/js0

Where js0 is your joystick / RC Sim adapter.
or write

SDL_JOYSTICK_DEVICE=/dev/input/js0

in /etc/environment

In Companion you will have two joysticks. Choose the first one.
If you experience calibration problems, have a look to the jscal utility.

calibrating:

jscal -c /dev/input/js0

directory for storing:

mkdir /var/lib/joystick

store the calibration:

jscal-store /dev/input/js0
Clone this wiki locally