updated 30 Jun 2021
Arduino for Black Pill
Background
Arduino originally employed microcontrollers lacking USB support.
Arduino now offers a few STM32 modules with integrated USB,
and ST Microelectronics now supports many STM32 chips and boards.
- Black and Blue Pill modules use the same Arduino board manager.
- Arduino wants STM32CubeProgrammer for Black Pill DFU; installed in Aurora E:\my
- added to path
- Setup package in USB1TB\Windows
Here is a Black Pill pinout reference:
- 5V tolerant PWM pins are wanted for driving hobby servos or 4-wire PC fans.
- Unlike Blue Pills, nearly all F401 Black Pill pins are 5V tolerant, but not PA0 and PB5 on STM32F411.
- Other Black (STM32F411) vs Blue (STM32F103) differences
- Black Pill
KEY
button pulls PA0 LOW - USB-C takes more pins; 14 remaining 5V-tolerant PWM pins: PA15,PB3 PB6-9 PB0,1 PB 10 PA6,7 PA1-3 T2 CH1,2 T4 CH1-4 T3 CH3,4 T2 CH3 T3 CH1,2 T5 CH2-4
T2 and T5 are 32-bit; T3 and T4 are 16-bit; T1 is advanced 16-bit
Two more complementary PWM: PB13,15: T1 CH 1,3
There are at least 4 ways to flash STM32 chips:
1) DFU (device firmware update) using DfuSe utility,
using the STM32 system memory bootloader in ROM,
using the Black Pill’s DFU bootloader with Arduino
By default, must force Black Pill into DFU using buttons on board
Arduino use_1200bps_touch
sketch code jumps to
STM32 ROM DFU bootloader.
Beta enhancement
Seemingly already supported for Arduino STM32 modules
May require a resistor and capacitor
2) SWD via ST-LINK
This can be used for any STM32 chip.
3) (Arduino) USB bootloader[s] <- there is seemingly at least one Adruino bootloader for Black Pill,
perhaps linked into sketches?
WeAct HID bootloader on Black Pill
4) STM serial bootloader for use with Arduino
A clone ST-LINK V2 costs no more than a USB COM dongle,
connects to dedicated pins and supports debug.
STM32duino
Arduino now has an ST Microelectronics-supported core and board manager
My clone ST-Link happens to have the correct pinout printed on its cover;
Verify ST-LINK clone pin artwork by sliding that cover partly open (along the USB plug):
Here is the Arduino software page.
Here is the Arduino for STM32 forum.
It replaced an earlier one, mostly for Maple/Roger Clark libraries.
Here is the READ-ONLY version of that earlier Arduino for STM32 forum.
STM32F411xC/E Reference manual
ST-LINK and Black Pill
Wiring Black Pill to ST-LINK V2 clone:
Connect 3.3V from ST-LINK to Black Pill only when Black Pill has no other connections
Put another way, when using ST-LINK to debug Black Pill e.g. plugged to USB,
do NOT connect 3.3V to Black Pill from ST-LINK.
Installing STM32duino support
Since SimHub already includes an older version of Arduino,
install the portable (ZIP file) version for STM32;
no need to install Arduino-specific driver[s]…
1) Download, unzip, and run Arduino
in my case, to E:\my\Arduino\
much of the following is thanks to sgbotic
2) Go to File
> Preferences
, add to Additional Board Manager URLs
text box:
https://github.com/stm32duino/BoardManagerFiles/raw/master/package_stmicroelectronics_index.json
3) Go to Tools
> Board
> Boards Manager
, enter search for STM32
:
click STM32 Cores
, then Install
(takes quite awhile)
4) Quit and restart Arduino; then
from Tools
> Board:
> STM32 Boards
, select [Generic STM32F4 series
].
From Tools
> Board Part Number:
, select [BlackPill F411CE
].
From Tools
> Upload method:
, select [STM32CubeProgrammer (DFU)
].
A simple next step uploads an Arduino blink loop sketch.