Flashing this STM32 "Blue Pill" board took me 5 hours.
I finally recieved my microcontrollers. I have at disposal :
But the Blue Pill needs more work. Basically, I followed the instructions on this site : http://wiki.stm32duino.com/index.php?title=Installation
Since it's quite complicated, consider the following as a tutorial to set up your Blue Pill. I tried different things, the following has worked for me.
Before doing anything software-related, while reading the Blue Pill page ( http://wiki.stm32duino.com/index.php?title=Blue_Pill ), I found out that the USB connector is not really soldered, and is very fragile. Looking on my Blue Pill, I saw that the 4 legs didn't have any soldering tin. So I took my soldering iron out to add some tin on its 4 legs. It should make it sturdier.
The Blue Pill comes without bootloader. I will hence burn the STM32duino bootloader. The procedure is somewhat detailed here : http://wiki.stm32duino.com/index.php?title=Burning_the_bootloader
A simple way to achieve this is to use an external USB-Serial adapter. To achieve that, I simply used the CH340 chip embedded on my old (and dead) NodeMCU.
First things first, I connected the NodeMCU to the Blue Pill. I plugged as follows on the little scheme. You can notice that I pulled the NodeMCU RST to GND in order to disable the ESP8266, so that I can use freely the CH340 as USB-TTL adapter. It's a trick I've seen on some Youtube video. If you have for example an Arduino Uno, you can do the same by disabling the Atmel chip with this RST-GND strap.
Then, I put the jumpers to allow flashing. Just see the photo !
hoto. After doing this, you have to press the Reset button on the board. The onboard LED should stop blinking.
Then, I have to download some useful stuff :
After burning successfully, I unplugged everything. I installed the Windows drivers by launching the install_drivers.bat in the archive (it's in drivers --> win ). I put both jumpers on 0 (instead of 1 and 0). These jumpers indicate the BOOT mode (the upper one is jumper BOOT0, the lower one is BOOT1. In short, I put BOOT0 and BOOT1 to 0).
I opened my Arduino IDE and configured it to recognize the STM32 family. First, I opened the Board Manager and installed the Arduino Due. According to the STM32duino website, it should install the Cortex M3 compiler.
I added the STM32 boards repositories into the Arduino IDE by going into "Preferences", then adding into the repositories the following URL : http://dan.drown.org/stm32duino/package_STM32duino_index.json
Then, in the Board Manager, I installed the boards STM32F1xxx (just type STM32 in the research and choose the right one). I closed and re-opened the IDE, plugged the Blue Pill with the USB cable, and began my first Blink example :
/*
Blink: Turns on the built-in LED on for one second, then off for one second, repeatedly.
Arduino 1.6.0rc1
Sketch uses 11,900 bytes (11%) of program storage space. Maximum is 108,000 bytes.
Global variables use 2,592 bytes of dynamic memory.
Ported to Maple from the Arduino example 27 May 2011 By Marti Bolivar
*/
void setup() {
// Set up the built-in LED pin as an output:
pinMode(PC13, OUTPUT);
}
void loop() {
digitalWrite(PC13,!digitalRead(PC13));// Turn the LED from off to on, or on to off
delay(1500); // Wait for 1.5 second (1500 milliseconds)
}
The Arduino IDE uses "user-friendly" names for the pins. I used the pinout from the wiki (names in light yellow. It just corresponds directly to what's written on board, so it's really convenient. I just wrote "PC13" in order to control the Pin written "C13" on the board.
In the Windows Device Manager, before the first flashing, the Blue Pill appears as a Maple DFU. It's like a "ready-to-be-sketched" Maple Mini board. When launching the first upload on the Arduino IDE, it detects the Maple DFU and programs it in order to assign it to a COM port. After the first programming, the Blue Pill is detected as a Maple Serial (COM12) on my PC. I can't remember well, but if the first programming doesn't work because it doesn't find the Maple DFU (which may happen), just try again and quickly press the RESET button on the Blue Pill board when the Arduino IDE is searching for Maple DFU. It worked for me. I had a lot of different problems I can't really recall at this step ; try to re-burn the good bootloader if you can't find anything.
At last, I have a glorious STM32 "Blue Pill", ready to be programmed through the Arduino IDE. It was quite a pain to figure out some of these things, but hey, that's why I write on this blog. I hope this might help someone to set up all of this.
Final words : I though about calling this rant "Flashing open a cold "Blue Pill" one with the "Arduino" boys, but I don't think Google would reference it correctly.
See you next time where I'll play with buttons, LEDs, interrupts, I2C and LCD screen !
I finally recieved my microcontrollers. I have at disposal :
- A brand new WeMos D1 Mini (it's a smallish NodeMCU)
- An Arduino Pro Mini (it acts just like a Leonardo, but it lacks some interesting pins sadly :( )
- An STM32F103C8T6, I'll call this the Blue Pill for short.
But the Blue Pill needs more work. Basically, I followed the instructions on this site : http://wiki.stm32duino.com/index.php?title=Installation
Since it's quite complicated, consider the following as a tutorial to set up your Blue Pill. I tried different things, the following has worked for me.
Before doing anything software-related, while reading the Blue Pill page ( http://wiki.stm32duino.com/index.php?title=Blue_Pill ), I found out that the USB connector is not really soldered, and is very fragile. Looking on my Blue Pill, I saw that the 4 legs didn't have any soldering tin. So I took my soldering iron out to add some tin on its 4 legs. It should make it sturdier.
The Blue Pill comes without bootloader. I will hence burn the STM32duino bootloader. The procedure is somewhat detailed here : http://wiki.stm32duino.com/index.php?title=Burning_the_bootloader
A simple way to achieve this is to use an external USB-Serial adapter. To achieve that, I simply used the CH340 chip embedded on my old (and dead) NodeMCU.
My Blue Pill uses the USB-Serial chip from the NodeMCU for its bootloader flashing. |
First things first, I connected the NodeMCU to the Blue Pill. I plugged as follows on the little scheme. You can notice that I pulled the NodeMCU RST to GND in order to disable the ESP8266, so that I can use freely the CH340 as USB-TTL adapter. It's a trick I've seen on some Youtube video. If you have for example an Arduino Uno, you can do the same by disabling the Atmel chip with this RST-GND strap.
Then, I put the jumpers to allow flashing. Just see the photo !
Pins I linked together. Notice the RST-GND ! Plus, positions of the jumpers to allow bootloader flashing. |
Then, I have to download some useful stuff :
- I needed the STMicroelectronics software to flash your Blue Pill. You can download it on the ST website : http://www.st.com/en/development-tools/flasher-stm32.html . You'll need to enter a name and a valid e-mail address to get a download link.
- Then I needed this whole archive, it contains the Windows drivers (among others) : https://github.com/rogerclarkmelbourne/Arduino_STM32/archive/master.zip
- Finally, I found the bootloaders here : https://github.com/rogerclarkmelbourne/STM32duino-bootloader/tree/master/STM32F1/bootloader_only_binaries
After burning successfully, I unplugged everything. I installed the Windows drivers by launching the install_drivers.bat in the archive (it's in drivers --> win ). I put both jumpers on 0 (instead of 1 and 0). These jumpers indicate the BOOT mode (the upper one is jumper BOOT0, the lower one is BOOT1. In short, I put BOOT0 and BOOT1 to 0).
I opened my Arduino IDE and configured it to recognize the STM32 family. First, I opened the Board Manager and installed the Arduino Due. According to the STM32duino website, it should install the Cortex M3 compiler.
I added the STM32 boards repositories into the Arduino IDE by going into "Preferences", then adding into the repositories the following URL : http://dan.drown.org/stm32duino/package_STM32duino_index.json
You can see I already had the repository for ESP8266. The STM32duino has been added. |
/*
Blink: Turns on the built-in LED on for one second, then off for one second, repeatedly.
Arduino 1.6.0rc1
Sketch uses 11,900 bytes (11%) of program storage space. Maximum is 108,000 bytes.
Global variables use 2,592 bytes of dynamic memory.
Ported to Maple from the Arduino example 27 May 2011 By Marti Bolivar
*/
void setup() {
// Set up the built-in LED pin as an output:
pinMode(PC13, OUTPUT);
}
void loop() {
digitalWrite(PC13,!digitalRead(PC13));// Turn the LED from off to on, or on to off
delay(1500); // Wait for 1.5 second (1500 milliseconds)
}
The Arduino IDE uses "user-friendly" names for the pins. I used the pinout from the wiki (names in light yellow. It just corresponds directly to what's written on board, so it's really convenient. I just wrote "PC13" in order to control the Pin written "C13" on the board.
Blue Pill pinout. Credits : http://wiki.stm32duino.com/index.php?title=Blue_Pill |
In the Windows Device Manager, before the first flashing, the Blue Pill appears as a Maple DFU. It's like a "ready-to-be-sketched" Maple Mini board. When launching the first upload on the Arduino IDE, it detects the Maple DFU and programs it in order to assign it to a COM port. After the first programming, the Blue Pill is detected as a Maple Serial (COM12) on my PC. I can't remember well, but if the first programming doesn't work because it doesn't find the Maple DFU (which may happen), just try again and quickly press the RESET button on the Blue Pill board when the Arduino IDE is searching for Maple DFU. It worked for me. I had a lot of different problems I can't really recall at this step ; try to re-burn the good bootloader if you can't find anything.
Don't pay attention to the RIM Virtual Serial Port... I had a BlackBerry. |
At last, I have a glorious STM32 "Blue Pill", ready to be programmed through the Arduino IDE. It was quite a pain to figure out some of these things, but hey, that's why I write on this blog. I hope this might help someone to set up all of this.
Final words : I though about calling this rant "Flashing open a cold "Blue Pill" one with the "Arduino" boys, but I don't think Google would reference it correctly.
See you next time where I'll play with buttons, LEDs, interrupts, I2C and LCD screen !
Comments
Post a Comment