Difference between revisions of "STM32 Starter Guide"

From Eleccelerator Wiki
Jump to: navigation, search
m
m (Bootloader)
Line 32: Line 32:
 
If you want to use the USB version of the bootloader, look for a tool called "DfuSe", also known as [http://www.st.com/web/en/catalog/tools/FM147/CL1794/SC961/SS1533/PF257916 STSW-STM32080]. The protocol is also documented, and the source code for the DfuSe tool is available as well.
 
If you want to use the USB version of the bootloader, look for a tool called "DfuSe", also known as [http://www.st.com/web/en/catalog/tools/FM147/CL1794/SC961/SS1533/PF257916 STSW-STM32080]. The protocol is also documented, and the source code for the DfuSe tool is available as well.
  
If you want to implement a custom version of the USB bootloader, ST does provide source code for the bootloader firmware, and it is compatible with DfuSe.
+
If you want to implement a custom version of the USB bootloader, ST does provide source code for the bootloader firmware (provided with their USB library), and it is compatible with DfuSe.
  
 
==Clock Configuration Tool==
 
==Clock Configuration Tool==

Revision as of 17:15, 31 October 2013

I use a lot of the STM32 family microcontrollers. This page will have some info on how to start using them.

Contents

IDE

I use Eclipse with the CDT (these help with C and C++ code). Some plugins can be installed from within Eclipse itself, some must be manually installed. Here are the list of plugins I have installed:

  • C/C++ Remote Debug Launcher
  • CDT GCC Cross Compiler Support
  • Eclipse C/C++ Development Tools
  • Eclipse GDB Hardware Debugging Plug-in
  • GDB Common
  • GNU ARM C/C++ Development Support

Compiler Toolchain

I use GCC ARM Embedded, because "ARM employees are maintaining this project", it is very up-to-date right now.

The GNU ARM plugin for Eclipse does support it.

Tools and Documents from ST

Remember to read the following documents for your specific chip

  • Datasheet, tells you about most of the electrical specifications, pin mappings, package details, etc
  • Reference Manual, tells you how to use the internal peripherals, etc
  • Programming Manual, not required to read but it is useful to understand how the flash memory is organized and written

Bootloader

Almost all STM32 chips can enter a factory stock bootloader that is stored in ROM (meaning it cannot be overwritten or deleted accidentally), and activated by a pin called BOOT0. To learn how to activate this bootloader mode, look for a document named STM32 microcontroller system memory boot mode. The bootloader uses UART (aka serial port) for communication, and it can also use USB if the chip has USB abilities.

This ROM bootloader usually works with a tool called "Flash Loader Demo", also known as STSW-MCU005. The protocol is also documented so that you can write your own application, but this is not required.

If you want to use the USB version of the bootloader, look for a tool called "DfuSe", also known as STSW-STM32080. The protocol is also documented, and the source code for the DfuSe tool is available as well.

If you want to implement a custom version of the USB bootloader, ST does provide source code for the bootloader firmware (provided with their USB library), and it is compatible with DfuSe.

Clock Configuration Tool

For different STM32 chips, ST provides an Excel spreadsheet with macros. You have to enter your parameters such as input crystal frequency and desired output frequency. The spreadsheet macro will use your info to generate a file that you can compile into your project. This file will setup the clock sources and PLLs for you. To find these files, you need to search for "Clock configuration tool for" on the ST website, there is a different tool for each chip.

Standard Peripheral Libraries

ST provides libraries that help you use the features of their microcontrollers. You need to find the specific library for your specific chip by searching for "Standard Peripheral Library" on the ST website.

Inside the library download, you will also find CMSIS support files, and linker scripts for GCC's linker. You need these files to build any project.

The library also comes with a ton of examples that compiles under many toolchains. If you get lost, start with an example.

ST supports Atollic TrueSTUDIO, which is an expensive IDE that is based on Eclipse and GNU GCC, so any files that works for TrueSTUDIO will also work using our GNU GCC build process.

USB Device and Host Library

ST provides a half decent USB library. It's not perfect but it gets the job done. Also known as STSW-STM32046.

Debugger

Discovery Boards

ST has a family of Discovery boards, which are dirt cheap ($8 is the cheapest). Each Discovery board has a ST Link V2 built into it, which can do SWD debugging. You can disconnect the ST Link and use it for other projects. This is a great backup tool as well.

The schematics for the Discovery boards are always available. They are a great starting point for when you need to design your own circuit with STM32 chips. There are also example code from ST written specifically for Discovery boards.

CoLink

CoLinkEx is also very cheap but it does not support all of the STM32 family. I support CooCox's open source efforts but I cannot recommend this debugger because some of my favorite STM32 chips are not supported yet. Once the support has been added, then I can recommend it.

J-Link

I own a J-Link EDU, which is reasonably priced at around $70. This is what I use. J-Link has a GDB server application that works with the GDB plugins in Eclipse.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox