cancel
Showing results for 
Search instead for 
Did you mean: 

Programming Flash in STM32F407

Ronald Brouwers
Associate II
Posted on April 05, 2017 at 22:20

Hi,

First, let me just say that I am new to the STM32 series of microcontrollers, so if I am asking the obvious, or has already answered somewhere else, I apologize.

Now, I want to use a bank of STM32F407s as co-processors for a bigger computer system. To this effect, I need to download firmware to the STM32s from the main CPU over and over again. I know I can do this using the bootloader in the STM32's system memory, but I am worried that it will not be able to recover, should the system memory gets corrupted.

So, I would love to program my code directly into the STM32's flash memory using JTAG or something similar, without going through software running on the chip. There is a lot of info about how to do this on the STM8 family, but nothing on the STM32.

How can I do that?

Ronald

5 REPLIES 5
Posted on April 07, 2017 at 01:20

I know I can do this using the bootloader in the STM32's system memory, but I am worried that it will not be able to recover, should the system memory gets corrupted.

This is not very likely without the chip being subjected to environmental stress far beyond normal operating conditions. Do you plan to operate it e.g. in a highly radioactive environment or at extreme temperatures?

You don't need to believe me but this is the way to go; the other one is lengthy, obscure, and full of pitfalls.

There is a lot of info about how to do this on the STM8 family, but nothing on the STM32.

The info is out there but as it is with other things in these SoCs, it's at the designer of the relevant IP block, in this case the debug modules which are part of the core. Ergo, you have to go to ARM to get most of that info; ST provides only the FLASH programming itself (which is described in the respective chapters of RMs). Be warned, ARM is not exactly famous for well-organized and easy-to-understand documents.

You can also have a look at open-source implementations of various levels of debuggers, namely the Cortex-M- relevant portions of OpenOCD but mainly the BlackMagic Probe.

JW

antonius
Senior
Posted on April 07, 2017 at 02:22

J-Link and ST-Link will do the job if you have the port for the chip doing it.

Ronald Brouwers
Associate II
Posted on April 08, 2017 at 00:53

Thanks guys. I've decided to go with both. I have additional I/O available on my main CPU, so will go through the bootloader for a start, but keep the connection between my main CPU and SWD interface for later.

Posted on April 08, 2017 at 01:04

I do not have a port. My main CPU is another ARM chip. Where do I find the source code for the ST-Link? I don't mind porting it myself.

Ronald

Posted on April 08, 2017 at 02:10

The source code for the ST-LINK is not available. You'd be better looking at open source implementations of the SWD/JTAG protocols if that is the way you want to go. Unless you're going into the cores at Fukushima I'm not sure I'd be loosing sleep about the System Memory OTP failing, more productive things to worry about.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..