This guide details the use of STMicroelectronics STM32 discovery kits in an open source environment.
- Stm32 Link Utility Download
- Stm32 St Link Utility
- Stm32 St-link Utility Manual
- Stm32 St Link Utility User Manual 2017
Any toolchain supporting the cortex m3 should do. You can find thenecessary to install such a toolchain here:
Details for the installation are provided in the topmost README
file.This documentation assumes the toolchains is installed in a$TOOLCHAIN_PATH
.
STLINK is open source software to program and debug ST’s STM32 Discoverykits. Those kits have an onboard chip that translates USB commands sentby the host PC into JTAG/SWD commands. This chip is called STLINK, (yes,isn’t that confusing? suggest a better name!) and comes in 2 versions(STLINK v1 and v2). From a software point of view, those versions differonly in the transport layer used to communicate (v1 uses SCSI passthrucommands, while v2 uses raw USB). From a user point of view, they areidentical.
STM32 ST-LINK Utility (STSW-LINK004) is a full-featured software interface for programming STM32 microcontrollers. It provides an easy-to-use and efficient environment for reading, writing and verifying a. User manual STM32 ST-Link Utility Introduction The STM32 ST-Link Utility software facilitates fast In-System Programming of the STM32 microcontroller families in both development and production environments via the ST-Link tool. This is the STM32 ST-Link Utility user manual, describing its software functionality.
Before continuing, the following dependencies must be met:
- libusb-1.0
- cmake
Also make sure gtk+
version 3.0 is installed. (sudo apt-get install gtk+-3.0
or similiar)
STLINK should run on any system meeting the above constraints.
The STLINK software source code is retrieved using:
Everything can be built from the top directory:
It includes:
- a communication library (libstlink.a),
- a GDB server (st-util),
- a flash manipulation tool (st-flash).
- a programmer and chip information tool (st-info)
This assumes you have got the libopencm3 project downloaded in ocm3
.The libopencm3 project has some good, reliable examples for each of theDiscovery boards.
Even if you don’t plan on using libopencm3, the examples they providewill help you verify that:
- Your installed toolchain is capable of compiling for cortex M3/M4targets
- stlink is functional
- Your arm-none-eabi-gdb is functional
- Your board is functional
Stm32 Link Utility Download
A GDB server must be started to interact with the STM32. Depending onthe discovery kit you are using, you must run one of the 2 commands:
Then, GDB can be used to interact with the kit:
From GDB, connect to the server using:
GDB has memory maps for as many chips as it knows about, and will loadyour project into either flash or SRAM based on how the project waslinked. Linking projects to boot from SRAM is beyond the scope of thisdocument.
Because of these built in memory maps, after specifying the .elf at thecommand line, now we can simply “load” the target:
Stm32 St Link Utility
st-util will load all sections into their appropriate addresses, and“correctly” set the PC register. So, to run your freshly loaded program,simply “continue”
Your program should now be running, and, if you used one of the blinkingexamples from libopencm3, the LEDs on the board should be blinking foryou.
If you want to simply flash binary files to arbitrary sections ofmemory, or read arbitary addresses of memory out to a binary file, usethe st-flash tool, as shown below:
It is also possible to write a hexfile which is more convinient:
Of course, you can use this instead of the gdb server, if you prefer.Just remember to use the “.bin” image, rather than the .elf file.
Upon reset, the board LEDs should be blinking.
Stm32 St-link Utility Manual
Disassembling THUMB code in GDB
By default, the disassemble command in GDB operates in ARM mode. Theprograms running on CORTEX-M3 are compiled in THUMB mode. To correctlydisassemble them under GDB, uses an odd address. For instance, if youwant to disassemble the code at 0x20000000, use:
Stm32 St Link Utility User Manual 2017
http://www.st.com/internet/mcu/product/248823.jspdocumentation related to the STM32L mcu
http://www.st.com/internet/evalboard/product/250990.jspdocumentation related to the STM32L discovery kit
http://www.libopencm3.orglibopencm3, a project providing a firmware library, with solidexamples for Cortex M3, M4 and M0 processors from any vendor.