» S

Compiling The AQ Firmware: A short introduction

Since the AutoQuad firmware is Open Source you can change the code for your needs, test it and contribute it back to the community.  You will already find some user contributions like Menno’s external signaling of the various flight modes and states via LED or beeper.  A short how-to set PWM frequencies for gimbal support can be found here.

Prerequisites & Preparation

  • AQ firmware source code (use SVN to check out a copy from the Google Code repository).
  • MAVLink libraries, pre-built for AQ (download at GitHub).  You only need the contents of the mavlink/include folder.
  • Download STM32F4xx_DSP_StdPeriph_Lib_V1.3.0 from our FTP site and unpack/install it next to your onboard and mavlink folders.
  • A supported STM32/ARM toolchain and build environment.  Currently this is Rowley’s CrossWorks Studio for ARM (only version 2.3.x is currently supported, not 3.x). You can download a fully functional evaluation version here.  Alternatives are discussed in this forum thread. You can also use MAKEFILE from the “onboard” folder. A short how-to can the found in this forum thread.

Note: AQ firmware versions starting at r187 require CrossWorks Studio version 2.3.2 or greater (but not 3.x).
Existing releases can be downloaded from here.

Place the mavlink folder next to (in the same root as) the onboard folder from the AQ repository.  The folder structure should look like this:

    / - mavlink 
    / - onboard
    / - STM32F4xx_DSP_StdPeriph_Lib_V1.3.0


If compiling firmware versions before r215, please manually adjust the mavlink include path in the project settings, as outlined in this forum post (you need to do this even if not needing telemetry).

After installation, start up CrossWorks.  You first need to select for which MCU this studio will be used. In the package manager you can select the STM32 support package and install that one. You only need to do it once.

After installing the studio and needed support package you can open the appropriate *.hzp file (called “solution”) from the “onboard” folder in CrossStudio from the “File” menu.

Now follow the instructions as in the next screen:

If everything works without compilation errors you will be rewarded by an aq*.hex file in the recently created “Thumb Release” folder. You can now proceed with flashing the *.hex file onto your AutoQuad Flight Controller.

Hardware revisions

Depending on the hardware revision number of your AQ board, you may need to customize the source files to suit your hardware.  To do this, set the value of the BOARD_REVISION macro in aq.h.  Alternatively, you can also pass BOARD_REVISION macro to the compiler directly (eg. -DBOARD_REVISION=1), see screenshot below in DIMU instructions for an example.

For revision 0 boards:

    // aq.h
    #ifndef BOARD_REVISION
        #define BOARD_REVISION    0

For revision 1 boards, or when the resistor R4 is replaced by the new value 8.45K, simply set BOARD_REVISION equal to 1 and recompile.

    // aq.h
    #ifndef BOARD_REVISION
        #define BOARD_REVISION    1

Compiling for DIMU

To build firmware which supports the DIMU add-on for version 6 hardware, you need to add a macro before compiling.  The production version of the DIMU is 1.1, so the macro you need to set is:

#define DIMU_VERSION 11

You can either add this directly to the source code (at the top of aq.h is a good place), or add the macro to the compiler command line.  Here is a screenshot showing how to do that (and also notice the commented-out #defined DIMU_VERSION, as an example of a good place to place that).


Producing a .bin file for flashing via USB (M4 and ESC32 v3)

CrossWorks-bin-fileSelect “bin” as Additional Output Format under Linker Options (be sure Project ‘autoquad’ is selected in Project Explorer window!).

This page was created on 18-Jun-12 by menno. Last modified on 16-Feb-15 by MaxP.