[update] documentation
[fw/stlink] / doc / tutorial / tutorial.tex
index 9efc7999cf5895d993e93ef7b2d449c66de45330..f177e2b87c703c012f64e4411ab9a712b21385e1 100644 (file)
@@ -52,8 +52,16 @@ STLINK is an opensource software to program and debug the discovery kits. Those
 kits have an onboard chip that translates USB commands sent by the host PC into
 JTAG commands. This chip is called STLINK, which is confusing since the software
 has the same name. It comes into 2 versions (STLINK v1 and v2). From a software
-point of view, those version differ only in the transport layer used to communicate
+point of view, those versions differ only in the transport layer used to communicate
 (v1 uses SCSI passthru commands, while v2 uses raw USB).
+
+\paragraph{}
+Before continuing, the following dependencies are required:
+\begin{itemize}
+\item libusb-1.0
+\item libsg2
+\end{itemize}
+
 \paragraph{}
 The STLINK software source code is retrieved using:\\
 \begin{small}
@@ -66,7 +74,10 @@ git clone https://github.com/texane/stlink stlink.git
 The GDB server is called st-util and is built using:\\
 \begin{small}
 \begin{lstlisting}[frame=tb]
-$> cd stlink.git; make ;
+$> cd stlink.git;
+$> make ;
+$> cd gdbserver ;
+$> make ;
 \end{lstlisting}
 \end{small}
 
@@ -77,15 +88,14 @@ $> cd stlink.git; make ;
 A simple LED blinking example is provided in the example directory. It is built using:\\
 \begin{small}
 \begin{lstlisting}[frame=tb]
-cd stlink.git/example ;
+cd stlink.git/example/blink ;
 PATH=$TOOLCHAIN_PATH/bin:$PATH make ;
 \end{lstlisting}
 \end{small}
 
 \paragraph{}
-A GDB server must be start to interact with the STM32.
-Depending on the discovery kit you are using, you must
-run one of the 2 commands:\\
+A GDB server must be start to interact with the STM32. Depending on the discovery kit you
+are using, you must run one of the 2 commands:\\
 \begin{small}
 \begin{lstlisting}[frame=tb]
 # STM32VL discovery kit
@@ -108,24 +118,52 @@ $> $TOOLCHAIN_PATH/bin/arm-none-eabi-gdb
 From GDB, connect to the server using:\\
 \begin{small}
 \begin{lstlisting}[frame=tb]
-$> target extended-remote localhost:4242
+$> target extended localhost:4242
+\end{lstlisting}
+\end{small}
+
+\paragraph{}
+By default, the program was linked such that the base address is 0x20000000. From the architecture
+memory map, GDB knows this address belongs to SRAM. To load the program in SRAM, simply use:\\
+\begin{small}
+\begin{lstlisting}[frame=tb]
+$> load blink.elf
 \end{lstlisting}
 \end{small}
 
 \paragraph{}
-To load the program, use:\\
+GDB automatically set the PC register to the correct value, 0x20000000 in this case. Then, you
+can run the program using:\\
 \begin{small}
 \begin{lstlisting}[frame=tb]
-$> load program.elf
+$> continue
 \end{lstlisting}
 \end{small}
 
 \paragraph{}
-Then, you can run the program using:\\
+The board BLUE and GREEN leds should be blinking (those leds are near the user and reset buttons).
+
+
+\newpage
+\section{Notes}
+\paragraph{}
+By default, the disassemble command in GDB operates in ARM mode. The programs running on CORTEX-M3
+are compiled in THUMB mode. To correctly disassemble them under GDB, uses an odd address. For instance,
+if you want to disassemble the code at 0x20000000, use:\\
 \begin{small}
 \begin{lstlisting}[frame=tb]
-$> run
+$> disassemble 0x20000001
 \end{lstlisting}
 \end{small}
 
+
+\newpage
+\section{References}
+\begin{itemize}
+\item http://www.st.com/internet/mcu/product/248823.jsp\\
+  documentation related to the STM32L mcu
+\item http://www.st.com/internet/evalboard/product/250990.jsp\\
+  documentation related to the STM32L discovery kit
+\end{itemize}
+
 \end{document}