The STM32VL Discovery board is a cheap and effective kit to start developing on ARM MCUs. It is based on the STM32 F1 family and features an onboard ST-LINK V1 programmer/debugger (both JTAG and SWD are supported). See More on the official pages ST-LINK and ST-LINK/V2.
In the following notes an how-to setup:
- the Eclipse IDE and the GNU ARM Eclipse plugin
- the GNU ARM toolchain
- the ST-LINK V1/V2 USB drivers
- the ST-LINK utility (to flash the MCU)
Everything is done on a MacBookPro 13″ running OSX 10.9.2 Mavericks. Eclipse – currently in its 4.3.2 release, Kepler – must be installed and on top of that
- C/C++ Development Tools
- C/C++ GDB Hardware Debugging
from the Kepler update repository, and
from the GNU ARM Eclipse Plugin update site.
GNU ARM toolchain
To build a project from source an ARM toolchain is required: the GNU Tools for ARM Embedded Processor is the toolset of choice (or see other options and even build it). It is available for download here
The following steps can be performed on OS X.
- download the latest OS X install tarball file
- locate the file (usually in the $HOME/Downloads folder)
- decide on a location to install the toolchain; the recommended folder is /usr/local
- unpack the archive in the destination folder
12 cd /usr/localsudo tar xjf ~/Downloads/gcc-arm-none-eabi-4_8-2013q4-20131218-mac.tar.bz2
- the result should be a folder like /usr/local/gcc-arm-none-eabi-4_8-2013q4
- test if the compiler is functional
12 $ /usr/local/gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-gcc --versionarm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.8.3 20131129 (release) [ARM/embedded-4_8-branch revision 205641]
DO NOT add the toolchain path to the user or system path!
The complete toolchain documentation is available in the …/share/doc/pdf/ folder.
If you’ll ever need to remove the toolchain, just remove the /usr/local/gcc-arm-none-eabi-4_8-2013q4, there are no other components stored in system folders.
A GDB client is available within the toolchain. In a cross-compiling environment, this command is used to connect the host (the computer used for development) to a GDB server (see here), a program acting as a proxy between the host and the target device (the STM32VL Discovery board)
ST-LINK driver, programmer and GDB server
Texane’s stlink is a STM32 command line programmer for Linux (and OSX). It provides the user with a flashing utility (st-flash) and a GDB server (st-util) among other features. Instruction on how to compile and build are available at:
- texane/stlink homepage and in the README
Some old info (dated back to 2011) are also available from cu.rious.org:
- cu.rious.org – Getting STLink to work on Mac OS X with MacPorts
Install the device driver for the STM32VL Discovery board (.kext) from texane GitHub page Refer to the README file for additional info.
NOTE – The .kext file installation should avoid the manual setup (modprobe,udev) described in the main README file.
NOTE – Normally no third-party software is required to install the .kext file. On Mavericks, a tool like Kext Utility will be required to authorize the file.
Once done st-util, etc… can be moved to /usr/local/bin folder to allow them to be executed no matter what the current location will be.
Once plugged in test the board as follow
Stefanos-MacBook-Pro-2:~ stefanocottafavi$ st-util -1
2014-04-29T19:50:15 WARN src/stlink-sg.c: Your stlink got into a real weird configuration, trying to fix it!
2014-04-29T19:50:16 INFO src/stlink-sg.c: Current mode unusable, trying to get back to a useful state...
2014-04-29T19:50:16 WARN src/stlink-sg.c: received tag 0 but expected 3
2014-04-29T19:50:16 INFO src/stlink-common.c: Loading device parameters....
2014-04-29T19:50:16 INFO src/stlink-common.c: Device connected is: F1 Medium-density Value Line device, id 0x10016420
2014-04-29T19:50:16 INFO src/stlink-common.c: SRAM size: 0x2000 bytes (8 KiB), Flash: 0x20000 bytes (128 KiB) in pages of 1024 bytes
2014-04-29T19:50:16 INFO src/stlink-sg.c: Successfully opened a stlink v1 debugger
Chip ID is 00000420, Core ID is 1ba01477.
Listening at *:4242...
Please note the ST-LINK on the STM32VL is version 1, so the use of “-1” argument at the command line “st-util -1” is advised; failing to do that can lead to error upon file loading (and again). The red COM LED on the board will turn on to indicate the GDB server is connected to the board and listening on the default port 424
With the GNU ARM Eclipse plugin installed no further configuration is required to code for the STM32. Follow the documentation on the project page for a quick start. Before any flashing or debugging attempt the GDB server previously installed must be up and running: an External Tools configuration can be defined to launch st-util from Eclipse toolbar. See
Then create a Debug configuration and use it (when launching for debugging) to connect to the GDB server.