Running an arduino sketch will build and flash the firmware, so that's the easiest way to go about it. The USB stuff is the Arduino's "ArduinoCore-samd" repo: https://github.com/arduino/ArduinoCore-samd
I've found the easiest way to hack on the samd core is to find the installed samd core, move it aside, and symlink to a clone of the github repo. On my mac the samd core gets installed in ~/Library/Arduino15/packages/arduino/hardware/samd/1.6.2/
If that works out then a similar modification could also be made to the bootloader, which is also part of the same repo. However, at that point it would probably make sense to engage with the Arduino folks to get the change incorporated into the mainline ArduinoCore-samd release so it can be used on other samd-based boards (like the Arduino Zero) and doesn't have to be maintained separately.