DFU: set serial to match STM32 DFU bootloader
This commit is contained in:
parent
ceff33ea0e
commit
c411d552a1
@ -112,7 +112,7 @@ static const struct usb_config_descriptor usb_dfu_configuration = {
|
||||
};
|
||||
|
||||
/** device ID used as serial number */
|
||||
static char usb_serial[] = "00112233445566778899aabb";
|
||||
static char usb_serial[] = "0123456789ab";
|
||||
|
||||
/** USB string table
|
||||
* @note starts with index 1
|
||||
@ -340,15 +340,14 @@ static enum usbd_request_return_codes usb_dfu_control_request(usbd_device *usbd_
|
||||
|
||||
void usb_dfu_setup(void)
|
||||
{
|
||||
// set serial
|
||||
// set serial according to STM32 USB-FS_Device developer kit
|
||||
// see https://community.st.com/s/question/0D50X0000ADCaTJSQ1/dfu-serial-number
|
||||
for (uint8_t i = 0; i < LENGTH(usb_serial) - 1; i++) { // write the serial
|
||||
uint32_t id; // current ID part
|
||||
if (i < 8) {
|
||||
id = DESIG_UNIQUE_ID2;
|
||||
} else if (i < 16) {
|
||||
id = DESIG_UNIQUE_ID1;
|
||||
id = DESIG_UNIQUE_ID0 + DESIG_UNIQUE_ID2;
|
||||
} else {
|
||||
id = (DESIG_UNIQUE_ID0 << 16) + (DESIG_UNIQUE_ID0 >> 16);
|
||||
id = DESIG_UNIQUE_ID1;
|
||||
}
|
||||
// transform into character
|
||||
char c = (id >> ((7 - (i % 8)) * 4)) & 0x0f; // get nibble
|
||||
|
Loading…
Reference in New Issue
Block a user