By popular request on the Arduino forum, I’m posting a quick tutorial on how to use a generic / unbranded STM32F103 board I bought from an eBay supplier with the Arduino 1.5.x IDE.
Additionally I need to credit Bob Cousins for his work to bring the Maple hardware files etc into the Arduino 1.5.x IDE (see https://github.com/bobc/maple-asp )
Now down to business.
Currently I don’t have a Maple or Maple mini, ( I have a Maple mini clone on order from an eBay supplier, but it has not arrived yet)
I have what the eBay suppliers refer to as a STM32F103C8T6 ARM STM32 Minimum System Development Board
I initially thought this board was the same as the Maple mini clones, that seem to be prevalent now on eBay but its not the same board, however I will come back to this, probably in another post.
To program this board using a PC and the Arduino IDE..
- Download and install the Arduino 1.5.x (Beta) from the Arduino website ( http://arduino.cc/en/Main/Software#toc3 )
Although its a Beta, I’ve not had any issues using it with the normal AVR based Arduino boards, but it includes support for the Due which means it has the gcc -ARM compiler which is needed to compile for the STM32 which has an ARM core.
- Download the zip of the additional files for the Maple support from my GitHub repository https://github.com/rogerclarkmelbourne/Arduino_STM32 (experienced Git users may want just to clone the repo into the relevant location . – see step 3)
- Assuming you are using Windows .. Copy the files from the zip to My Documents\Arduino\hardware so that inside the hardware folder there is the Arduino_STM32 folder. Check that inside that folder you can see see the sub folders of drivers, tools and STM32F1XX
- If the Arduino 1.5.x IDE was running, you’ll need to restart it.
- In the Arduino IDE, under Tools->Board you will see “Maple boards” at the top (probably with “STM32 to Flash – no bootloader” selected
- If you have a maple mini and want to attempt to upload using USB, please at least for the moment, you’ll need to refer to mrbrunette’s posting somewhere in this thread on the Arduino forum (if I track down the details I’ll update this post)
- Assuming you want to go down the USB to Serial route (which is what I did), you need to connect the USB to Serial to Pins PA9 and PA10 which is USART1 on the STM32.
STM32 USBto serial
PA9 <–> RXD
PA10 <–> TXDOn my board, the real STM pin names are printed on the board, however I don’t think this is true on the Maple mini etc.
The schematic for the maple mini can be download as a PDF from here .
Looking at the Maple docs the pins for the serial ports are
Serial Port TX RX CK CTS RTS Serial1 D26 D25 D27 D24 D23 Serial2 D9 D8 D7 D11 D10 Serial3 D1 D0 D31 D30 D29
So it appears that for serial 1, the pins are D25 and D26. (CTS and RTS are not used)
You also need to power the board from the USB to Serial, my USB to serial has 3.3V out, so I’m using that, however there is a 5V in on both boards, you can use 5V as well.
- The rest of this tutorial will show you how to upload directly into the Flash on the chip.NOTE. THIS WILL ERASE THE MAPLE BOOTLOADER IF YOU HAVE ONE INSTALLED.However its possible to re-install the bootloader, but I’ll need to deal with that in a another post.
- Select the comm port of the USB to serial adaptor from within the IDE
- Make a new sketch
- Paste this codevoid setup()
// Set up the built-in LED pin as an output:
toggleLED(); // Turn the LED from off to on, or on to off
delay(250); // Wait for
- On the Maple mini, press and hold the “Button” then tap and release “reset”. This puts the board into serial flash upload mode
- In the Arduino IDE press upload. This will compile (a lot of files) and then upload
- Once the upload is complete, the LED on the maple should flash, this also works on the generic STM32 board as it also blinks pin PC13
If it has uploaded but nothing blinks, check you have a maple board or check where your LED is attached
If the board fails to upload, the best thing to do is unplug the usb to serial from the PC, then reconnect, reset the Maple using the same sequence as before and try again.
If it still fails to upload, check the serial connections are to the correct pins and are not swapped around.
I will post about more advanced things like Serial in a later post, but hopefully this would be enough of an introduction to get people up and running