The
last time I scoffed at ATtiny 85 microcontrollers, matching poor octopus chips with an Arduino IDE. And then I wanted to see what a miracle is - STM32, whose fans look at AVR programmers (not to mention the arduinschiki) with some disapproval. In a quick googling process, it turned out that the STM32 “for idiots” exists - there is a
Leaf Maple project, within which there are two boards on the STM32F103 and a development environment that is a clone of the Arduino IDE.
The decisive factor was the cost. The Chinese version of the Leaf Maple Mini sells for $ 4, which is a little more expensive than the Arduino Nano. Having ordered three pieces, I began to wait.
')
Perhaps, with a bet on Maple, I hurried a little - the project is more likely dead than alive. IDE does not develop, there are no drivers without a tambourine under Windows 8, libraries are in embryo, complete despondency and desolation. For the sake of interest, I blinked the LED, running Maple IDE under OS X (it worked out of the box), and then began to think which side to approach the board for further study.
For starters, I found this. In the STM32F103CBT6 microcontroller (the name of the ST, I note, severe) on the Leaf Maple Mini board is sewn loader that works via USB with Maple IDE. It is located in flash memory. How to program the naked STM32? In a good way, you need to use ST-Link, because it allows you not only to “flash” the firmware, but also to debug it. And without this piece of iron what to do? Use the "system" loader STM32, working on the UART. Mini-board on the CP2102 chip in the bins there, you can start to kink.
The IDEs that are used to program the STM32 drive me longingly. The fact is that I am not a programmer, and the multiple windows with tabs and a bunch of scary letters cause a hidden reluctance to delve into all this. But it seems necessary. The least confused of the trinity (Keil, IAR, Coocox) seemed to me last.
So, the sequence of actions. We put Coocox, to it is the GCC compiler for ARM. Writing a masterpiece project - Blink. Then on the mounting board we assemble the structure from Maple Mini and CP2102. We find out that to fill the firmware you need something else, because the "coconut" wants ST-Link. Directly compiled code is easily flashed over UART using the utility from ST - Flash Loader Demonstrator. Now more.
Coconut with rake
I have no rake. The very first "ambush" - the current version of IDE (2.0) - is something strange, which suddenly does not support STM32F1xx. We delete, we put version 1.7.7, now we can create the project. We connect the GPIO to the project, take an example from this module with the Blink we need and rework it a bit to use the Maple Mini LED (PORT B ​​PIN 1). The initialization of the ports here is a whole song (understandable, but more complicated than on the AVR). That is, you need not just say, this port is the way out. This port - it must be turned on and clocked, and it will be a way out with a bow and a plushy, and not with a squiggle and a stud…
Iron assembly
Everything is simple - we take the module on the CP2102 and connect it with the STM32.
STM - 2102
RX1 - TX
TX1 - RX
GND - GND
Vin - VCC
One trick is how to make the STM32F103 run in the UART bootloader mode. The process is well described on the Leaf Labs website in the section “What to do if you ruin the USB bootloader”. We connect the BOOT1 leg to the ground, press the RESET and the second button, release the RESET, release the second button. Hi, loader!
We burn!
It remains to run Flash Loader Demonstrator and feed the bin-file to it, dangling after compilation somewhere in the depths of the project. It is curious how the operations in this utility are called. Download is Chip. And Upload is from the chip. My perception revolts, but maybe it’s accepted here.
Total
You can not just take and blink the LED on the STM32. Make it two clicks of the mouse (as in the Arduino) or a pair of commands avr-gcc and avrdude will not work here. Attempt (Maple IDE) was, but was blown away. Therefore, you have to really sit down and figure out how things work here.
UPD. Added a poll.