Where does the STM32 store the target information? - Page 1
Forum section: electronics / general

author: Red_Micro
author_rank: Regular Contributor
timestamp: December 10, 2021, 04:23:57 am
content: Normally when we read a STM32 through ST Link we get some information (see attached) such as the device ID. Where is this information stored? In the ROM? This got me thinking that I want to store some non-volatile data by simulating a flash section as EEPROM. I know this process is slow, but I won't write frequently, that's why I think I could get away with using the internal flash.

author: ataradov
author_rank: Super Contributor
timestamp: December 10, 2021, 04:48:02 am
content: It is not really "stored" anywhere, it is just a device identifier that is read from the corresponding register.Specifically for this device, this part of the RM describes its location:QuoteYou can use flash as EEPROM, of course, this is a very common thing to do. But I don't see how it is related to the above ID.

author: AndyC_772
author_rank: Super Contributor
timestamp: December 10, 2021, 07:45:08 am
content: The part has a small amount of additional Flash which is factory programmed, with things like the boot loader and the unique 96-bit id.Only ST's engineers will ever really know for sure how the device ID is really implemented, but the obvious way would be to just factory program it into that Flash along with everything else.

author: DavidAlfa
author_rank: Super Contributor
timestamp: December 10, 2021, 11:05:21 am
content: You can read and program the flash without problem, just remember you must erase the whole sector, so first you must read and store it in the RAM, modify the desired values and write it back, you can't simply modify one byte there.

author: Red_Micro
author_rank: Regular Contributor
timestamp: December 10, 2021, 12:33:55 pm
content: Quote from: DavidAlfa on December 10, 2021, 11:05:21 amThanks for the further clarification. I was a bit confused as I was reading that I need to erase the whole sector before write it back. So it makes sense to read and use the RAM first.Quote from: ataradov on December 10, 2021, 04:48:02 amI need to store an unique ID as non-volatile, but I rather use the 96 unique ID embedded in the device. I thought one could also use that 16 bits device ID read by the debugger.

author: abyrvalg
author_rank: Frequent Contributor
timestamp: December 10, 2021, 12:40:53 pm
content: “Debugger’s” device ID can be read too, see ataradov’s answer. But it is the same on all CPUs of the same model.

author: mikerj
author_rank: Super Contributor
timestamp: December 10, 2021, 06:34:13 pm
content: There is anST App Noteon EEPROM emulation using flash.

author: fchk
author_rank: Frequent Contributor
timestamp: December 13, 2021, 08:51:52 pm
content: Quote from: Red_Micro on December 10, 2021, 12:33:55 pmMany of my boards have an AT24MAC402 I2C EEPROM. This chip has got two I2C device addresses, one for 256 bytes of eeprom, and +8 for Ethernet MAC plus 128 Bit UUID. This chip is available in small packages like SOT23-5, and it's cheap.http://ww1.microchip.com/downloads/en/devicedoc/Atmel-8807-SEEPROM-AT24MAC402-602-Datasheet.pdfThis might be a better solution for you.fchk

author: DavidAlfa
author_rank: Super Contributor
timestamp: December 14, 2021, 01:13:25 am
content: Each stm32 has its own 96bit UID.You have to check the reference manual, the memory address changes between models.You cannot change it, it's set in production and available as read-only for the user.There're tons of examples in Google searching "read stm32 uid”