Black Pill STM32F4: pinout, specs, and Arduino IDE configuration – 4
This article will explain how to program the Black Pill STM32F4 microcontrollers. It can be considered the big brother of the STM32F1 series, more powerful, and with all the features of the F1 version.

One of the most exciting features of the Black Pill variant of STM32 has a built-in ROM bootloader that cannot be disabled or erased, and this makes it a fool-proof way always to be able to recover your microcontroller code.
But now we start to look at the STM32 family of microcontrollers, and then we’ll go deep into the STM32F4 series and learn how to use/program.
SMT32 details
The STM32 family of 32-bit microcontrollers is based on the Arm® Cortex®-M processor.
These products combine very high performance, real-time capabilities, digital signal processing, low-power / low-voltage operation, and connectivity while maintaining full integration and ease of development.
The range of STM32 microcontrollers, based on an industry-standard core, comes with a vast choice of tools and software to support project development, making this family of products ideal for small projects and end-to-end platforms.
Here the most commons STM32 STM32F103C8T6 STM32F401 STM32F411 ST-Link v2 ST-Link v2 official
Specs
There is a wide variety of stm32; here is a schematization of the main categories.
A more detailed classification can do with the part number decoding:
STM32F051R8
STM32xxwwyz
- xx – Family
- ww – subtype: differs in the equipment of peripherals and this depends on certain family
- y – Package pin count
- z – FLASH memory size
Family: [xx]
Code | Core | Max freq [MHz] | Max FLASH [KB] | Max SRAM [KB] | Target |
---|---|---|---|---|---|
F0 | Cortex-M0 | 48 | 256 | 32 | Mainstream |
F1 | Cortex-M3 | 72 | 1024 | 96 | Mainstream |
F2 | Cortex-M3 | 120 | 1024 | 128 | High performance |
F3 | Cortex-M4F | 72 | 512 | 80 | Mainstream |
F4 | Cortex-M4F | 180 | 2048 | 384 | High performance |
G0 | Cortex-M0+ | 64 | 128 | 36 | Mainstream |
G4 | Cortex-M4F | 170 | 512 | 128 | Mainstream |
F7 | Cortex-M7F | 216 | 2048 | 512 | High performance |
H7 | Cortex-M7F | 480 | 2048 | 1024 | High performance |
WB | Cortex-M4F | 64 | 1024 | 256 | Wireless |
WL | Cortex-M4 | 48 | 256 | 64 | Wireless |
L0 | Cortex-M0+ | 32 | 192 | 20 | Ultra-low-power |
L1 | Cortex-M3 | 32 | 512 | 80 | Ultra-low-power |
L4 | Cortex-M4F | 80 | 1024 | 320 | Ultra-low-power |
L4+ | Cortex-M4F | 120 | 2048 | 640 | Ultra-low-power |
L5 | Cortex-M33F | 110 | 512 | 256 | Ultra-low-power |
U5 | Cortex-M33F | 160 | 2048 | 786 | Ultra-low-power |
Package pin count [y]
Code | Number of pins |
---|---|
A | 169 |
B | 208 |
C | 48 |
F | 20 |
G | 28 |
H | 40 |
I | 176 |
J | 8/72 |
K | 32 |
M | 81 |
N | 216 |
Q | 132 |
R | 64 |
T | 36 |
U | 63 |
V | 100 |
Z | 144 |
FLASH memory size [z]
Code | FLASH size [KB] |
---|---|
4 | 16 |
6 | 32 |
8 | 64 |
B | 128 |
Z | 192 |
C | 256 |
D | 384 |
E | 512 |
F | 768 |
G | 1024 |
H | 1536 |
I | 2048 |
STM32F4 details
STM32F4 series of high-performance MCUs with DSP and FPU instructions
The ARM® Cortex®-M4-based STM32F4 MCU series leverages ST’s NVM technology and ART Accelerator™ to reach the industry’s highest benchmark scores for Cortex-M-based microcontrollers with up to 225 DMIPS/608 CoreMark executing from Flash memory at up to 180 MHz operating frequency.
With dynamic power scaling, the current consumption running from Flash ranges from 89 µA/MHz on the STM32F410 up to 260 µA/MHz on the STM32F439.
The STM32F4 series consists of eight compatible product lines of digital signal controllers (DSC), a perfect symbiosis of the real-time control capabilities of an MCU, and the signal processing performance of a digital signal processor (DSP):
- Advanced lines:
- 180 MHz CPU/225 DMIPS, up to 2 Mbytes of dual-bank Flash memory with SDRAM and Chrom-ART Accelerator™
- STM32F469/479 – Quad-SPI interface, LCD-TFT controller and MPI-DSI interface
- STM32F429/439 – LCD-TFT controller
- STM32F427/437 – serial audio interface, more performance and lower static power consumption
- 180 MHz CPU/225 DMIPS, up to 2 Mbytes of dual-bank Flash memory with SDRAM and Chrom-ART Accelerator™
- Foundation lines:
- STM32F446 – 180 MHz/225 DMIPS, up to 512 Kbytes of Flash memory with dual Quad-SPI and SDRAM interfaces
- STM32F407/417 – 168 MHz CPU/210 DMIPS, up to 1 Mbyte of Flash memory adding Ethernet MAC and camera interface
- STM32F405/415 – 168 MHz CPU/210 DMIPS, up to 1 Mbyte of Flash memory with advanced connectivity and encryption
- Access lines: The entry-level microcontrollers of the STM32F4 series!
- 84 MHz CPU/105 DMIPS, the smallest, cost-effective solution with outstanding power efficiency (Dynamic Efficiency™)
- STM32F401 – Less than 3 x 3mm with USB 2.0FS OTG and SDIO interfaces
- 100 MHz CPU/125 DMIPS, outstanding power efficiency (Dynamic Efficiency™) and Batch Acquisition Mode (BAM), a new smart DMA-optimizing power consumption for data batching
- STM32F410 – New milestone in outstanding power efficiency (89 µA/MHz and 6 µA in Stop mode), true random number generator, low-power timer, and DAC.
- STM32F411 – High RAM density and enhanced peripheral set such as USB 2.0FS OTG and up to 5 SPI interfaces.
- STM32F412 – High RAM and Flash memory density, USB interface, and enhanced peripheral set including a flexible external static memory controller with up to 16-bit data bus for LCD and external memory control, dual-mode Quad-SPI, CAN, DFSDM, and TRNG.
- STM32F413/F423 – Extends STM32F412 features with higher RAM and Flash memory density and an enhanced peripheral set including 10 UARTs, 3 CANs, SAI interface, a low-power timer, 2 DACs, 2 DFSDM with up to 6 filters. The STM32F423 includes AES encryption.
- 84 MHz CPU/105 DMIPS, the smallest, cost-effective solution with outstanding power efficiency (Dynamic Efficiency™)
Pinouts
The F401 model is one of the most popular, also considering the very affordable cost.
WeAct STM32F401CCU6 Black-Pill: high-resolution pinout and specs
The 411 version is certainly more performing, which also has an extra SPI, timer and I2S.
It is important to note pins 10 and 41 that F411 is not tolerant to 5V (check the red color of the square).
WeAct STM32F411CEU6 Black-Pill: high-resolution pinout and specs
But the 5V tolerance is one of the most important features of these F4xx series.
Arduino STM32 from STMicroelectronics
We must add the URL descriptor to our Arduino IDE.
https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
Go to File –> Preferences and add the URL on “Additional Boards Manager URLs.”
Then you must add a new board to Boards Manager
The boards to select are STM32 MCU-based boards.
Now you can choose the specified device:
Now we are going to select the specified board.
As already said, these devices have a DFU bootloader already uploaded, so you can use USB to program, and you must select the DFU bootloader.
To use Serial to debug your code, you must select "USB support (if It's available): "CDC (generic 'Serial' supersede U(S)ART)"
Install STM32CubeProgrammer
To work, you also need to install the STM32CubeProgrammer released from STMicroelectronics.
You can download It from here.
Select boot mode
Put this device in boot mode:
- hold down BOOT0 button;
- push NRST button;
- release NRST;
- release BOOT0.
Now you have the red PWR led only.
Simple Blink sketch for STM32F4
My device has an LED on PA13.
/*
Blink for STM32F4
Turns an LED on for one second, then off for one second, repeatedly.
http://www.mischianti.org
*/
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
// while (!Serial) {
// ; // wait for serial port to connect. Needed for native USB port only
// }
Serial.println(F("Serial OK!"));
pinMode(PC13, OUTPUT);
}
void loop() {
digitalWrite(PC13, HIGH);
Serial.println(F("HIGH!"));
delay(1000);
digitalWrite(PC13, LOW);
Serial.println(F("LOW!"));
delay(1000);
}
Now start the upload.
-------------------------------------------------------------------
STM32CubeProgrammer v2.9.0
-------------------------------------------------------------------
USB speed : Full Speed (12MBit/s)
Manuf. ID : STMicroelectronics
Product ID : STM32 BOOTLOADER
SN : 31A035713237
FW version : 0x011a
Board : --
Device ID : 0x0433
Device name : STM32F401xD/E
Flash size : 8 MBytes (default)
Device type : MCU
Revision ID : --
Device CPU : Cortex-M4
Memory Programming ...
Opening and parsing file: sketch_feb22a.ino.bin
File : sketch_feb22a.ino.bin
Size : 24296 Bytes
Address : 0x08000000
Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 1]
erasing sector 0000 @: 0x08000000 done
erasing sector 0001 @: 0x08004000 done
Download in Progress:
File download complete
Time elapsed during download operation: 00:00:01.101
RUNNING Program ...
Address: : 0x8000000
Start operation achieved successfully
If all It’s ok, your C13 LED starts to blink, and as if by magic new Serial port has appeared, for me COM12.
When connecting the serial monitor to the COM port, you get this result:
Serial OK!
HIGH!
LOW!
HIGH!
LOW!
HIGH!
LOW!
HIGH!
LOW!
HIGH!
Thanks
- STM32F1 Blue-Pill: pinout, specs, and Arduino IDE configuration (STM32duino and STMicroelectronics)
- STM32: program (STM32F1) via USB with STM32duino bootloader
- STM32: programming (STM32F1 STM32F4) via USB with HID boot-loader
- STM32F4 Black-Pill: pinout, specs, and Arduino IDE configuration
- STM32: ethernet w5500 with plain HTTP and SSL (HTTPS)
- STM32: ethernet enc28j60 with plain HTTP and SSL (HTTPS)
- STM32: WiFiNINA with ESP32 WiFi Co-Processor
- How to use SD card with stm32 and SdFat library
- \STM32: SPI flash memory FAT FS
- STM32: internal RTC, clock, and battery backup (VBAT)
- STM32 LoRa
- STM32 Power saving
- STM32F1 Blue-Pill clock and frequency management
- STM32F4 Black-Pill clock and frequency management
- Intro and Arduino vs STM framework
- Library LowPower, wiring, and Idle (STM Sleep) mode
- Sleep, deep sleep, shutdown, and power consumption
- Wake up from RTC alarm and Serial
- Wake up from the external source
- Backup domain intro and variable preservation across reset
- RTC backup register and SRAM preservation
Hi Renzo,
thank you very, very ! , much for this excellent description. You have saved me many lost hours, after I did not get the required support from my local german supplier. This guide line is perfect ! Yes my blue light is blinking and I can see the speed of the CPU is much higher that of ESP8266 or ESP32 or Arduino Nano, Uno, Mega. If you are interested to see the comparison, just send me an email as I have made the test already and will include the results in a PDF.
Hi Jos,
thanks, yes, I’d like to see It.
I am sending an email to you.
Bye Renzo
hi sir, can you send me blackpill bootloader…i cannot blinky the led like your step
Hi gibran,
you can find to the end of the article all the link to flash and download the firmware.
Bye Renzo
Thank you very much for creating an excellent introduction to using STM32F4xx boards with Arduino IDE. The serial USB example worked first time for me.
I have one question; I am trying to use hardware serial UARTs (1,2, and 6 on the STM32F411 pin out). In addition to your Serial USB example, I have found that Serial1 works on TXD1/RXD1 (PA9/PA10) but I get errors when trying to use Serial2 or higher (like on Arduino ATMEGA2560).
Is there some configuration necessary for STM32?
Hi Andy,
if I understand you must declare the Hardware Serial like so
HardwareSerial Serial2(USART2);
or
HardWareSerial Serial2 (PA3, PA2);
Bye Renzo
Hi Renzo,
Thank you for your reply.
Your suggested solution: “HardwareSerial Serial2(USART2);” works perfectly! I now see serial TX on PA2 and RX on PA3.
I look forward to experimenting with STM32 Blackpill.
Grazie mille!
Hi Andy,
Sure, keep us posted on your progress.
Bye Renzo
I am currently work on project with a custom STM32f411ceu6 chip. I would to upload the sketch from raspberry pi terminal without using Arduino IDE. I have installed all the required from this source: Site
TX (pin 8) — RX (pin A10); RX (pin 10) –TX (pin A9).
When I am running the command$ stm32flash -v -w led.ino.Generic_F411Cx.bin /dev/serial0.
The uploading is successful but the led isnot flashing connected to PIn 12 of the board. Any suggestion will be welcome.
Hi Sevic,
I never use a secondary micro controller as serial adapter, but pay attention to the jumper setting, if you select the boot position you risk to override the boot-loader and the sketch doesn’t start.
Bye Renzo
Hi Renzo,
Thanks for your excellent work! I am new to stm32 boards , follow your guide I successfully flashing the test code and the led blinks as expected. But the serial monitor didn’t print anything, anything wrong? BTW, I am using a stm32f401 board.
Eric
Thanks Lu,
Check the UsART parameter on Arduino ide.
Bye Renzo
I got problems connecting the ST-LINK v2 with the STM32F401CC, It was working perfectly till I burnt a code included PIN8 to PIN12 in PORTA as an output,
I was trying the code by the OCD, but after this I couldn’t reconnect the MCU with the PC again even with “STM32 ST-LINK utility” program. it gives me
** Can not connect to target!
Please select “Connect Under Reset” mode from Target->Settings menu and try again.
If you’re trying to connect to a low frequency application , please select a lower SWD Frequency mode from Target->Settings menu.
**
and when I try again it gives me
**
STLink USB communication error
**
Is there any way to clear the Flash memory by hardware ?
Hi Ariad,
try to use Visual Studio Code that simplify a lot this process and you can’t make errors.
Bye Renzo