cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 IC's Unique ID

sireevenkat1
Senior

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

1 ACCEPTED SOLUTION

Accepted Solutions
Peter BENSCH
ST Employee

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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

8 REPLIES 8
Peter BENSCH
ST Employee

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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

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

sireevenkat1_0-1712134530799.png

 

 

Peter BENSCH
ST Employee

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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

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

Peter BENSCH
ST Employee

Yes, your code would be a possibility.

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

@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

 

Hi @Andrew Neil ,

I included stm32g4xxx_hal.h file still I got the error.

Thanks

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.

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