2019-01-11 09:04 PM
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?
Solved! Go to Solution.
2019-01-12 06:19 AM
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
And the Get_SerialNum() here has an 8-byte implementation
2019-01-12 06:19 AM
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
And the Get_SerialNum() here has an 8-byte implementation
2019-01-14 01:10 AM
The link is not a community link, perhaps @Amel NASRI can assist.
2019-01-15 12:06 AM
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.
2019-01-15 12:31 AM
Unfortunately the "search" functionality now is less than stellar.
Does the System Loader do some contraction of the Unique ID?
2019-01-16 11:27 AM
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.
2019-01-16 12:13 PM
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];
2019-01-16 12:37 PM
"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
2019-01-16 12:51 PM
I doubt this is unique enough.
JW
2019-01-16 12:53 PM
Maybe ST would like to comment on why this implementation was chosen and what sort of uniqueness guarantees it does make.