Repository navigation
4. How to setup for development
Development for the Wunderkiste firmware can be done with many different tools, but here's the recommended setup:
-
gitfor sourcecode management -
Visual Studio Codeas a text editor / debugging host / IDE -
clang-formatauto-formatting -
gcc-arm-none-eabicompiler and toolchain (version 9-2020-q2-update) -
openocdgdb debugging server for connecting to the board
Wunderkiste is hosted as a git repository. It is helpful to have a basic understanding of what git is and how it's used. I recommend to read this tutorial if you feel unsure.
git can be fully used from the command line, but many prefer to user a graphical user interface like Fork, Sourcetree or Github Desktop. Any of these will be very helpful for a beginner as they visualize the history of changes and the state of your local working copy of the code.
A graphical git client (like the ones mentioned above) often brings its own version of git, so you usually don't have to install your own version of git.
If you plan on contributing code to the project, you'll need an account on github. Also make sure to configure your git client (or your local git installation) so that any changes (commits) you make to the code are correctly attributed to your user account on github. Here's a guide that shows you how to do that while hiding your personal email adress. A graphical git client (like the ones mentioned above) typically allows you to configure these settings via their own settings dialog.
clang-format is a handy tool for helping you to tidy up your code formatting. It can assist you in fixing indentation, spacing and line breaks to provide a clean, even code style across the project.
You don't have to use this tool, but i would recommend to have it installed.
- Windows: Download and install the LLVM setup from here
- linus: Just use your local package manager to install it
- macOS: Homebrew can be used to install clang-format
gcc-arm-none-eabi is the compiler and toolchain used to build the Wunderkiste source code. Wunderkiste currently uses the version 9-2020-q2-update. Other versions will likely work but produce slightly different machine code. This will typically be irrelevant but we recommend top stick to this version nonetheless.
- Windows:
- Download the
9-2020-q2-updateinstaller from https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads - Install to the default directory for seamless integration with the build environment:
C:\Program Files (x86)\GNU Arm Embedded Toolchain\9 2020-q2-update
- Download the
- macOS / linux:
- I recommend simply to place the toolchain into a folder and not use any particular installer. This allows you to use different versions along each other.
- Download the
9-2020-q2-updatearchive from https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads - Extract to this directory for seamless integration with the build environment:
~/dev/gcc-arm-none-eabi-9-2020-q2-update
During the build process, various other build tools are required.
- Windows:
- These linux-like build tools are provided via
cygwin. - Download the cygwin installer from the cygwin website
- Run the installer and install the following packages:
- gcc-core
- gcc-g++
- gdb
- make
- pkg-config
- These linux-like build tools are provided via
- macOS:
- Install Xcode and the Xcode command line utilities
- linux:
- Install the
build-essentialpackage via your package manager.
- Install the
openocd connects to the Wunderkiste hardware, programs it and is a debugging server for gdb.
- Windows:
- Download and install
openocdfrom the xpack project - Make sure it is available via the system PATH variable
- Download and install the ST-LINK/V2-1 USB driver from the ST website
- Download and install
- macOS:
- Download and install
openocdfrom the xpack project - Make sure it is available via the system PATH variable
- Download and install
- linux:
- Install
openocdvia your package manager.
- Install
Any text editor can be used to modify the source code. However, it is recommended to use Visual Studio Code as the Wunderkiste project provides integration files for
- syntax highlighting
- compiling
- debugging
- auto-formatting
- Download and install Visual Studio Code
- Install the following extensions:
- C/C++ (syntax highlighting, auto-completion, etc.)
- Clang-Format (auto-formatting via a keyboard shortcut)
- GoogleTest Adapter (for displaying and running the unit tests locally)
- Open your git client and clone the Wunderkiste repository to a location of your choice. Make sure to also checkout the submodules.
- Open that folder in Visual Studio Code.
- Press
Ctrl-Shift-BorCmd-Shift-Band run thebuild-Wunderkistetask. - The code should compile - if not: Check the output from the Visual Studio Code terminal to see what's missing.
- To run a debugging session:
- Connect the board to your computer via a USB cable. Connect to the USB-mini-B connector on the ST-Link side of the board, not the USB-micro-B connector on the other side.
- Click on the
Run and Debugtab on the left of the Visual Studio Code window. - Run the
Launch On Hardwarejob. A debugging session should start.
- To run the unit tests locally:
- Click on the
Run and Debugtab on the left of the Visual Studio Code window. - Run the
Launch Tests Locallyjob. - You can also run tests from the
Testtab on the left of the Visual Studio Code window.
- Click on the
- You can build the firmware directly from the commandline by executing
make allin thefirmwaredirectory - You can program the firmware directly from the commandline by executing
make uploadin thefirmwaredirectory - You can build the unit tests directly from the commandline by executing
makein thefirmware/testsdirectory - You can run the unit tests directly from the commandline by executing
Wunderkiste_gtest(.exe)in thetests/build/bin/directory