Blog

Erase the complete flash memory on a STM32 with OpenOCD

Lately I had the pleasure of working with Frank Voorburg on integrating his OpenBLT bootloader in a STM32F4 (precisely a STM32F405RG) based project. As a means to debug the microcontroller OpenOCD in combination with an Olimex ARM-USB-TINY-H JTAG adapter was used. For those not familiar with openocd, you can simply install it via

OpenOCD can be started via

However, it is necessary to have a openocd.cfg file present in the directory where openocd is invoked which defines the used microcontroller as well the used JTAG adapter. In our case openocd.cfg looked like that:

At one point of our integration effort it was necessary to erase the complete flash memory of the target microcontroller. Since the information on how to do it was not so easy to find I decided to document it here. First thing to do is to establish a telnet connection to the OpenOCD driver:

Than the execution of commands within the microcontroller needs to be stopped:

With the next command one can obtain various information about the flash present at the microcontroller:

The important thing here is that the STM32F4x uses the same flash model as the STM32F2x. This is important because the flash type 'stm32f2x' is used as a part of the next command to completely erase the flash:

Done 🙂 You have completely erased the flash of your STM32F4x microcontroller 🙂

0
  Related Posts
  • No related posts found.