Steven Carmichael

signal processing, XR, sim racing, microscopes, STM32 and ESP32 projects


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: Generic STM32F4x1 board pinout

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): ST-LINK pin artwork

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

Wiring Black Pill to ST-LINK V2 clone: 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:
Boards Manager STM32 search
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.

SimHub Custom serial hacking is described here.