Black Pill STM32F4: pinout, specs, and Arduino IDE configuration – 4

Spread the love

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.

Black Pill STM32F4: pinout, specs, and Arduino IDE configuration
Black Pill STM32F4: pinout, specs, and Arduino IDE configuration

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


There is a wide variety of stm32; here is a schematization of the main categories.

STM32 family of 32bit microcontrollers categories
STM32 family of 32bit microcontrollers categories

A more detailed classification can do with the part number decoding:


  • 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]

CodeCoreMax freq [MHz]Max FLASH [KB]Max SRAM [KB]Target
F2Cortex-M31201024128High performance
F4Cortex-M4F1802048384High performance
F7Cortex-M7F2162048512High performance
H7Cortex-M7F48020481024High performance

Package pin count [y]

CodeNumber of pins

FLASH memory size [z]

CodeFLASH size [KB]

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
  • 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.
STM32F4xx comparison table
STM32F4xx comparison table


The F401 model is one of the most popular, also considering the very affordable cost.

STM32 STM32F401 STM32F401CCU6 pinout low resolution
STM32 STM32F401 STM32F401CCU6 pinout low resolution

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.

STM32 STM32F411 STM32F411CEU6 pinout low resolution
STM32 STM32F411 STM32F411CEU6 pinout low resolution

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.

Go to File –> Preferences and add the URL on “Additional Boards Manager URLs.”

Arduino IDE add Arduino STM32 URL descriptor
Arduino IDE adds Arduino STM32 URL descriptor.

Then you must add a new board to Boards Manager

Select board manager

The boards to select are STM32 MCU-based boards.

Arduino IDE select STM32 MCU official based boards
Arduino IDE selects STM32 MCU official-based boards

Now you can choose the specified device:

Arduino IDE Arduino SMT official select stm32f4 board series
Arduino IDE Arduino SMT official select stm32f4 board series

Now we are going to select the specified board.

Arduino IDE: Arduino SMT official, select specified stm32f401cc board
Arduino IDE: Arduino SMT official, select specified stm32f401cc 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.

STM32 Arduino IDE select Upload with DFU Bootloader
STM32 Arduino IDE select Upload with 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)"

STM32 Arduino IDE select: CDC generic 'Serial' supersede U(S)ART
STM32 Arduino IDE select: 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.

My device has an LED on PA13.

  Blink for STM32F4

  Turns an LED on for one second, then off for one second, repeatedly.

void setup() {
  // Open serial communications and wait for port to open:

//  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);
  digitalWrite(PC13, LOW);

Now start the upload.

                       STM32CubeProgrammer v2.9.0                  

USB speed   : Full Speed (12MBit/s)
Manuf. ID   : STMicroelectronics
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.

STM32 STM Serial DFU bootloader with Serial declaration
STM32 STM Serial DFU bootloader with Serial declaration

When connecting the serial monitor to the COM port, you get this result:

Serial OK!


  1. STM32F1 Blue-Pill: pinout, specs, and Arduino IDE configuration (STM32duino and STMicroelectronics)
  2. STM32: program (STM32F1) via USB with STM32duino bootloader
  3. STM32: programming (STM32F1 STM32F4) via USB with HID boot-loader
  4. STM32F4 Black-Pill: pinout, specs, and Arduino IDE configuration
  5. STM32: ethernet w5500 with plain HTTP and SSL (HTTPS)
  6. STM32: ethernet enc28j60 with plain HTTP and SSL (HTTPS)
  7. STM32: WiFiNINA with ESP32 WiFi Co-Processor
    1. STM32F1 Blue-pill: WiFi shield (WiFiNINA)
    2. STM32F4 Black-pill: WiFi shield (WiFiNINA)
  8. How to use SD card with stm32 and SdFat library
  9. \STM32: SPI flash memory FAT FS
  10. STM32: internal RTC, clock, and battery backup (VBAT)
  11. STM32 LoRa
    1. Unleashing IoT Potential: Integrating STM32F1 Blue-Pill with EByte LoRa E32, E22, and E220 Shields
    2. Unleashing IoT Potential: Integrating STM32F4 Black-Pill with EByte LoRa E32, E22, and E220 Shields
  1. STM32 Power saving
    1. STM32F1 Blue-Pill clock and frequency management
    2. STM32F4 Black-Pill clock and frequency management
    3. Intro and Arduino vs STM framework
    4. Library LowPower, wiring, and Idle (STM Sleep) mode
    5. Sleep, deep sleep, shutdown, and power consumption
    6. Wake up from RTC alarm and Serial
    7. Wake up from the external source
    8. Backup domain intro and variable preservation across reset
    9. RTC backup register and SRAM preservation

Spread the love

14 Responses

  1. Jos Wich says:

    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.

  2. gibran says:

    hi sir, can you send me blackpill bootloader…i cannot blinky the led like your step

  3. Andy Bentley says:

    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);
      HardWareSerial Serial2 (PA3, PA2);

      Bye Renzo

      • Andy Bentley says:

        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!

    • Sevic bel says:

      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

  4. LIU GANG says:

    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.

  5. ariad says:

    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 ?

Leave a Reply

Your email address will not be published. Required fields are marked *