2024-04-02 11:08 PM
Hi,
I am using STM32G491RE MCU for my project. Is it true each STM32 IC has its own unique ID. For STM32G4 product has the UID facility. Is it 96-bit ID for all the stm32 families or is it different.
Which manual has to be referred for this?
If yes can I use that for serial number for the product.
Which memory location is it stored?
Can read that from IC and send it through UART?
Can anyone suggest.
Thanks
Solved! Go to Solution.
2024-04-03 02:41 AM
Correct, 0x1FFF7590 is the base address (named UID_BASE in the firmware) of the UID.
It is also correct that the UID is factory programmed and cannot be changed.
The UID can be determined simply by reading the three 32-bit values UID_BASE, UID_BASE+4 and UID_BASE+8. You can also use the HAL or LL library to do this:
stm32g4xx_hal.c:
uint32_t HAL_GetUIDw0(void)
uint32_t HAL_GetUIDw1(void)
uint32_t HAL_GetUIDw2(void)
stm32g4xx_ll_utils.h:
uint32_t LL_GetUID_Word0(void)
uint32_t LL_GetUID_Word1(void)
uint32_t LL_GetUID_Word2(void)
Of course you can use this UID as a unique serial number.
Regards
/Peter
2024-04-02 11:24 PM
If the UID feature is included, all STM32s have their own and unique - across all families of STM32s.
The Unique device ID feature is described in the respective reference manual, for the STM32G4 in RM0440, section 48.1
Theoretically you can use the UID for a serial number, but then it is 96bit long. As soon as you truncate it, a unique serial number is no longer given.
The address of the serial number can be found in the section of the reference manual mentioned above.
Of course you can read out the UID and send it as you wish.
Does it answer your questions?
Regards
/Peter
2024-04-03 02:04 AM
Thanks @Peter BENSCH for the quick response.
I referred the RM0440,As below image they mentioned base address 0x1FFF7590.Is that the address of UID number stored memory.
If so, that address is not stored in flash/system memory/OTP/option bytes but it is factory programmed memory.
Can you please provide the resources to read the UID number from MCU.
As soon as you truncate it, a unique serial number is no longer given.
I am not planning to reduce the UID number If I use that UID,I will use full 96-bit number then can I use that number for serial number?
Thanks
2024-04-03 02:41 AM
Correct, 0x1FFF7590 is the base address (named UID_BASE in the firmware) of the UID.
It is also correct that the UID is factory programmed and cannot be changed.
The UID can be determined simply by reading the three 32-bit values UID_BASE, UID_BASE+4 and UID_BASE+8. You can also use the HAL or LL library to do this:
stm32g4xx_hal.c:
uint32_t HAL_GetUIDw0(void)
uint32_t HAL_GetUIDw1(void)
uint32_t HAL_GetUIDw2(void)
stm32g4xx_ll_utils.h:
uint32_t LL_GetUID_Word0(void)
uint32_t LL_GetUID_Word1(void)
uint32_t LL_GetUID_Word2(void)
Of course you can use this UID as a unique serial number.
Regards
/Peter
2024-04-03 04:47 AM - edited 2024-04-03 04:56 AM
Hi @Peter BENSCH ,
I am trying to read the STM32 IC UID number.
#define STM32_UUID ((uint32_t *)0x1FFF7590)
uint32_t idPart1 = STM32_UUID[0];
uint32_t idPart2 = STM32_UUID[1];
uint32_t idPart3 = STM32_UUID[2];
printf("Unique ID: %lu,%lu,%lu\n", idPart1, idPart2, idPart3);
Is it correct way of getting the values??
With below code I got undefined reference to HAL_GetUID error.
uint32_t HAL_GetUIDw0(void)
uint32_t HAL_GetUIDw1(void)
uint32_t HAL_GetUIDw2(void)
Thanks
2024-04-03 05:12 AM
Yes, your code would be a possibility.
2024-04-03 05:19 AM - edited 2024-04-03 05:22 AM
@sireevenkat1 wrote:With below code I got undefined reference to HAL_GetUID error.
uint32_t HAL_GetUIDw0(void)
uint32_t HAL_GetUIDw1(void)
uint32_t HAL_GetUIDw2(void)
Thanks
That means you didn't include the HAL source files which define the HAL_GetUID...() functions.
EDIT
Probably called something like stm32g4xxx_hal.c
2024-04-03 09:21 PM
Hi @Andrew Neil ,
I included stm32g4xxx_hal.h file still I got the error.
Thanks
2024-04-04 12:32 AM
Check modules pulled in via stm32g4xx_hal_conf.h
If Linker error, check the sources pulled in by the project.
Search sources and library code for the functions.Check they are part of the project or if any preprocessor definitions that would preclude inclusion of the code/functions.