AnsweredAssumed Answered

UID for STM32L4xx... Where?

Question asked by shingadaddy on Apr 18, 2017
Latest reply on May 10, 2017 by shingadaddy

My understanding of the UID is it's plopped into the device by ST and not touchable write-wise (read only) .

Makes it good for use in SERIAL number application like USB descriptor serial number string.


For the STM32L476 which address is correct for the UID register location ? 1FFF7A10 or 1FFF7590?

And is the EVAL CDC demo fouled for this?

-------------------------------------------------------------------------------------------------


STM32L476 manual RM0351  (REV 5 March 2017) says


49.1 Unique device ID register (96 bits)

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 part of the 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 cannot be altered by the user.

Base address: 0x1FFF 7590   (DING DING DING !!!)

----------------------------------------------------------------------------------------------

 

 

----------------------------------------------------------------------------------------------


EVAL USB CDC demo code file usbd_desc.h says :


/* Exported constants --------------------------------------------------------*/

#define DEVICE_ID1 (0x1FFF7A10)

#define DEVICE_ID2 (0x1FFF7A14)

#define DEVICE_ID3 (0x1FFF7A18)

-----------------------------------------------------------------------------------------------


------------------------------------------------------------------------------------------------

EVAL USB CDC demo code that USES that stuff. usbd_desc.c says:


/**

* @brief Create the serial number string descriptor

* @param None

* @retval None

*/

static void Get_SerialNum(void)

{

uint32_t deviceserial0, deviceserial1, deviceserial2;

 


 deviceserial0 = *(uint32_t*)DEVICE_ID1;  (0x1FFF7A10) ???????

 deviceserial1 = *(uint32_t*)DEVICE_ID2;  (0x1FFF7A14) ???????

 deviceserial2 = *(uint32_t*)DEVICE_ID3;  (0x1FFF7A18) ???????


deviceserial0 += deviceserial2;


if (deviceserial0 != 0)

{

 IntToUnicode (deviceserial0, &USBD_StringSerial[2] ,8);

 IntToUnicode (deviceserial1, &USBD_StringSerial[18] ,4);

}

}

------------------------------------------------------------------------------------------------

 


Nobbling all that together and programming the device with it, then snooping gets me THIS!:


Device Descriptor:
bcdUSB:             0x0200
bDeviceClass:         0x00
bDeviceSubClass:      0x00
bDeviceProtocol:      0x00
bMaxPacketSize0:      0x40 (64)
idVendor:           0x0483 (STMicroelectronics)
idProduct:          0x5740
bcdDevice:          0x0200
iManufacturer:        0x01
0x0409: "STMicroelectronics"
iProduct:             0x02
0x0409: "STM32 Virtual ComPort in FS Mode"
iSerialNumber:        0x03
0x0409: "FFFFFFFEFFFF"    <------------------------- !
bNumConfigurations:   0x01

 


And it gets me THIS "FFFFFFFEFFFF" on EVERY device I program.


Oh...   And COM 6 is very prevalent... On EVERY DEVICE I PLUG IN.

 


So in the EVAL DEMO - It looks like maybe the "1FFF7A10" register address is maybe okay for F devices. Right ?

Looks like the L476 family it might need to be 1FFF7590. Right ?

 


What I sort of expected was -

Every device I plug in has the same VID
Every device I plug in has the same PID
Every device I plug in has a DIFFERENT USB SERIAL NUMBER STRING


If I have 3 devices for example ( 3 separate micros on separate PCB's) Every device I plug in gets a NEW VCP com port number the
first time. (Different serial number - or SUPPOSED to be anyway)

From THEN ONWARD - unless someone clears the allocated com port numbers from the Windows box

Device 1 - Gets that SAME COM PORT NUMBER (com3 for example) tied to it, no matter what hole I plug it in to on that PC. (SERIAL NUMBER remembered by WINDOWS).
Device 2 - Gets that SAME COM PORT NUMBER (com4 for example) tied to it, no matter what hole I plug it in to on that PC. (SERIAL NUMBER remembered by WINDOWS).
Device 3 - Gets that SAME COM PORT NUMBER (com5 for example) tied to it, no matter what hole I plug it in to on that PC. (SERIAL NUMBER remembered by WINDOWS).

Please correct me where I went off track?

Outcomes