cancel
Showing results for 
Search instead for 
Did you mean: 

DFU Serial Number

Rob.Riggs
Senior

I am looking at the code here that has the algorithm for producing the device serial number reported when the MCU is in USB DFU mode.

https://github.com/libopencm3/libopencm3/blob/master/lib/stm32/desig.c

The document they reference there, https://my.st.com/52d187b7, is now a dead link. Does anyone have the name of the document and its current location?

1 ACCEPTED SOLUTION

Accepted Solutions

It's is likely are very old forum reference. Perhaps @brk​ or @Amel NASRI​ can dig it out

The interference here is this is a 6-byte contraction used by the System Loader. I would suppose you could quickly verify this by pulling the 96-bit unique ID for a unit and contrasting that with the reported serial number.

UM0424 doesn't really cover this

https://www.st.com/content/ccc/resource/technical/document/user_manual/01/c6/32/df/79/ad/48/32/CD00158241.pdf/files/CD00158241.pdf/jcr:content/translations/en.CD00158241.pdf

And the Get_SerialNum() here has an 8-byte implementation

https://github.com/fthorey/swiftler-bones/blob/master/stm32/STM32_USB-FS-Device_Lib_V3.3.0/Project/Device_Firmware_Upgrade/src/hw_config.c

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

View solution in original post

13 REPLIES 13

It's is likely are very old forum reference. Perhaps @brk​ or @Amel NASRI​ can dig it out

The interference here is this is a 6-byte contraction used by the System Loader. I would suppose you could quickly verify this by pulling the 96-bit unique ID for a unit and contrasting that with the reported serial number.

UM0424 doesn't really cover this

https://www.st.com/content/ccc/resource/technical/document/user_manual/01/c6/32/df/79/ad/48/32/CD00158241.pdf/files/CD00158241.pdf/jcr:content/translations/en.CD00158241.pdf

And the Get_SerialNum() here has an 8-byte implementation

https://github.com/fthorey/swiftler-bones/blob/master/stm32/STM32_USB-FS-Device_Lib_V3.3.0/Project/Device_Firmware_Upgrade/src/hw_config.c

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

The link is not a community link, perhaps @Amel NASRI​ can assist.

Yes this seems to be an old link in the platform used before migrating to Jive.

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.

Unfortunately the "search" functionality now is less than stellar.

Does the System Loader do some contraction of the Unique ID?

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

The code I referenced does indeed match the serial number of the DFU serial number. I was just hoping to have an official reference to the algorithm I could point to. Finding dead links to a major developer resource like st.com is rather disappointing.

ST has gone through at least 4 forum softwares, a lot of content has been damaged or lost.

Unfortunately the cite in the code you provided lacks any title information so it's have to cross-reference via other means.

I don't recall the post or the functionality described in DFU related docs.

	uint8_t *id = (uint8_t *)DESIG_UNIQUE_ID_BASE;
 
	uint8_t serial[6];
	serial[0] = id[11];
	serial[1] = id[10] + id[2];
	serial[2] = id[9];
	serial[3] = id[8] + id[0];
	serial[4] = id[7];
	serial[5] = id[6];

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

https://www.st.com/content/ccc/resource/technical/document/user_manual/01/c6/32/df/79/ad/48/32/CD00158241.pdf/files/CD00158241.pdf/jcr:content/translations/en.CD00158241.pdf

"In all available demos in the “STM32 USB-FS_Device developer kit�? there is an example implementing a unique serial number string descriptor based on the STM32 Device Unique ID register (12 digits)."

Here from V3.2.1 does not look consistent

/*******************************************************************************
* Function Name  : Get_SerialNum.
* Description    : Create the serial number string descriptor.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void Get_SerialNum(void)
{
  uint32_t Device_Serial0, Device_Serial1, Device_Serial2;
 
  Device_Serial0 = *(__IO uint32_t*)(0x1FFFF7E8);
  Device_Serial1 = *(__IO uint32_t*)(0x1FFFF7EC);
  Device_Serial2 = *(__IO uint32_t*)(0x1FFFF7F0);
 
  Device_Serial0 += Device_Serial2;
 
  if (Device_Serial0 != 0)
  {
    IntToUnicode (Device_Serial0, &DFU_StringSerial[2] , 8);
    IntToUnicode (Device_Serial1, &DFU_StringSerial[18], 4);
  }
}
 
/*******************************************************************************
* Function Name  : HexToChar.
* Description    : Convert Hex 32Bits value into char.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len)
{
  uint8_t idx = 0;
 
  for( idx = 0 ; idx < len ; idx ++)
  {
    if( ((value >> 28)) < 0xA )
    {
      pbuf[ 2* idx] = (value >> 28) + '0';
    }
    else
    {
      pbuf[2* idx] = (value >> 28) + 'A' - 10;
    }
 
    value = value << 4;
 
    pbuf[ 2* idx + 1] = 0;
  }
} 

STM32 DFU Serial Unique

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

I doubt this is unique enough.

JW

Maybe ST would like to comment on why this implementation was chosen and what sort of uniqueness guarantees it does make.