6_Programming with UART

Rok Palhartinger edited this page Jan 29, 2015 · 2 revisions

This is a litlle modified version of Tilen Majerle post of [Program STM32F4 with UART] (http://stm32f4-discovery.com/2014/09/program-stm32f4-with-uart/).

STM32F1 devices have great feature. They can be programed with only USB to UART converter. Each device has bootloader inside, which supports UART programming.

In this tutorial, I will go through step-by-step how to program device with USB->UART converter. I will use cheap USB2TTL CH340G converter.

This will work on STM32F103C8T6 board. It also works on others, but they have UART port's on different pins.

Step-by-step

  • Insert you USB to UART converter to computer.
    • Install drivers if necessary, prepare it to work, and go to device manager and get COMx number.
    • In my case, I put CH340G converter, and I got result below.

  • Download Flash Loader Demonstrator from ST’s official site.
  • Install loader.
    • There is no specific settings to set. It should be understandable how to install.
  • Open loader. You should get something like on image below.

  • Before we can continue with loader program, we have to prepare hardware for UART bootloader. Get your board in hands and do stuff:
    • Set BOOT0 pin and set it to HIGH, BOOT1 pin leave it on LOW.
    • Reset device

  • We need to connect our USB to UART converter with STM32F103C8T6 device.

    • STM32F4 supports many UART combination.

      • uart1 => TX: PA9; RX: PA10 (I tested with these pins, and works.)

      • uart2 => TX: PA02; RX: PA03

      • uart3 => TX: PB10; RX: PB11

      • Connect TX of STM32F103C8T6 with RX of converter and RX of STM32F103C8T6 with TX of converter.

  • Let’s go back to out flash loader.

  • Leave settings as they are, just change “Port Name“, to your port name. My is COM3.

    • Hit “Next”
  • If you have lucky, then you can go to the next step.

  • If you are not lucky, then you will probably get an error like one below:

  • If you get this, first make sure that you have correct pinout. Also, make sure that BOOT pins are set correct.
  • Then, disconnect your board from power (USB or CH340G) and put power back, and in program test again. It should work and you should go to the next step.
  • When you are OK with detection, you will get window like one below. Hit “Next”.

  • You will get a new window, where you have to select target.
    • You have to take a value, for your device. If you have 64KB flash size, select STM32F1_Med-density_64K.
  • Hit “Next”

  • New window will open. There you have to select your .hex, .bin or .s19 file.
    • Select file under “Download to device” section.
    • Leave other settings as they are.
    • If you prototyping, you don't want to make changes the boot1 jumper, so you could check the option "Jump to the user program". That will execute the program immediately after the download finished.

  • Hit “Next”. Program will automatically start with downloading data to STM32F103C8T6.

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

  • Hit close.
  • Program is written to device, but if you try to reset device, it will not work.
  • You have to remove jumpers and reset, so that program will boot from flash and not waiting for UART.
    • Actually, only BOOT0 has to be set back to HIGH
    • BOOT1 does not matter where it is, program will still boot.
  • Hope it helps for you.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.