mobilelab

Documentation for the mobilelab project

Setting up the development environment for the STM32F10x with ST-Link

Installation

Eclipse IDE for C/C++

We’ll be Eclipse as our primary software development tool for the STM32, every other tool will be configured to run through Eclipse.

GCC Arm

The GNU Compiler Collection for the Arm architecture.

We’ll be using an open source version of the ST Microelectronics ST-Link Tools that runs on Linux. This tool allow us to flash the chip.

Follow the installation instructions from their README at GitHub.

After building it, copy st-flash to the /usr/bin/ directory by running:

cp st-flash /usr/bin/

OpenOCD

OpenOCD allow us to fully debug software directly on the chip.

Follow the installation instructions at their instructions page. Note: If you are building it from source, don’t forget to enable ST-Link.

You also need to set the “Toolchain Folder” in the GNU MCU Eclipse plugin settings at Window -> Preferences -> MCU -> Global OpenOCD Path, which needs to point to OpenOCD bin directory.

Compiling

Open Eclipse and create a new C/C++ project -> C Managed Build -> STM32F10x C/C++ Project -> ARM Cross GCC.

You may want to set “Use system calls” to “Semihosting” in case you need to print messages into the console.

You should be able to create and compile the project if the GNU MCU Eclipse plugin and the GCC Arm are both installed correctly.

Debugging

Go to Run -> Debug Configurations, add a new launch configuration under GDB OpenOCD Debugging for the project open.

You’ll need to locate two files inside the OpenOCD installation directory, they are usually located at ./interface/stlink-v2.cfg and ./target/stm32f1x.cfg inside the tcl or scripts directory. You should replace those paths below:

-f OPENOCD-PATH/interface/stlink-v2.cfg -f OPENOCD-PATH/target/stm32f1x.cfg

Set the parameters above to the Config options in the Debugger tab.

OpenOCD Eclipse Config Options

Connect the hardware, with each port mapped as listed below:

st-linkv2 stm32f103c8t6
SWDIO DIO
GND GND
SWCLK CLK
3.3V 3.3V

You should be able to run the newly created debug configuration if OpenOCD was installed and configured correctly. You can test it out by running it and adding breakpoints to your code.

Flashing

You can configure the flashing process for release through Eclipse by following the instructions below.

Right click the project, go to Properties -> C/C++ Build -> GNU ARM Cross Create Flash Image -> General and set the “Output File Format” to “Raw Binary”.

Compile the project in release mode (a release folder should be created)

Open Run -> External Tools -> External Tools Configuration, create a new configuration under “Program”:

You should be able to run the configuration to flash the device.