Skip to content
Parker Lusk edited this page Jun 25, 2019 · 6 revisions

Setup ARM Toolchain

You can either use Ubuntu's apt package manager to get a (slightly outdated) ARM toolchain, or grab the latest toolcahin from https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads.

Download the toolchain, bunzip/untar, move to a sane location (/opt/) and edit your path:

$ tar jxvf gcc-arm-none-eabi-8-2018-q4-major.tar.bz2
$ sudo mv gcc-arm-none-eabi-8-2018-q4-major /opt/
$ echo 'export PATH="/opt/gcc-arm-none-eabi-8-2018-q4-major/bin:$PATH"' >> ~/.bashrc

The thing to note is that there is a gdb with python support (gcc-arm-none-eabi-gdb-py) which is required for QtCreator debugging.

ST-Link-v2 and OpenOCD

Install openocd: sudo apt install openocd. (I got v0.9.0 in June 2019).

To start the debugger (using an st-link-v2):

$ openocd -f /usr/share/openocd/scripts/interface/stlink-v2.cfg -f /usr/share/openocd/scripts/target/stm32f4x.cfg

I've noticed that with the onboard debugger on the F3 Discovery board, I have to use

$ openocd -f /usr/share/openocd/scripts/interface/stlink-v2-1.cfg -f /usr/share/openocd/scripts/target/stm32f3x.cfg

udev rules:

# /etc/udev/rules.d/99-stlink.rules

# https://gctechspace.org/2014/09/getting-to-blinky-with-the-stm32-and-ubuntu-linux/
 ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", MODE="0666"
# /etc/udev/rules.d/45-stdfu-permissions.rules

# DFU (Internal bootloader for STM32 MCUs)
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", MODE="0664", GROUP="plugdev"
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", MODE="0664", GROUP="plugdev"

Debugging with QtCreator

Installation

  1. Download the latest qtcreator from the official mirror (tested with 4.9.1)
  2. Install to /opt/qtcreator-4.9.1:
    $ chmod +x qt-creator-opensource-linux-x86_64-4.9.1.run
    $ sudo ./qt-creator-opensource-linux-x86_64-4.9.1.run
    • Skip login
  3. Dark theme
    • Tools > Options > Environment > Theme > Flat Dark

Devices and Kits Setup

(see also, http://www.iwasz.pl/electronics/stm32-on-ubuntu-linux-step-by-step/)

  1. Help > Plugins > DeviceSupport > BareMetal > check box for load
  2. Help > Plugins > Version Control > disable (prevents annoying popups when opening existing projects)
  3. Restart
  4. Tools > Options > Devices > Bare Metal > Add,OpenOCD. Defaults are good. Apply
  5. Tools > Options > Devices > Devices > Add,Bare Metal Device. Name STM32. OpenOCD GDB server provider. Apply
  6. Tools > Options > Kits > Compilers > Add (add to path, see here)
  7. Tools > Options > Kits > Debuggers > Add (rename arm-gdb, choose path to be where arm-none-eabi-gdb-py is. empty working dir is okay)
  8. Tools > Options > Kits > Add. (set name, device type, GCC/G++, GDB, QtVer:None, remove qt stuff from CMake Config)

Open an Existing Project

(see also, http://docs.rosflight.org/en/latest/developer-guide/debugging/)

  1. File > New .. Project > Import Project > Import Existing Project (select root dir of airdamon_f3; select entire source tree)
  2. Projects (sidebar) > Disable Desktop kit to prevent confusion.
  3. Projects (sidebar) > Build Settings > change build dir to wherever your Makefile is. Expand build steps details and uncheck all target (unless you need it)
  4. Projects (sidebar) > Run > Change 'run configuration' to STM32. Select the *.elf file for the project and set the working directory to the build dir (you may need to run make in the terminal for these to appear).