Download and unpack the gcc-arm-embedded toolchain.
Download the latest FreeRTOS release. We're using version 7.3.0.
Unpack the ZIP file in a directory near the smaccmpilot-stm32f4 tree: the same parent directory is best. We will refer to the path of the unzipped source tree during build configuration.
Many of the libraries in the SMACCMPilot software are from the ArduPilot project.
Clone the Galois fork of the ArduPilot repo, using the master
branch.
Keep this clone in a directory near the smaccmpilot-stm32f4 tree, as you did
with the FreeRTOS sources.
- Copy
Config.mk.example
toConfig.mk
. Open this file in a text editor. - Set
CONFIG_CORTEX_M4_PREFIX
to the location of the Cortex-M4 toolchain. - Set
CONFIG_FREERTOS_PREFIX
to the location of the FreeRTOS source. - Set
CONFIG_ARDUPILOT_PREFIX
to the location of the Ardupilot source. - Set
CONFIG_BOARD
topx4
for the PX4FMU, orstm32f4-discovery
.
- Simply run
make
from the top-level directory. You can also specify a specific target such aslibhwf4.a
. - Build output is placed in the
build
directory. The test program images are in thebuild/$(CONFIG_ARCH)/$(CONFIG_BOARD)/img
directory.
We use the Black Sphere Technologies Black Magic Probe as a JTAG/SWD debugger to flash and debug on the PX4FMU hardware.
- Follow the instructions on the PX4 wiki for setting up your Black Magic Probe.
- Start GDB:
arm-none-eabi-gdb
- Connect to the Black Magic Probe:
target extended-remote /dev/ttyACM0
- Scan the single-wire debug adapters:
mon swdp_scan
- This should display a single result, such as:
1 STM32F4xx
. - Attach to this target:
attach 1
- Load the image to flash:
file build/cortex-m4/px4/img/ledtest
- Flash the image to the device:
load
- Execute the firmware:
run
- Interrupt the debugger with Control-C to reflash by running
load
andrun
again.
On the STM32F4-Discovery board, we find it easier to use the builtin STLink debugger with OpenOCD. (If you're only using the Black Magic Probe with the PX4FMU, you can skip this section.)
- Download a recent release of OpenOCD We have tested with version 0.6.1.
- Configure and install OpenOCD with:
$ tar -zxvf openocd-0.6.1.tar.gz
$ cd openocd-0.6.1
# NOTE: you may not need all of these flags
$ ./configure --enable-ftdi --enable-ft2232_libftdi --enable-stlink \
--enable-amtjtagaccel --enable-buspirate
$ make
$ sudo make install