Minimum system STM32 guide


For the past few months or so, I've been eyeing off the STM32 series of uCs. They are powerful and quite popular, but much more difficult to use than Arduino. Arduino is great for learning and for the vast majority of projects, but it's not so great for professional projects where cost and size are a priority. That's why I've been trying to work out how to use the STM32 uCs. It's taken me a while to work out how to use these things productively, so I thought I'd make up a guide detailing all the steps from setting up a compiler to uploading firmware to a minimum system circuit board. Hopefully you find it interesting!

I'd really appreciate feedback and constructive criticisms.

Cheers, Camel

Seems a bit chibiOS-centric; your instructions rely on the chibios download for all the processor-specific info like stm32f10x.h, for instance.

You’re right, but I think ChibiOS really is the way to go. The build system takes care of linker ld scripts and everything. Do you suggest I write about making ld scripts and do a bare-bones blinky example? I’d have to do some reading and learning first . . . but, good idea?

ChibiOS on STM32 is great. The STM32 Discovery boards are nice and the high end models are very powerful.

I have also been using Nucleo boards. These boards have Arduino style connectors so you can use Arduino shields.

The NUCLEO-F411RE has 128 KB SRAM, 512 KB of flash and runs at 100 MHz This board is available for $10.33 from Mouser and Future Electronics.

The Nucleo USB connector can power the board, provides a virtual serial port, supports drag and drop programming, and ST Link programmers and debuggers.

You can start with only the mbed web development environment You edit and build your project on the mbed website, down load the binary and drag it to the board.

I think there should be something about building non-chibios applications. At least in theory, the chibios install contains the files that you need, but they're in "unusual" locations. I don't think that you need a new linker script; the chibios one(s) are fine for bare metal applications as well, aren't they?

And maybe at least mention the Standard Peripheral Libraries that ST wants people to use. Even though they suck. :-(

And maybe at least mention the Standard Peripheral Libraries that ST wants people to use. Even though they suck. :frowning:

I agree The Standard Peripheral Library is not great.

I do like ST’s STM32CubeMX initialization code generator It’s good for choosing which pins are used for each peripheral and generating a first cut of initialization code.

STM32Cube includes the STM32CubeMX which is a graphical software configuration tool that allows generating C initialization code using graphical wizards.

I also like STM Studio

STMicroelectronics STM Studio helps debug and diagnose STM32 applications while they are running by reading and and displaying their variables in real-time

STM Studio is a non-intrusive tool, preserving the real-time behavior of applications.

The ARM mbed development site is a great way to try bare metal STM32 with an Arduino like environment. You don’t need to install any software, just develop on the website and down load the bin file. If you choose, you can install the open source libraries locally. With Nucleo you just drag and drop the bin file into the Nucleo mass storage volume that appears on your computer.

Here is output from a simple test program that writes the time in seconds and analog value to Serial monitor while blinking an led. See the attached screen dump of the development environment.

Hello World !
1 seconds. a0: 982
2 seconds. a0: 1012
3 seconds. a0: 1013
4 seconds. a0: 1013
5 seconds. a0: 1034
6 seconds. a0: 1008

If you click on a class, you get the documentation. I attached the top of the documentation for Serial.

There are many third party libraries available. For example there are FAT files systems libraries for SD cards, USB keys, and other devices.

The total cost here was $10.33 for a NUCLEO_F401RE with 512 KB of flash and 96 KB of RAM.