How to flash firmware to STM32Fx

Unfortunately, you can’t flash firmware to STM32 with «Arduino» easiness, but I’ll describe how to do it.

First of all, you need separate hardware programmer, for example ST-Link V2 Mini

9d9cd4

You need to connect it to dev mini board and wiring is simple:

ST-Link        STM32F103C8T6
3.3V     ---       3.3V
GND      ---       GND
SWDIO    ---       DIO
SWCLK    ---       DCLK

Like this:

DSC_0473

Then you have to download from st.com and install ST-Link Utility. When you connect programmer first time, it is recommended to upgrade firmware of programmer itself. Open ST-Link Utility program and choose in menu ST-Link -> Firmware update, then click Device Connect and if newer firmware is available,  you will see something like this:

stlink_upgrade

Click Yes and newer firmware will be installed.

Then you have to open file with firmware and choose Target -> Connect. If your wiring between programmer and board is correct, you can see info about your MCU:

stlink2

Then you have to choose Target -> Program and thats all!

 

If my firmware for Pedal & Buttons controller already flashed to the board and needs to updated or reflashed than programmer will can’t connect to the board. Its because I disabled SWD and used its pins as normal GPIO. So in this case you have to do Connect under Reset

  • choose Target -> Settings in ST-Link utility
  • choose Hardware Reset in Reset Mode
  • push and hold Reset button on the board
  • click OK in ST-Link utility
  • release Reset button

ST-Link utility should now connect to stm board and you can flash a newer firmware.

 

PS. If you have another development board, for example STM32F4Discovery, you can use its build-in programmer. In this case you need to remove both CN3 jumpers and use Disco’s SWD connector this way:

STM32F4Discovery        STM32F103C8T6
3.3V              ---      3.3V
PIN2              ---      DCLK
PIN3              ---      GND
PIN4              ---      DIO

Something like this:DSC_0472

Реклама

Добавить комментарий

Заполните поля или щелкните по значку, чтобы оставить свой комментарий:

Логотип WordPress.com

Для комментария используется ваша учётная запись WordPress.com. Выход / Изменить )

Фотография Twitter

Для комментария используется ваша учётная запись Twitter. Выход / Изменить )

Фотография Facebook

Для комментария используется ваша учётная запись Facebook. Выход / Изменить )

Google+ photo

Для комментария используется ваша учётная запись Google+. Выход / Изменить )

Connecting to %s