Skip to main content
Visitor II
January 21, 2021
Solved

MCU serial number

  • January 21, 2021
  • 3 replies
  • 2223 views

For some reasons it will be good to write my own MCU serial number for USB purpose.. Is it possible to change seria number of hte MCU and how to do this...

    This topic has been closed for replies.
    Best answer by KnarfB

    Any number that is persistently stored on the device will do. Could be stored in flash, user option bytes, external eeprom etc.. Just implement the Get_SerialNum(void) function and supply your own variant of deviceserial0 and deviceserial1.

    3 replies

    Graduate II
    January 21, 2021

    No, but you can write your own code to generate the USB Serial number

    MJova.1Author
    Visitor II
    January 22, 2021

    Some explanation will be good... I found that into usbd_desc.c file is is generated but I am not sure how I can add my own serial number. Some useful explanation with example will be good.

    Graduate II
    January 22, 2021

    It is putting an alpha/numeric identifier in a USB descriptor, how complicated can that be?​

    Why isn't the current method working for you now?

    I​f you want some linear number space, or particular form you have to manage the allocation and programming of each individual device.

    Graduate II
    January 22, 2021

    If you need to uniquely serialized each device at final test most of the challenge is how you manage that allocation. On the STM32 side you'd likely want to put serialization, configuration, keys and calibration ​data into FLASH or OTP areas you have set aside for that purpose.

    KnarfBAnswer
    Super User
    January 22, 2021

    Any number that is persistently stored on the device will do. Could be stored in flash, user option bytes, external eeprom etc.. Just implement the Get_SerialNum(void) function and supply your own variant of deviceserial0 and deviceserial1.

    Super User
    January 23, 2021

    @KnarfB​ Are there any option bytes that are available for random user data? In which STM32 family?

    Thanks,

    Pavel

    Super User
    January 25, 2021

    Not really/many, but they do exist. For example some F0 (RM0091) have 2 bytes of user data. That's okay for 2^16 boards.

    On some F7 (RM0385) you may use BOOT_ADD1 for that, if the feature is not needed.