1 \documentclass[a4paper, 11pt]{article}
11 \title{Using STM32 discovery kits with open source tools}
12 \author{STLINK development team}
19 \addtocontents{toc}{\protect\setcounter{tocdepth}{1}}
26 This guide details the use of STMicroelectronics STM32 discovery kits in
27 an opensource environment.
32 \section{Installing a GNU toolchain}
34 Any toolchain supporting the cortex m3 should do. You can find the necessary
35 to install such a toolchain here:\\
37 \begin{lstlisting}[frame=tb]
38 https://github.com/esden/summon-arm-toolchain
43 Details for the installation are provided in the topmost README file.
44 This documentation assumes the toolchains is installed in a \$TOOLCHAIN\_PATH.
49 \section{Installing STLINK}
51 STLINK is an opensource software to program and debug the discovery kits. Those
52 kits have an onboard chip that translates USB commands sent by the host PC into
53 JTAG commands. This chip is called STLINK, which is confusing since the software
54 has the same name. It comes into 2 versions (STLINK v1 and v2). From a software
55 point of view, those version differ only in the transport layer used to communicate
56 (v1 uses SCSI passthru commands, while v2 uses raw USB).
58 The STLINK software source code is retrieved using:\\
60 \begin{lstlisting}[frame=tb]
61 git clone https://github.com/texane/stlink stlink.git
66 The GDB server is called st-util and is built using:\\
68 \begin{lstlisting}[frame=tb]
79 \section{Building and running a program}
80 A simple LED blinking example is provided in the example directory. It is built using:\\
82 \begin{lstlisting}[frame=tb]
83 cd stlink.git/example ;
84 PATH=$TOOLCHAIN_PATH/bin:$PATH make ;
89 A GDB server must be start to interact with the STM32. Depending on the discovery kit you
90 are using, you must run one of the 2 commands:\\
92 \begin{lstlisting}[frame=tb]
93 # STM32VL discovery kit
94 $> sudo ./st-util /dev/sg2
96 # STM32L discovery kit
102 Then, GDB can be used to interact with the kit:\\
104 \begin{lstlisting}[frame=tb]
105 $> $TOOLCHAIN_PATH/bin/arm-none-eabi-gdb
110 From GDB, connect to the server using:\\
112 \begin{lstlisting}[frame=tb]
113 $> target extended localhost:4242
118 To load the program in SRAM, use:\\
120 \begin{lstlisting}[frame=tb]
126 GDB automatically set the PC register to the correct value, 0x20000000 in this case. Then, you
127 can run the program using:\\
129 \begin{lstlisting}[frame=tb]
135 The board BLUE and GREEN leds should be blinking (those leds are near the user and reset buttons).
141 \item http://www.st.com/internet/mcu/product/248823.jsp\\
142 documentation related to the STM32L mcu
143 \item http://www.st.com/internet/evalboard/product/250990.jsp\\
144 documentation related to the STM32L discovery kit