I've been dabbling with arduino for some time, and found the new usb framework really amazing (PluggableUSB/HID are great concepts)!
My issue is that i'd like to delay the starting of the USBCore and get the PID and VID to use from an attached raspi clone via serial. So to do that, the serial would need to be initialized first, right? Is that the case in the current arduino runtime?
The second part would be to also get the information which device we shall configure with PluggableUSB (which also needs to be initialized statically) from serial too. So the actual op flow would be
USBCore init pause, send pidvid configuration request to serial, wait for response, resume USBCore init
Static initializer for PluggableUSB/HID, send USB config request to serial, wait for response, init PluggableUSB
I think the last part is the easier one, as I can hopefully just wait for serial input in my static setup code block. The USBCore changes seem trickier - I already scanned over the USBCore sources , but sadly my c skills are limited (thats why i love arduino and having a nodejs runtime on my raspi clone for doing the complex processing).
Still, i think to actually change the PID and VID from the USB_PID and USB_VID variables provided through the boards.txt file, i would just have to change https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/USBCore.cpp#L74 and then call a custom static function in the const definition, right?
If the approach through serial does not work, i have another idea (which is not as elegant): Save the pid/vid in eeprom/nvram, reset the mc via the raspi (which i also would do in the first scenario) and have it read the data needed during usbCore startup from eeprom (its methods are static, so that should always work, right?). One downside to this is that frequent changes of the usb config might wear out the eeprom.