cancel
Showing results for 
Search instead for 
Did you mean: 

MCU serial number

MJova.1
Associate II

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...

1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

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.

View solution in original post

9 REPLIES 9

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

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

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.

KnarfB
Principal III

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.

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.

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

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.

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

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

Thanks,

Pavel

I'm guessing, but probably Knarf meant OTP, not option bytes.

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.

Thank you KnarfB... I manage to do this....