Skip to content

Application Note: Updating Firmware on a STM32 Device

Overview

This application note is used to update firmware on products based on the STM32 family of devices. This procedure is moderately complex and has the potential to damage your device or connected equipment if done improperly, so carefully read all instructions and then follow them exactly. If you encounter issues please contact support. We can also reprogram your device for you if you would like to return it for an update.

Required Materials

  • ST Link V2 Programmer - Genuine is preferred, Generic Option is OK but some have caused issues. Use at your own risk!
  • Female-Female Jumper wires (may be included with your programmer)
  • 4 Pins of Header (for circuit boards without header installed)
  • Computer Runnning Windows

Installing the Software

We recommend using the STM32 ST-LINK Utility which can be downloaded here. The newer STM32CubeProgrammer utility can be used as well and downloaded here, but we find it to be more complex than is necessary and it does not work well with some after market or older programmers.

Follow the standard installation procedures of downloading, unzipping, and running the installer for the programming utility.

Connecting the Programmer

  1. Remove the case from your device (ensure that it is NOT powered first).
  2. Locate the programming header which will be a single row of 4 pads or pins. Many products have it labeled as a programming port with a designation such as ISCP, ISP, ICSP, or similar. There may also be pin labels which say GND, SWCLK, SWDIO, and 3V3. If your board does not have the pins labeled individually then pin 1 (which has a different marking on the silkscreen corner marking as shown below) is GND followed by SWCLK, SWDIO, and 3V3.

Finding the programming header

  1. If your circuit board has header (pins) sticking out of these ports you can use female-female jumper wires to connect the programmer to the pins. If it just has the holes and pads you can use a small piece of header to connect and simply hold it in firm contact with the pads when programming. We find holding it at an angle works best as it ensures contact with the conductor on the inside of the pad.

Holding header at an angle

The connections should be made between GND, SWCLK, SWDIO, and 3V3 to the same pins on your programmer. See the examples below. We find taping the jumper pins together in the correct order to be most efficient.

Programmer connections

Generic programmers may be different pinouts, so follow the pinout on the programmer and use at your own risk! The genuine STLink programmer pinout is shown below.

STLink Pinout Diagram

  1. Connect the programmer to your computer's USB port and power on the device being very careful to stay clear of the internal connections as they may present hazardous voltages.
  1. Get the most recent version of the firmware for your device from the product page.
  2. Open the STM32 ST-LINK software.
  3. After following the "Connecting the Programmer" steps, click the connect icon in the top toolbar of the STM32 ST-LINK software. The device information should populate with the details of the microcontroller and things appear in the memory table as shown below.

Connecting to the microcontroller

  1. Click the program and verify icon.

Click the program and verify button

  1. In the window that pops up click browse and select the BIN or HEX file that you downloaded with the new firmware for the device. Click "Start"

Select the firmware file and begin programming

  1. Once the process completes you should see "Verification...OK" in the message window.

Verification of firmware

  1. Remove power and disconnect the programmer.
  2. Your firmware update is complete!

Updating the Firmware with STM32CubeProgrammer

Note that many of the generic programmers will not work with STM32CubeProgrammer and you will need to use the older STM32 ST-LINK software instead.

  1. Get the most recent version of the firmware for your device from the product page.
  2. Open the STM32CubeProgrammer software.
  3. After following the "Connecting the Programmer" steps, set the programmer type to "ST-LINK" and click connect.

Connecting to the microcontroller

  1. After connection, the device information should populate with the details of the microcontroller and things appear in the memory table as shown below. The icon at the top right of the screen will also change to "Connected".

Connecting to the microcontroller

  1. Select the program and erase tab on the left menu. Click browse and select the BIN or HEX file that you downloaded with the new firmware for the device. Click "Start Programming".

Select the firmware file and begin programming

  1. Once the process completes you should see "Download verified successfully" in the message window.

Click the program and verify button

  1. Remove power and disconnect the programmer.
  2. Your firmware update is complete!