[update] documentation
[fw/stlink] / doc / tutorial / tutorial.tex
1 \documentclass[a4paper, 11pt]{article}
2
3 \usepackage{graphicx}
4 \usepackage{graphics}
5 \usepackage{verbatim}
6 \usepackage{listings}
7 \usepackage{color}
8
9 \begin{document}
10
11 \title{Using STM32 discovery kits with open source tools}
12 \author{STLINK development team}
13 \date{}
14
15 \maketitle
16
17 \newpage
18 \tableofcontents
19 \addtocontents{toc}{\protect\setcounter{tocdepth}{1}}
20
21
22 \newpage
23
24 \section{Overview}
25 \paragraph{}
26 This guide details the use of STMicroelectronics STM32 discovery kits in
27 an opensource environment.
28
29
30 \newpage
31
32 \section{Installing a GNU toolchain}
33 \paragraph{}
34 Any toolchain supporting the cortex m3 should do. You can find the necessary
35 to install such a toolchain here:\\
36 \begin{small}
37 \begin{lstlisting}[frame=tb]
38 https://github.com/esden/summon-arm-toolchain
39 \end{lstlisting}
40 \end{small}
41
42 \paragraph{}
43 Details for the installation are provided in the topmost README file.
44 This documentation assumes the toolchains is installed in a \$TOOLCHAIN\_PATH.
45
46
47 \newpage
48
49 \section{Installing STLINK}
50 \paragraph{}
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).
57 \paragraph{}
58 The STLINK software source code is retrieved using:\\
59 \begin{small}
60 \begin{lstlisting}[frame=tb]
61 git clone https://github.com/texane/stlink stlink.git
62 \end{lstlisting}
63 \end{small}
64
65 \paragraph{}
66 The GDB server is called st-util and is built using:\\
67 \begin{small}
68 \begin{lstlisting}[frame=tb]
69 $> cd stlink.git;
70 $> make ;
71 $> cd gdbserver ;
72 $> make ;
73 \end{lstlisting}
74 \end{small}
75
76
77 \newpage
78
79 \section{Building and running a program}
80 A simple LED blinking example is provided in the example directory. It is built using:\\
81 \begin{small}
82 \begin{lstlisting}[frame=tb]
83 cd stlink.git/example ;
84 PATH=$TOOLCHAIN_PATH/bin:$PATH make ;
85 \end{lstlisting}
86 \end{small}
87
88 \paragraph{}
89 A GDB server must be start to interact with the STM32.
90 Depending on the discovery kit you are using, you must
91 run one of the 2 commands:\\
92 \begin{small}
93 \begin{lstlisting}[frame=tb]
94 # STM32VL discovery kit
95 $> sudo ./st-util /dev/sg2
96
97 # STM32L discovery kit
98 $> sudo ./st-util
99 \end{lstlisting}
100 \end{small}
101
102 \paragraph{}
103 Then, GDB can be used to interact with the kit:\\
104 \begin{small}
105 \begin{lstlisting}[frame=tb]
106 $> $TOOLCHAIN_PATH/bin/arm-none-eabi-gdb
107 \end{lstlisting}
108 \end{small}
109
110 \paragraph{}
111 From GDB, connect to the server using:\\
112 \begin{small}
113 \begin{lstlisting}[frame=tb]
114 $> target extended localhost:4242
115 \end{lstlisting}
116 \end{small}
117
118 \paragraph{}
119 To load the program, use:\\
120 \begin{small}
121 \begin{lstlisting}[frame=tb]
122 $> load blink.elf
123 \end{lstlisting}
124 \end{small}
125
126 \paragraph{}
127 Then, you can run the program using:\\
128 \begin{small}
129 \begin{lstlisting}[frame=tb]
130 $> run
131 \end{lstlisting}
132 \end{small}
133
134
135 \newpage
136 \section{References}
137 \begin{itemize}
138 \item http://www.st.com/internet/mcu/product/248823.jsp\\
139   documentation related to the STM32L mcu
140 \item http://www.st.com/internet/evalboard/product/250990.jsp\\
141   documentation related to the STM32L discovery kit
142 \end{itemize}
143
144 \end{document}