Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

There’s a few ways of doing this. The way I recommend is to use ST’s ide, but this guide will also explain the legacy way of doing it from the command line and setting up your own tools in a separate IDE.

Also, since your’e you’re here and looking to deal with hardware, odds are your’e probably going to need ST's CubeMX tool to generate particular HAL drivers. If there’s no guide for doing that at the time your’e you’re reading this, ask someone who knows what they’re doing to write one. But anyway, back to flashing/debugging.

...

For this, you're going to have to download ST's ID. There’s versions available for Linux, Mac and Windows, so you should be good. Now, here are the instructions:

  1. In the IDE, create a new project. You can do this by clicking File->new->STM32 project.

  2. This will open up the target selector.

    Image Modified

    In the part number field, enter the part number of the relevant microcontroller (STM32F765ZG for the autopilot chip and STM32F030RC for the safety chip). Choose that part and click next.

  3. Now, give the project a name, select C++, empty, and click finish.

    Image Modified

  4. Now, click on the green bug in the task bar

    Image Modified

  5. This will pull up the debug configuration menu. You have to point the debugger to the elf file we built with our build system rather than the garbage that STM defaults to. So browse for the project. Our elf files are located in ZeroPilot-SW\Autopilot\build and are produced after a successful build.

    Image Modified
  6. Sweet, now just make sure your debugger is plugged in, connected to the board, and everything is powered on. Hit apply then OK to begin the debug session.

  7. It is possible that upon launching the debug executable, ST has a hard time finding the source files. If that’s the case, just open the corresponding source files in the IDE (File->Open File)

  8. Awesome, your’e good to go. If your’e new to debugging in an eclipse based IDE, I’d recommend looking for some tutorials on YouTube to get familiar with doing that.

The VSCode Way

For those who are not interested in downloading and installing cubeide, you should be able to make vscode handle intellisense, build, flash, and debug processes with some basic configuration.

...

These programmers connect to the Zeropilot board via a 5 pin cable that's usually custom made. They communicate over the SWD protocol, which also allows for in-step debugging! To actually flash the chip, you've got two options.

  1. Using the official flashing software (Windows ONLY): 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.

  2. Using Open-OCD - this is an open source project that allows for debugging and flashing of MANY MCU and programmer combos. You can also integrate it with CLion to get debugging through the IDE


You don't need both! Either Open-OCD or ST-Link will do

Installation (Windows)

  1. Install GNU Windows build tools

    - so you have make on your system

  2. Install the rest of the tools above, following the web page instructions


When installing CMake, make sure you tick the checkbox that asks if you wanna add it to you PATH

Installation (macOS)

  1. Open up a terminal window

  2. Install homebrew

  3. Run.    brew install git arm-gcc-bin cmake open-ocd

  4. If you're installing Clion, installing CMake is optional in the above command ^^. Also make sure to install version 2018.3, and not the latest version!

Building

  1. Clone the repo with: `git clone https://github.com/UWARG/ZeroPilot-SW `

  2. If you have CMake locally installed and in your path, cd into ZeroPilot-SW/AutoPilot (or into ZeroPilot-SW/Safety if your'e developing for the safety chip) and run the build script with: ./Tools/build.bash. This will generate a .elf and .bin file inside the build/ folder that you can use for flashing.

Building with CLion

  • Once CLion is downloaded, open up either the Autopilot or Safety project. Make sure your version is 2018.3 and not the latest once, as a critical plugin isn't supported by the latest version

  • You should be prompted to install the OpenOCD + STM32CubeMX plugin. If not, go to Settings->Editor→Plugins and install it:

...