I've got a modified bootloader installed in an ATmega32u4 which contains a hard-coded USB serial number. The whole USB serial string descriptor is stored in a known location in the bootloader flash area. That's working fine.
I did this so that when I move the unit to a different USB port, Windows keeps the same COM port assignment.
What I'd like to do is hack the Arduino core (probably USBCore.cpp) so that it grabs the serial number string descriptor from the known location in bootloader memory and reports that as its USB serial number. Technically, I'll need to change one character in the serial number so that it is not identical to the bootloader's serial -- but that's easy to do and not shown below for the sake of simplicity.
I made some changes to USBCore.cpp that I thought might do the trick but it seems to have no effect. Perhaps I'm getting confused by the new "PluggableUSB" concept.
Here's the code I changed in the SendDescriptor function (USBCore.cpp) on or about line 530. This is a simplified version but it gets the idea across. Should this be working? I was assuming that if there's no pluggable modules defined, control would fall through to this section of code. Is there perhaps a better way to do this?
Anyway, any ideas or thoughts would be welcome.
else if (setup.wValueL == ISERIAL) {
#if 1
USB_SendControl(TRANSFER_PGM, (const void*)0x70B6u, 42u);
return true;
#else
#ifdef PLUGGABLE_USB_ENABLED
char name[ISERIAL_MAX_LEN];
PluggableUSB().getShortName(name);
return USB_SendStringDescriptor((uint8_t*)name, strlen(name), 0);
#endif
#endif
}