The unique device identifier is ideally suited:
* for use as serial numbers (for example USB string serial numbers or other end applications)
* for use as security keys in order to increase the security of code in Flash memory while using and combining this unique ID with software cryptographic primitives and protocols before programming the internal Flash memory
* to activate secure boot processes, etc.
The 96-bit unique device identifier provides a reference number which is unique for any device and in any context. These bits can never be altered by the user.
The 96-bit unique device identifier can also be read in single bytes/half-words/words in different ways and then be concatenated using a custom algorithm.
According to the STM32F4 reference manual, the UUID is stored in memory at address 0x1FFF7A10.
Examples:
1. STM32-UID.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A simple header for reading the STM32 device UUID | |
* Tested with STM32F4 and STM32F0 families | |
* | |
* Version 1.0 | |
* Written by Uli Koehler | |
* Published on http://techoverflow.net | |
* Licensed under CC0 (public domain): | |
* https://creativecommons.org/publicdomain/zero/1.0/ | |
* | |
* Posted by "Electrical engineering and programming notepad" | |
* URL: https://ee-programming-notepad.blogspot.com/2017/06/reading-stm32f4-unique-device-id-from.html | |
*/ | |
#ifndef __UUID_H | |
#define __UUID_H | |
#include <stdint.h> | |
/** | |
* The STM32 factory-programmed UUID memory. | |
* Three values of 32 bits each starting at this address | |
* Use like this: STM32_UUID[0], STM32_UUID[1], STM32_UUID[2] | |
*/ | |
#define STM32_UUID ((uint32_t *)0x1FFF7A10) | |
#endif //__UUID_H |
2. Usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "STM32-UID.h" | |
void main() | |
{ | |
uint32_t idPart1 = STM32_UUID[0]; | |
uint32_t idPart2 = STM32_UUID[1]; | |
uint32_t idPart3 = STM32_UUID[2]; | |
// do something with the overall 96 bits | |
printf("idPart1: 0x%08X\n", idPart1); | |
printf("idPart2: 0x%08X\n", idPart2); | |
printf("idPart3: 0x%08X\n", idPart3); | |
} |