Difference between revisions of "STM32 tutorial"

From AIRWiki
Jump to: navigation, search
(Getting started)
 
(32 intermediate revisions by the same user not shown)
Line 1: Line 1:
Work in progress
+
---Work in progress---
  
 +
__forceTOC__
  
To be able to work with ARM microcontrollers you will need:
+
STM32 is an ARM Cortex-M3 microcontroller built from ST. It combines a modern 32 bit architecture, high performances and low cost, making it a good choice for many applications.
- an hardware board with the MCU and a JTAG connector to program it
+
 
- a JTAG adapter
+
In AIRLab there are some STM32 based boards to learn how to work with this kind of microcontrollers, and some projects have been developed on this architecture.
- a toolchain to compile ARM executables on your computer
+
 
- OpenOCD to write the executable on the MCU
+
To be able to work with STM32 microcontrollers you will need:
 +
* an hardware board with the MCU and a JTAG connector to program it
 +
* a JTAG adapter
 +
* a toolchain to compile ARM executables on your computer
 +
* OpenOCD to write the executable on the MCU
 +
 
 +
== Hardware ==
 +
==== STM32 module ====
 +
In the AIRLab there are two ET-STM32 Stamp Module, low-cost plug-in modules with a STM32F103RET6 MCU on board. They include also a crystal oscillator, a MAX232 to communicate via serial port and the circuitry needed to upload the firmware via a bootloader, that is preloaded on the microcontroller.
 +
[[Image:Stm32 module.jpg|320px]]
 +
 
 +
==== Demo board ====
 +
To start working with STM32 and it's peripherals there is a custom built demo board for the STM32 plug-in module that includes some LEDS, some buttons, two trimmers for ADC conversions, a 7-segment display, power supply and connections for RS232, SPI, I2C, CAN and USB interface.
 +
 
 +
[[Image:Stm32 demoboard.JPG|400px]]
 +
 
 +
==== ST board (IMU) ====
 +
 
 +
 
 +
==== JTAG Adapter ====
 +
 
 +
In the AIRLab there are four JTAG - USB adapter to program and debug ARM microcontrollers. Those adapters are ARM-USB-TINY from Olimex, and there are drivers for Windows, Linux and OSX.
 +
 
 +
[[Image:Arm-usb-tiny.jpg|320px]]
 +
 
 +
== Development software ==
 +
 
 +
In order to build executables for ARM microcontrollers you need a compiler (ASM, C or C++) and a linker specifically built for ARM targets. There are some complete solutions that integrate the compiler and linker with a graphical source editor and a debugger, but most of them have commercial licenses.
 +
 
 +
==== Commercial solutions ====
 +
 
 +
Here you can find a list of Integrated Development Environments for STM32 microcontrollers:
 +
http://www.st.com/mcu/inchtml-pages-ide.html
 +
 
 +
IAR and KEIL are the most common in industrial applications, but they are quite expensive (more than 2000 USD).
 +
Crosswork's CrossStudio is an IDE that runs on Windows, Linux and OSX and works also with some cheap JTAG adapters (including Olimex's ARM-USB-TINY) and it's price starts from 150 USD. We have evaluated it and the first impressions are really good.
 +
 
 +
==== Free IDEs ====
 +
 
 +
Some of the IDEs are available for free. Currently, they are:
 +
* Raisonance RIDE7, but it works only with Raisonance's programmer, that costs money
 +
* Atollic TrueStudio, that is an eclipse based IDE with GCC built for ARM targets (runs only on windows)
 +
 
 +
Some people from ST are working on an open source toolchain, that can be downloaded here: http://www.danielecaltabiano.com/wwme/ST-ARM_toolchain/st-arm.htm .
 +
It is in alpha stage, but it is possible to build valid executables.
 +
 
 +
==== Custom toolchain ====
 +
 
 +
Another solution is to build a custom toolchain to make ARM executables (instructions will be posted here).
 +
 
 +
Codesourcery has developed an optimized toolchain for ARM processors that is open source (their IDE on the contrary has a commercial license) that runs on Windows and Linux (and there is a source packages, so it is possible to build it for OSX too). Here there are binary installers for Windows and Linux as well as the source tarball: http://www.codesourcery.com/sgpp/lite/arm/ .
 +
 
 +
To install from binary packages, just download the one you need and run it (if you have downloaded the installer package) or extract it (if you have downloaded the tarball). To install from sources, you'll need to extract them, enter the source directory, and then run ./configure && make && make install.
 +
 
 +
==== OpenOCD ====
 +
 
 +
== Getting started ==
 +
 
 +
To start working with STM32 Microcontrollers, follow these easy steps:
 +
* download Codesourcery's toolchain from http://www.codesourcery.com/sgpp/lite/arm/download.html (select EABI target, then download the TAR package under "Advanced Packages")
 +
* download OpenOCD sources from http://developer.berlios.de/projects/openocd

Latest revision as of 13:45, 27 April 2010

---Work in progress---


STM32 is an ARM Cortex-M3 microcontroller built from ST. It combines a modern 32 bit architecture, high performances and low cost, making it a good choice for many applications.

In AIRLab there are some STM32 based boards to learn how to work with this kind of microcontrollers, and some projects have been developed on this architecture.

To be able to work with STM32 microcontrollers you will need:

  • an hardware board with the MCU and a JTAG connector to program it
  • a JTAG adapter
  • a toolchain to compile ARM executables on your computer
  • OpenOCD to write the executable on the MCU

Hardware

STM32 module

In the AIRLab there are two ET-STM32 Stamp Module, low-cost plug-in modules with a STM32F103RET6 MCU on board. They include also a crystal oscillator, a MAX232 to communicate via serial port and the circuitry needed to upload the firmware via a bootloader, that is preloaded on the microcontroller. Stm32 module.jpg

Demo board

To start working with STM32 and it's peripherals there is a custom built demo board for the STM32 plug-in module that includes some LEDS, some buttons, two trimmers for ADC conversions, a 7-segment display, power supply and connections for RS232, SPI, I2C, CAN and USB interface.

Stm32 demoboard.JPG

ST board (IMU)

JTAG Adapter

In the AIRLab there are four JTAG - USB adapter to program and debug ARM microcontrollers. Those adapters are ARM-USB-TINY from Olimex, and there are drivers for Windows, Linux and OSX.

Arm-usb-tiny.jpg

Development software

In order to build executables for ARM microcontrollers you need a compiler (ASM, C or C++) and a linker specifically built for ARM targets. There are some complete solutions that integrate the compiler and linker with a graphical source editor and a debugger, but most of them have commercial licenses.

Commercial solutions

Here you can find a list of Integrated Development Environments for STM32 microcontrollers: http://www.st.com/mcu/inchtml-pages-ide.html

IAR and KEIL are the most common in industrial applications, but they are quite expensive (more than 2000 USD). Crosswork's CrossStudio is an IDE that runs on Windows, Linux and OSX and works also with some cheap JTAG adapters (including Olimex's ARM-USB-TINY) and it's price starts from 150 USD. We have evaluated it and the first impressions are really good.

Free IDEs

Some of the IDEs are available for free. Currently, they are:

  • Raisonance RIDE7, but it works only with Raisonance's programmer, that costs money
  • Atollic TrueStudio, that is an eclipse based IDE with GCC built for ARM targets (runs only on windows)

Some people from ST are working on an open source toolchain, that can be downloaded here: http://www.danielecaltabiano.com/wwme/ST-ARM_toolchain/st-arm.htm . It is in alpha stage, but it is possible to build valid executables.

Custom toolchain

Another solution is to build a custom toolchain to make ARM executables (instructions will be posted here).

Codesourcery has developed an optimized toolchain for ARM processors that is open source (their IDE on the contrary has a commercial license) that runs on Windows and Linux (and there is a source packages, so it is possible to build it for OSX too). Here there are binary installers for Windows and Linux as well as the source tarball: http://www.codesourcery.com/sgpp/lite/arm/ .

To install from binary packages, just download the one you need and run it (if you have downloaded the installer package) or extract it (if you have downloaded the tarball). To install from sources, you'll need to extract them, enter the source directory, and then run ./configure && make && make install.

OpenOCD

Getting started

To start working with STM32 Microcontrollers, follow these easy steps: