Program STM32F4 with UART

STM32F3 devices have a great feature. They can be programmed with the only USB to UART converter. Each device has a bootloader inside, which supports UART programming. This is not a very great method for Discovery boards, because they have a better and faster solution onboard, ST-link. But if you are working on your own board, then this solution can be quite nice.

In this tutorial, I will go through step-by-step how to program the device with USB->UART converter. I will use FTDI’s home made converter.

This will work on all STM32F4 boards (Discovery, Nucleo). Also, if you create own board.


  1. Insert your USB to the UART converter to the computer.
  2. Install drivers if necessary, prepare it to work, and go to devise manager and get COMx number.
  3. In my case, I put the FTDI converter, and I got the below mentioned result.
  1. Download Flash Loader Demonstrator from ST’s official site.
  2. Install loader.
  3. There are no specific settings to set. It should be understanding how to install it.
  4. Open loader. You should get something like in the image below.

Hardware connection requirements

  1.  Before we can continue with the loader program, we have to prepare hardware for the UART bootloader.
  2.  Get your board in your hands and do stuff.
  3.  Connect the respected connection as follow:
  • Find BOOT0 pin and set it to HIGH as show in below figure 1. On discovery boards, VDD pin is near BOOT0 pin, so if you have jumper, just put it on.
  • To use the USART bootloader, the host must be connected to the RX and TX pins of the desired USARTx interface via a serial cable.

Figure1. USART connection

  1. A pull-up resistor must be added if the pull-up resistor is not connected in the host-side connect pull up resistor.
    1. Note: +Vtypically is 3.3 V and R typically 100 KΩ.These values depend upon the application and the used hardware.
    1. An RS232 transceiver must be connected to adapt voltage level (3.3 to 12 V) between the STM32 device and host.
    1. To use the DFU, connect the microcontroller USB interface to a USB host (i.e. a PC).
    1. Find PB2 (BOOT1) pin and set it LOW. On discovery boards, the GND pin is near the PB2 pin, so if you have a jumper, just put it on.
    1. If you don’t have jumpers, you can take 2 provided on discovery board. They are on the GND, if you rotate discovery board, under ST-link.
    1. Reset device.
    1. We need to connect our USB to UART converter with STM32F3 device.
    1. STM32F3 supports many UART combination.
  2. TX: PA9; RX: PA10
  3. TX: PB10; RX: PB11
  4. I tested with these pins, maybe there are more pins.
  5. If you are working with STM32F3-Discovery, then pins PA9 and PA10 will work.

If you’re programming with respect to I2C connection connect the respected connection as shown below figure.

If you’re programming with respect to SPI connection connect the respected connection as shown below figure.

If you’re programming with respect to CAN connection connect the respected connection as shown below figure.

Note: When a bootloader firmware supports DFU, it is mandatory that no USB Host is connected to the USB peripheral during the selection phase of the other interfaces. After selection phase, the user can plug a USB cable without impacting the selected bootloader execution except commands which generate a system reset.

It is recommended to keep the RX pins of unused bootloader interfaces (USART_RX, SPI_MOSI, CAN_RX and USB D+/D- lines if present) at a known (low or high) level at the start up of the bootloader (detection phase). Leaving these pins floating during the detection phase might lead to activating unused interfaces.

Figure6. Exit Secure Memory function usage

Before starting bootloader look this below table then we can find list of communication ports available for bootloader.

  1. Let’s go back to our flash loader.
  2. If you get this, first make sure that you have the correct pinout. Also, make sure that BOOT pins are set correct.
  3. Then, disconnect your board from power (USB probably on discovery) and put power back, and in program test again. It should work and you should go to the next step.
  4. When you are OK with detection, you will get a window like the one below. Hit “Next”.

You will get a new window, where you have to select target.

  1. You have to take a value, for your device. If you have 1MB flash size, select STM32F4_1024K.
  2. For STM32F4-Discovery select STM32F4_1024K.
  3. STM32F429-Discovery is not supported, because there is processor with 2MB flash. This size is not supported by ST’s loader tool. This is very strange, because they didn’t update this.
  4. Hit “Next”.

New window will open. There you have to select your .hex, .bin or .s19 file.

  1. Select file under “Download to device” section.
  2. Leave other settings as they are.
  3. Hit “Next”. Program will automatically start with downloading data to STM32F4.

Correct written data will be shown with window like my below.

  1. Hit close.
  2. Program is written to device, but if you try to reset device, it will not work.
  3. You have to remove jumpers and reset, so that program will boot from flash and not waiting for UART.
  4. Actually, only BOOT0 has to be set back to LOW.
  5. PB2 (BOOT1) does not matter where it is, program will still boot.
  6. Hope it helps for you.


  1. No response from the target the boot loader can not be started.
  2. Unrecognized devices… please reset your device then try again.

Problem 1

  1. No response from the target the boot loader cannot be started.
  2. If you getting this kind of error.
  3. Change RX & TX and boot mode connected to pull-up resistor.

Note: connect boot pin to ground or VCC its depend of board it change

Problem 2

Still you getting this kind of error.

Note: after completion of connection as shown above figure.

After that you have to reset the board if you’re not doing this then you’re going to face this problem.

By Devilal

One thought on “PROGRAM STM32 WITH UART”
  1. Can we flash using teraterm or any other console via uart, with same uart settings sending only the hex or bin files to uart.

Leave a Reply

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