Firmware Development Environment Setup

The following guide will help you setup the development environment for embedded development with the Zeropilot. If you're just joining our team, only do the steps marked "mandatory". All "optional" may become mandatory for you in the future, depending on what sort of tasks you're picking up.

First things first (all steps mandatory)

To develop anything at all, you're going to need a text editor, command line access, and cmake.

Text editor (mandatory)

What text editor you use is entirely up to you. Anything from vim to visual studio is fine. If you don't have a preferred one yet, I'd suggest sublime text or visual studio code as quite a few of our members use those.

Command line (mandatory)

All our code is built, tested, simulated, and pushed to Github from the command line. In linux or mac, you'll be using the terminal and in windows, you'll be using git bash. You can do everything (except uploading code to the microcontrollers) from WSL as well.

Cmake (mandatory)

CMake is a simple, cross-platform build system. We use it to build everything on all supported operating systems (ask someone what's going on if you're curious about build systems).

IMPORTANT: Be sure to select the checkbox that says "Add CMake to system PATH".

  • Download link (pick the binary distribution that's right for your system)

To make sure Cmake is properly installed, open the command line and type "cmake". If the cmake help menu comes up, you’re good to go.

Building the code (some steps mandatory)

The Zeropilot consists of two MCUs (Microcontroller Units). A STM32F7 and an STM32F0. Both of these are ARM chips (the same chips that can be found in your phones and new Macs!). The project is written in C++ (primarily) with some parts in C. The process under which our code gets converted into a binary is called a toolchain. When developing our firmware, there are 3 different toolchains you will need to setup to cover 3 types of builds.

Target build (mandatory)

Building for the target means converting the C++/C code into binary that can be understood by the microcontrollers on our hardware. Setting up this toolchain is mandatory and instructions for doing that can be found here.

Unit test build (mandatory)

Unit tests are used to make sure our code is bug free. The tests run locally, on each of our computers, so this toolchain converts our C/C++ code into an x86_64 binary.

Because writing unit tests is mandatory, setting up this toolchain is also mandatory and instructions for doing that can be found here.

Simulation build (optional)

The team leverages simulation to ensure that the entirety of the autopilot firmware is capable of flying the airplane the way we want it to fly. Depending on what you’re developing though, setting up the simulation stuff is optional. The simulations run locally, on each of our computers, and so they share some the unit testing toolchain. However, setting up the simulation requires a few more steps which can be found here.

Getting Started

To get started developing for the ZeroPilot firmware, you will need a few things:

Git

Git is the version control system we use to manage changes in our code. If you aren't already familiar with Git, there are many resources to help you learn:

CMake

CMake is a simple, cross-platform build system. It's used for building and uploading all the code for the ZeroPilot project. Be sure to select the checkbox that says "Add CMake to system PATH".

  • Download link (pick the binary distribution that's right for your system)

GNU ARM Embedded

GNU ARM Embedded is the toolchain (compiler, linker, etc.) that will be used to build the software for ZeroPilot.

On Windows, you will likely need GNU Windows build tools to build the project (unless you have MinGW installed).

If you use MacOS and your code still does not build, refer to here.

A Code Editor

No fancy IDE (Integrated Development Environment) is needed to develop ZeroPilot. Instead, we just use code editors and some common programming tools. A code editor is just a text editor that has been designed for easily writing code, and almost all code editors have plugin support for additional languages or features.

Some options:

If you must use an IDE, your best bet will likely be JetBrains CLion. You can get a free license for as long as you are a student.

St-Link (Optional)

To setup ST-link, visit ST-Link Drivers. Download the ST-link driver and ST-link utility. Once you download these, you should be able to connect to the board. You can verify this by opening the ST-Link utility and clicking "Connect" with the board powered and plugged into the programming port.

Uploading/debugging the code (optional)

To actually run your code on the hardware, you've got a couple options. You can either do things from STM's IDE (which allows you to have a gui for the debugger and a few other nice tools (this is the easiest, and recommended way to do things), you can set things up the way you want inside the jetBrains CLion IDE, or you could do everything straight from the command line. All three options are described here:

  • apt update

  • QT networks

    • Linux: sudo apt install qt5-default

    • MacOS: brew install qt5

    • Windows: fuck windows

  • flightgear

Setting Up

Let's get started setting up your environment! First things first, fork and clone the project using git: https://github.com/UWARG/ZeroPilot-SW.

If you're not sure how to do that, check out the GitHub Guides in the first section.

Navigate to the the "Autopilot" directory and try to build the project.

Building the Project

Autopilot

  • ./Tools/build.bash -c

  • ./Tools/build.bash -c -t

Safety

  • ./Tools/build.bash -c

  • ./Tools/build.bash -c -t