Algorithm to derive USB-DFU DeviceDescriptor.iSerialNumber from UnigueDeviceID?
I have a device with STMF412 processor.
This device has UniqueDeviceID [1F 00 23 00 09 51 37 35 31 37 37 36 ]
- Contents of the register "Unique device ID register: (96 bits) at address UID_BASE 0x1FFF7A10UL
---------------------------------
When I boot into the application (USB-CDC communication was generated in CubeIde)
and I connect the device to the PC, so I read the following DeviceDescriptor for the USB-CDC device
Device Descriptor:
bcdUSB: 0x0201
bDeviceClass: 0x02
bDeviceSubClass: 0x02
bDeviceProtocol: 0x00
bMaxPacketSize0: 0x40 (64)
idVendor: 0x0483 (STMicroelectronics)
idProduct: 0x5740
bcdDevice: 0x0200
iManufacturer: 0x01 0x0409: "STMicroelectronics"
iProduct: 0x02 0x0409: "STM32 Virtual ComPort"
iSerialNumber: 0x03 0x0409: "365A37503537"
bNumConfigurations: 0x01
The serial number is calculated in the file usdd_desc.c by the function Get_SerialNum()
static void Get_SerialNum(void)
{
uint32_t deviceserial0, deviceserial1, deviceserial2;
deviceserial0 = *(uint32_t *) DEVICE_ID1; // [1F 00 23 00] 0x0023001F
deviceserial1 = *(uint32_t *) DEVICE_ID2; // [09 51 37 35] 0x35375109
deviceserial2 = *(uint32_t *) DEVICE_ID3; // [31 37 37 36] 0x36373731
deviceserial0 += deviceserial2; // 0x0023001F+0x36373731 = 0x365A3750
if (deviceserial0 != 0)
{
IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); "36 5A 37 50"
IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); "35 37"
}
}
---------------------------------
When I boot into DFU
and connect the device to the PC, I read the following DeviceDescriptor for the USB-DFU device
Device Descriptor:
bcdUSB: 0x0100
bDeviceClass: 0x00
bDeviceSubClass: 0x00
bDeviceProtocol: 0x00
bMaxPacketSize0: 0x40 (64)
idVendor: 0x0483 (STMicroelectronics)
idProduct: 0xDF11
bcdDevice: 0x2200
iManufacturer: 0x01 0x0409: "STMicroelectronics"
iProduct: 0x02 0x0409: "STM32 BOOTLOADER"
iSerialNumber: 0x03 0x0409: "365A375A3537"
bNumConfigurations: 0x01
---------------
Does anyone know how to derive the DFU-bootloader from the UniqueDeviceID [1F 00 23 00 09 51 37 35 31 37 37 36 ]
that serial number "365A375A3537" ? Which, unlike the CubeIde serial number, has the value "5A" instead of "50"?
( "365A37503537" vs "365A375A3537")
