STM32F103 Minimum System Development Board

I've had some experience with ARM microcontrollers with STM32F4 Discovery Board.

That had a more powerful version of the STM32 chip and cost around $20

For quite a while I have been seeing the little ARM board on ebay for under $4 and with some research found that

they contained a factory installed serial bootloader, so no ST-LINK programmer is required you simply need a

USB-TTL Serial adapter (of which I have tons of).

This seemed like a good cheap way to go when a project required a more capable CPU than my beloved ATMega32.

These little boards have quite a lot for the price you pay.

  • The STM32F103C8T6 chip has 64Kflash, 20k SRAM and runs at 72MHz

  • The 8MHz main crystal as well as a 37.362KHz crystal are supplied.

  • A power LED, User LED, reset button and boot mode jumpers are included

  • A micro USB connector and ST-LINK connector are also supplied

  • the package also included header pins (thankfully NOT installed)

All this fits in about the space of a 40pin DIP chip so the entire board could easily be incorporated into your project.

Resources and Tools:

IDE and Toolchain:

While waiting for these little scamps to arrive from China I had plenty of time to hunt around the web
for anything that would help me get started. There's lots of stuff out there about using the Arduino IDE with these boards but I didn't really want to go in that direction just yet. One of the online sellers included links to a couple of sample projects specific to a particular IDE called CoIDE from www.coocox.org.

CoIDE is a free Eclipse based IDE that uses the GCC for ARM open source compiler.
I chose the older 1.7.8 version as it seemed more stable than the newer release and worked very well for me. (see below for the download links)
Once I had the GCC Compiler installed and the CoIDE installed I was able to load & build the blink example code I had found and was ready to program the chip.
I started with the ST Flash Demonstrator Utility (I eventually found something better but I'll discuss that later)
This was a bit tricky since it involved getting the jumper pins correct and for some reason you need to unplug the the serial adapter each time you launch the ST Flash Loader or it will not connect. I eventually figured all this out.
The downside with using the serial bootloader to program the board is that it's not supported in the CoIDE. so you need to build the project, find the .hex file, set the boot jumpers on the board to bootloader mode, then run the flash loader utility. I added a tiny switch that lives on the boot jumper pins to make it easier to set the mode and a batch file helped when launching the flash loader utility.
Another big downside is not being able to debug in the IDE. But were keeping things cheap here (for now)

A better serial flash loader:

Not really happy with the utility from ST a search of the web uncovered stm32Flash.
https://sourceforge.net/projects/stm32flash/

stm32flash was originally written by Geoffrey McRae and is since 2012 maintained by Tormod Volden. Many thanks to all involved with that project. This utility is provided only as source code so I had to figure out how to build it for Windows.
I'ts a command line only utility but it's a LOT faster than the ST utility and did not require the un-plugging of the adapter. I was able to create a nice batch file that was specific to the file structure used with my CoIDE projects. Now when I create a new project for this board I just copy the batch file in, edit it to change the project name, and from then on I simply click on the batch file to flash the chip.

( my Windows based version of stm32Flash is attached, way down at the bottom of the page... )

IDE Update 3/10/16

Once I was comfortable with the device and had built some projects, I took some time to investigate other IDE offerings.
I decided to limit myself to free IDEs that used the open source GCC for Arm compiler and most all of those were eclipse based. So in addition to the earlier mentioned CoIDE, I installed System Workbench for STM32 and GNU ARM Eclipse (the GNU/ARM plugin for eclipse) I struggled with the GNU/ARM plugin, and although I eventually got it working I found it a poor experience (at least for myself) and abandoned it.
The System Workbench for STM32 ended up being the IDE of choice for me (so far).
It is a bit more complicated than CoIDE and has less community support but it has a few features that made it a winner for me. The most important turned out to be the ability to add external tools to the IDE. A dropdown allows you to configure settings that will launch an external program. So I was able to configure a command to kick off the flash programmer utility with just 2 clicks. Later I added another to launch a PuTTY session. This allowed me to compile, program, and execute (with Putty) without leaving the IDE
These external tool configurations are stored with the project and eliminates the need to copy batch files to each new project.
Once I had a "template" project, or example one with routines for a serial menu and a blinking LED, It was a simple matter to copy the project, rename it, then add new functionality, all from within the IDE.
A quick search of the web revealed a way to add a serial terminal function directly into the IDE which would eliminate the need for PuTTY. I tried it but found it too easy to forget I was connected. Having the terminal connected will of course prevent you from using the serial flash programmer since they share the same COM port. When Putty is running it's a lot more obvious so I'm still using it.

IDE Update 10/1/19

I re-visited the eclipse IDE with the GNU/ARM plugin and now use that exclusively.

Once you get a sample project working it a simple matter to port the necessary files from my System Workbench projects to standard eclipse + GNU/ARM plugin projects.

ST Link Update 4/9/16

I ordered an ST Link V2 programmer from ebay for about $3.50.
It took many hours to get this working. Even as a stand-alone programmer.

I downloaded the ST Link utility from STM along with the latest drivers. Naturally nothing worked on my Windows 10 desktop. I finally got the utility to work by setting compatibility to Window XP SP3.
Then getting it to work in the IDE was even worse. Lots of experimentation and web searches were necessary before I found just the right combination of settings that worked. Even then it still throws up an error the first time into a debugging session. Second time works though. (sometimes one of the hardest tricks to find is simply trying a second time after an error) I'll stick with programming through the serial bootloader and only use the ST Link when I really get stuck and need to do true line by line debugging.

See the attached document for details on how to make it work.

128K Flash Update 3/2/17

I had been seeing reports that the chips on these boards actually have twice as much flash memory as advertised.
It's difficult to dig out of the datasheets but the STM32F103C8 is supposed to have only 64k and the STM32F103CB supports 128K. I suppose the manufacturer tests a run of chips and any that don't pass all the tests for 128K get the "8" part number. Recently I was experimenting with a new 1.8" color TFT LCD module and developed a utility to convert a .BMP image file into a header file (.h) that creates an array of bytes that can be sent to the LCD to display a picture.
Naturally this took up a bunch of flash memory. I figured out how to make the linker think the chip had 128K and was able to include 3 image files and uploaded over 101K to the chip. It worked just fine.

See this for more info: http://wiki.stm32duino.com/index.php?title=Blue_Pill

Using the Arduino IDE with this board.

That's right. If you really are in a hurry and want to get started with an IDE you're familiar with you can setup your Arduino IDE to load and run simple Arduino sketches on this little ARM board.

There's even a bootloader you can install on the board which will eliminate the need for the USB-Serial adapter.

Once it's installed you can upload and communicate with your programs using the on-board USB connector.

Click here for more details

Software:

The ST Flash Loader Demonstrator http://www.st.com/web/en/catalog/tools/PF257525

CoIDE Home Page http://www.coocox.org/software/coide.php

System Workbench for STM32 http://www.openstm32.org/System+Workbench+for+STM32

GCC Arm Compiler download page https://launchpad.net/gcc-arm-embedded/+download

GNU ARM for Eclipse extension http://gnuarmeclipse.github.io/

Image Gallery ** for larger image right click and open in new tab

Attachments Details:

Note: The entire projects collection can now be found on GitHub

https://github.com/emklaus/STM32F103-Sample-Projects

Debugging with ST Link in openSTM32 System Workbench.doc Steps to get debugging working with ST-Link.

STM32F103_24C02.zip Project: use I2c to interface with a 24C02 EEPROM

STM32F103_24C16.zip Project: use I2c to interface with a 24C16 EEPROM

STM32F103_5110.zip Project: drive a NOKIA 5110 84x48 LCD display

STM32F103_7SEG.zip Project: drive a single digit 7 segment LED display

STM32F103_ADC.zip Project: read analog voltage using A/D converter

STM32F103_EXTIx.zip Project: simple external interrupt example

STM32F103_GPIO1.zip Project: Blink the on-board LED

STM32F103_IRx.zip Project: use an IR detector module to read signals from TV remote control.

(*removed to save space - email me)

STM32F103_RTC.zip Project: using the Real Time Clock component and writing to flash memory

STM32F103_SDCard1.zip Project: read and write data to/from an SD card using SPI interface

(*removed to save space - email me)

STM32F103_SERVOx.zip Project: example to drive 4 RC servo motors

STM32F103_TIMx.zip Project: example using timer TIM3 to generate PWM driving an LED

STM32F103_USARTx.zip Project: basic template that implements a blinking LED and USART menu.

STM32F103_VCPx.zip Project: use the on-board USB to create a Virtual COM port

STM32F103_VGA1.zip Project: generate a VGA signal (*removed to save space - email me)

STM32F103_WAV.zip Project: use PCM to play .WAV files that have been stored in flash memory

STM32flash_Windosw.zip Windows version of serial flash programmer utility (includes .exe)