Skip to main content
shingadaddy
Senior
April 18, 2017
Solved

UID for STM32L4xx... Where?

  • April 18, 2017
  • 6 replies
  • 2811 views
Posted on April 18, 2017 at 22:04

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?

    This topic has been closed for replies.
    Best answer by shingadaddy
    Posted on April 18, 2017 at 22:59

    I did...

    #if

    0

    /*** 'F' devices' ****/

    #define

    DEVICE_ID1 (0x1FFF7A10)

    #define

    DEVICE_ID2 (0x1FFF7A14)

    #define

    DEVICE_ID3 (0x1FFF7A18)

    #endif

    // #if 0

    /*** 'L' devices ***/

    #define

    DEVICE_ID1 (0x1FFF7590)

    #define

    DEVICE_ID2 (0x1FFF7594)

    #define

    DEVICE_ID3 (0x1FFF7598)

    // #endif

    Works like I expected...

    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 FARTS Mode'

    iSerialNumber:        0x03

    0x0409: '207032954834'   < ------------------------   !! 

    bNumConfigurations:   0x01

    Each working with a DIFFERENT / REMEMBERED com port !

    No matter what USB hole.

    So -

    For the STM32L476 which address is correct for the UID register location ? 1FFF7A10 or 1FFF7590?   ( 1FFF7590 / 1FFF7594 / 1FFF7598 for L476 )

    And is the EVAL CDC demo fouled for this?  (Yes.... )

    Thanks!

    6 replies

    shingadaddy
    Senior
    April 18, 2017
    Posted on April 18, 2017 at 22:53

    Well why don't you just code that up and see what happens ?

    shingadaddy
    shingadaddyAuthorBest answer
    Senior
    April 18, 2017
    Posted on April 18, 2017 at 22:59

    I did...

    #if

    0

    /*** 'F' devices' ****/

    #define

    DEVICE_ID1 (0x1FFF7A10)

    #define

    DEVICE_ID2 (0x1FFF7A14)

    #define

    DEVICE_ID3 (0x1FFF7A18)

    #endif

    // #if 0

    /*** 'L' devices ***/

    #define

    DEVICE_ID1 (0x1FFF7590)

    #define

    DEVICE_ID2 (0x1FFF7594)

    #define

    DEVICE_ID3 (0x1FFF7598)

    // #endif

    Works like I expected...

    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 FARTS Mode'

    iSerialNumber:        0x03

    0x0409: '207032954834'   < ------------------------   !! 

    bNumConfigurations:   0x01

    Each working with a DIFFERENT / REMEMBERED com port !

    No matter what USB hole.

    So -

    For the STM32L476 which address is correct for the UID register location ? 1FFF7A10 or 1FFF7590?   ( 1FFF7590 / 1FFF7594 / 1FFF7598 for L476 )

    And is the EVAL CDC demo fouled for this?  (Yes.... )

    Thanks!

    Uwe Bonnes
    Chief
    April 18, 2017
    Posted on April 19, 2017 at 00:41

    Did you use the UID_BASE values given in the  STM32L4??xx.h header files?

    shingadaddy
    Senior
    April 19, 2017
    Posted on April 19, 2017 at 06:22

    Hi Uwe

    At first I used the values as shown in the EVAL USB CDC device demo.I got that from the CubeL4 example cdc code for

    EVAL. I was surprised each time I plugged in a different board and got the same com port. Knowing that was wrong, when I got time to look into it and saw the difference in the manual RM0351.and the usbd_desc.h file. I changed that .h file and it seems to work fine now.

    ST Technical Moderator
    May 10, 2017
    Posted on May 10, 2017 at 12:17

    Hello

    Palmer.Randall

    ,

    I have checked and confirmed thisissue.

    This is reported internally to take the necessary action.

    Thank you for your contribution.

    Imen

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    shingadaddy
    Senior
    May 10, 2017
    Posted on May 10, 2017 at 18:24

    Glad to help. Thanks Imen