Skip to content

OpenTX 2.3 Windows Build Instructions

3djc edited this page Mar 4, 2021 · 11 revisions

Preparing the Build Environment

To build OpenTX 2.3 on Windows using Microsoft Visual Studio and associated tools please follow the steps listed below.

These instructions assume that you are starting from a clean slate, with nothing installed. If you already have one of the build environment tools installed you may need to adapt the instructions accordingly.

1. Install Visual Studio 2019, Community Edition

https://visualstudio.microsoft.com/downloads/

  • Under Workloads select Desktop development with C++

2. Install Qt, including the Visual Studio tools and MinGW

  1. Download the Qt Online Installer from https://www.qt.io/download-qt-installer
  2. De-select all components
  3. Expand the latest version (the top item) and select MSVC 2019 32-bit
  4. Expand Developer and Designer Tools and select MinGW 8.1.0 32-bit
  5. Click Next to install the selected tools

When the installation is finished:

  • Add these folders to the system PATH:
    • C:\Qt\Tools\mingw810_32\bin
    • C:\Qt\Tools\QtCreator\bin
  • Copy C:\Qt\Tools\QtCreator\bin\libclang.dll to the Windows System folder (C:\Windows\System32)

3. Install CMAKE

https://cmake.org/download/

  • Choose the latest Windows x64 or x86 installer as appropriate for your system
  • During the installation check the option to Add cmake to the path for all users

4. Install the latest Python Release

https://www.python.org/downloads/windows/

  • Install for all users
  • Select path in custom installation method

5. Install Python packages with PIP

For the following step open a cmd.exe Prompt by using Right click and select Run as administrator

  • pip install pillow clang pyqt5

This should finish with a listing that pillow, clang, and pyqt5 packages were successfully installed

  • You can ignore the warnings listed that pip has an updated version available

6. Download PThreads and Extract all Files

ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-8-0-release.exe

  • Using 7-Zip or similar open above .exe file and Extract contents to "C:\Programs\pthreads". "C:\Programs" typically needs to be explicitly created and is not to be confused with "C:\Program Files" nor "C:\Program Files (x86)".

7. Install GCC for ARM

https://launchpad.net/gcc-arm-embedded/4.7/4.7-2013-q3-update/+download/gcc-arm-none-eabi-4_7-2013q3-20130916-win32.exe

Note on compiler version: while this version may look old (and it is), it is the only one guaranteed to work with 2.3.x versions of OpenTX. Using other versions can (and likely will) produce issues ranging from radio not booting to pulses issues.

8. Install LibSDL

http://www.libsdl.org/release/SDL-devel-1.2.15-VC.zip

  • Unzip SDL-devel-1.2.15-VC.zip to "C:\Programs\SDL"

9. Clone or download the OpenTX source

https://github.com/opentx/opentx

Building Radio Firmware

For the following steps open a Command Prompt (cmd.exe)

Preparing the environment

SET PATH=%PATH%;C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q3\bin

SET C_INCLUDE_PATH=C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q3\arm-none-eabi\include

SET CPLUS_INCLUDE_PATH=C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q3\arm-none-eabi\include\c++\4.7.4;C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q3\arm-none-eabi\include\c++\4.7.4\arm-none-eabi

Configuring the build

  • cmake is used to configure the build.

Syntax

cmake -G "MinGW Makefiles" -S [path to source] -B [path to build folder] -DCMAKE_PREFIX_PATH=[path to Qt MSVC2019 folder] -DDISABLE_COMPANION=YES [build options]

Example

For example, to configure the firmware build for the RadioMaster TX16S:

cmake -G "MinGW Makefiles" -S C:\Temp\opentx -B C:\Temp\OpenTX-Firmware -DCMAKE_PREFIX_PATH=C:\qt\5.15.2\msvc2019 -DDISABLE_COMPANION=YES -DPCB=X10 -DPCBREV=TX16S -DINTERNAL_MODULE_MULTI=YES

Compiling the Firmware

  • mingw32-make is used to compile the firmware.

Syntax

mingw32-make -C [path to build folder] -j [number of threads] firmware

Example

For example, to compile the firmware using eight threads:

mingw32-make -C C:\Temp\OpenTX-Firmware -j 8 firmware

If the compilation succeeds, firmware.bin will be located in the root of the build folder.

Example Compilation Script

@ECHO OFF
REM Path where the firmware will be built
SET BUILDPATH=C:\Temp\OpenTX-Firmware

REM Path where the OpenTX source can be found
SET SRCPATH=%USERPROFILE%\GitHub\opentx

REM Path where the Qt compiler tools can be found
SET QTPATH=C:\Qt\5.15.2

REM Firmware build options
SET CMAKEOPTIONS=-DDISABLE_COMPANION=YES -DPCB=X10 -DPCBREV=TX16S -DINTERNAL_MODULE_MULTI=YES

REM Make the Firmware build folder
MKDIR %BUILDPATH%

REM Include GNU ARM Toolchain in the path
SET PATH=%PATH%;C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q3\bin
SET C_INCLUDE_PATH=C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q3\arm-none-eabi\include
SET CPLUS_INCLUDE_PATH=C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q3\arm-none-eabi\include\c++\4.7.4;C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q3\arm-none-eabi\include\c++\4.7.4\arm-none-eabi

REM Configure the build
cmake -G "MinGW Makefiles" -S %SRCPATH% -B %BUILDPATH% -DCMAKE_PREFIX_PATH=%QTPATH%\msvc2019 %CMAKEOPTIONS%

REM Build the firmware, using the maximum number of cores
mingw32-make -C %BUILDPATH% -j %NUMBER_OF_PROCESSORS% firmware

Building Companion

For the following steps open a cmd.exe Prompt by using Right click and select Run as administrator

Configuring the build

  • cmake is used to configure the build. It will create a Visual Studio solution file and several project files.

Syntax

cmake -A win32 -S [path to source] -B [path to build folder] -DCMAKE_PREFIX_PATH=[path to Qt MSVC2019 folder] [build options]

Examples

For example, to configure the build for the RadioMaster TX16S (in order to build the TX16S simulator library):

cmake -A win32 -S C:\Temp\opentx -B C:\Temp\OpenTX-Companion -DCMAKE_PREFIX_PATH=C:\qt\5.15.2\msvc2019 -DPCB=X10 -DPCBREV=TX16S -DINTERNAL_MODULE_MULTI=YES

A second example, to configure build for Taranis X9D+ (not 2019) with "noheli" option (and to build the X9D+ sim library):

cmake -A win32 -S C:\Temp\opentx -B C:\Temp\OpenTX-Companion -DCMAKE_PREFIX_PATH=C:\qt\5.15.2\msvc2019 -DPCB=X9D+ -DPCBREV=2014 -DHELI=NO

Compiling Companion

The easiest way to compile Companion is by building the INSTALL project.

At the end of the build the Companion and Simulator executable files will be in the Releases sub-folder of the build folder.

Note: At this time building the INSTALL project does not actually put all the required DLL files in the output folder. A simple way to overcome this is to build the project using a script which finishes the build by putting all the dependencies in the Releases folder.

Example Compilation Script

@ECHO OFF
REM Path where Companion will be built
SET BUILDPATH=C:\Temp\OpenTX-Companion

REM Path where the OpenTX source can be found
SET SRCPATH=%USERPROFILE%\GitHub\opentx

REM Path where the Qt compiler tools can be found
SET QTPATH=C:\Qt\5.15.2

REM Companion build options
SET CMAKEOPTIONS=-DPCB=X10 -DPCBREV=TX16S -DINTERNAL_MODULE_MULTI=YES
REM SET CMAKEOPTIONS=-DPCB=X9D+ -DPCBREV=2014 -DHELI=NO

REM Make the Companion build folder
MKDIR %BUILDPATH%

REM Import the Visual Studio command line build environment
CALL "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\Common7\Tools\VsMSBuildCmd.bat"

REM Configure the build
cmake -A win32 -S %SRCPATH% -B %BUILDPATH% -DCMAKE_PREFIX_PATH=%QTPATH%\msvc2019 %CMAKEOPTIONS%

REM Build the INSTALL project
msbuild %BUILDPATH%\INSTALL.vcxproj /t:Build /p:Configuration=Release

REM Move the resource DLLs into the Release folder
MOVE %BUILDPATH%\*.dll %BUILDPATH%\Release

REM Install the Qt dependencies in the Release folder
%QTPATH%\msvc2019\bin\windeployqt.exe --no-translations --no-opengl-sw --no-system-d3d-compiler --no-angle --no-compiler-runtime -dir "%BUILDPATH%\Release" %BUILDPATH%\Release\companion.exe %BUILDPATH%\Release\simulator.exe

Troubleshooting

fatal error C1060:

Building Companion on Windows 32bit system you may encounter:

  • fatal error C1060: compiler is out of heap space
  1. Open a cmd.exe Prompt by using Right click and select Run as administrator
  2. C:\ > bcdedit /set IncreaseUserVa 3072
  3. Restart Windows to enable access to 3GB switch in Win 32bit systems
Clone this wiki locally