2

Is there any memory on the STM32F407VG that is retained when a new program is flashed onto the chip?

I want to store a serial number on the device that is tied to the device, not the program.

I am aware there is a hardware identifier stored on the chip, but I want to create a more relevant number.

  • More relevant to what? When are you planning to change it (if it's not tied to the program)? Is your program meant to run on several different versions of the device? – barak manos May 22 '14 at 22:08
  • In general, you should check your project settings (the linker settings in particular), and/or your project's linker command file, which defines the different memory regions within your program. Both of these may have different structure on each IDE. For example, if you're using IAR, then your project's linker command file is `.icf`. – barak manos May 22 '14 at 22:12
  • The program will be running on many of the same chip – Neomanderx3 May 22 '14 at 22:44
  • So under what circumstances are you planning to change this number, and for what reasons (under these circumstances) do you want to make it independent from the version of your program? – barak manos May 22 '14 at 22:47
  • The number won't change. Is the version number stored on the chip somewhere as well? – Neomanderx3 May 22 '14 at 23:27

3 Answers3

2

As Etienne said in his answer, you can use the backup registers or backup SRAM but those imply having a backup power source. What I have done for the STM32F3, is use the Flash as an Emulated EEPROM. The drivers are on the ST website, you reserve a few pages of Flash as your 'EEPROM' and write whatever information you want there. On startup your device can read those values or modify them during program execution.

Described here: AN3969.(Application Note from ST, you can just google the ref. #)

A safety measure wold be to change linker file so those flash pages don't accidentally get overwritten if your code should grow larger.

Galaxy
  • 210
  • 4
  • 15
0

You can use the backup registers (20*32bits), or the backup SRAM (4kbytes).

Étienne
  • 4,773
  • 2
  • 33
  • 58
0

You can put this in the OTP area, which will keep the serial number for the life of the part.

OTP function description

Daniel
  • 111
  • 3