More about Flashing:
Flashing is the process by which your computer communicates to an external programmer over USB, and flashes the target MCU with the binary you generated using the toolchain. The external programmers are called STLink progammers, and are designated by several version numbers. The ones we have in the bay are either STLinkV2 or STLink V2.1 programmers, and look like this:
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.
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.
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)
Install GNU Windows build tools
- so you have
make
on your systemInstall 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)
Open up a terminal window
Install homebrew
Run.
brew install git arm-gcc-bin cmake open-ocd
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
Clone the repo with: `git clone https://github.com/UWARG/ZeroPilot-SW `
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 thebuild/
folder that you can use for flashing.
Building with CLion
Once CLion is downloaded, open up either the
Autopilot
orSafety
project. Make sure your version is 2018.3 and not the latest once, as a critical plugin isn't supported by the latest versionYou should be prompted to install the OpenOCD + STM32CubeMX plugin. If not, go to Settings->Editor→Plugins and install it:
Afterwards, you should have listed a series of configurations for building the project on the top right:
Now you should configure CMake properly for the project. Go into Preferences→Build & Execution → CMake. Modify the Debug profile, and make sure the contents
of the CMake Options
field are the following:
For the Safety project:
-DCMAKE_BUILD_TYPE="Debug" -DCMAKE_TOOLCHAIN_FILE="STM32F030xx.cmake"
For the Autopilot Project:
-DCMAKE_BUILD_TYPE="Debug"
-DCMAKE_TOOLCHAIN_FILE="STM32F765xG.cmake"
Optionally modify the Release profile with the same settings, but the set the debug build type flag to be "Release" instead of "Debug"
Most of the time you'll wanna select the STLINKV2 configuration, since we have very few programmers that are STLINKV2.1. Click the play button to flash the chip, or the bug button to debug it!
Install instructions for flasher/debugger (only for windows atm):
Install the st-link drivers mentioned above
Download st-link
unzip st-link and place its contents in program files (x86)
Add C:\Program Files (x86)\stlink-1.6.1-x86_64-w64-mingw32\bin to your path environment variable
To begin a debug session:
plug the programmer into the board and into your computer
power the board
execute ZeroPilot-SW/Autopilot/Tools/debug.bat
A couple windows will open, one of them runs gdb. The program is now under your control, you may use gdb as you wish (run "continue" to begin executing the program)
Add Comment