Hardware

[PDF] Schematic STM32F103C8T6 Dev Board
Ref: [PDF] Blackmagic Probe (Original) Schematic/ Board Layout
Ref: [PDF] Blackmagic Probe(Mini) Schematic
Ref: http://www.stm32duino.com
Ref: http://www.espruino.com/Serial+Bootloader

Note: Check the value of the pull-up resistor connected to PA12. Forum posts indicate problems with the USB if this is 10kOhm (R10). The recommendation is for a 1.5kOhm resistor. I measured a 4.7kOhm resistor on my board and haven't experienced any issues.

STM32 Minimal System Board
STM32 Minimal System Board

The image above shows the STM32F103C8T6 Development board plugged into a breadboard. 5V & GND connections have been established. There us a 5V to 3.3V regulator on board which is why 5V is being used. The TTL-232R-3V3 provides 5V power but uses 3.3 for signals, exactly what is needed for this setup.

Serial Bootloader

All STM32 ARM chips contain a hardware bootloader allowing them to be programmed over the serial interface (USART1). I will be using a USB to Serial cable (FTDI TTL-232R-3V3) to perform my uploads.
Ref: http://www.ftdichip.com/Support/Documents/DataSheets/Cables/DS_TTL-232R_CABLES.pdf

Pin Connections for Serial Upload to target
Note: USB to Serial Converter TTL232R-3V3 (5V Power, 3.3V Signals)

TTL232R-3V3 Dev Board
Pin1 (Black) GND ----- GND (Various Pins)
Pin2 (Brown) CTS# Not Connected
Pin3 (Red) VCC[5V] ----- 5V/3.3V DC/DC Converter
Pin4 (Orange) TXD ----- PA10 (RX)
Pin5 (Yellow) RXD ----- PA09 (TX)
Pin6 (Green) RTS# Not Connected
STM32 Breadboard, Power & Serial Connections
STM32 Breadboard, Power & Serial Connections

To enable the bootloader set the jumpers on the board accordingly (See Image Above):
BOOT0 = 1
BOOT1 = 0
Then push the reset button.

To perform the upload I will be using a Python script called stm32loader.py available on GitHub https://github.com/jsnyder/stm32loader.
A slightly newer/modified version that does the same thing can be found at
https://github.com/espruino/Espruino/blob/master/scripts/stm32loader.py

Flashing a bootloader

I had found a page at http://leaflabs.com/docs/bootloader.html but this seems to be offline for some reason. An older version of the page can be found through the archive.org.The guide references/referenced a maple board to which a bootloader would be uploaded to allow flashing via the Arduino environment. The guide itself was applicable to loading up any program via the serial interface. It looks like I might have to come back to this and write it up in a little more detail.

Uploading a test program

I found a simple blinking LED test that was compatible with my hardware to have a go at uploading.

https://github.com/rogerclarkmelbourne/STM32duino-bootloader/blob/master/STM32F1/binaries/generic_boot20_pc13.bin

So now all I have to do is to test the upload.
- Plug in USB/Serial Converter and attach board
- Jumper BOOT0 = 1
- Jumper BOOT1 = 0
- Reset Board

The stm32loader.py should auto detect the converter so we can proceed to upload the program.
$ ./stm32loader.py -ew generic-boot20_pc13.bin 
-e = erase chip, -w= write file

On completion of upload
- Jumper BOOT0 = 0
- Reset Board
LED on PC13 should now be flashing.

If the LED isn't flashing then you may have made the same mistake I did. Open the bootloader.bin file in a text editor. It should look like gibberish. If it looks like html/xml content then you have managed to download a copy of the webpage rather than the file.
Download the raw file from GitHub and attempt the upload again.
$ ./stm32loader.py -e
$ ./stm32loader.py -r 8192 test
$ less text 

Time to pause at this point. The program we have uploaded should have been a maple bootloader for use with the Arduino environment. The issue with it at the time of writing is that it fails to enumerate as a usable port when connected to my machine. I am not overly concerned as I wasn't planning on continuing to use this method but it does halt proceedings a little. We have the hardware and a method of uploading a program to it (via Serial). The one thing that is not yet possible is to compile program for upload.

Back to Index

Leave a Reply