USB-MIDI Bootloader- Best approach?

Hey everyone,

I would like to make a bootloader that can update firmware via SysEx messages received over MIDIUSB. Emilie Gillet made a standard serial midi bootloader several years ago, including a python script to convert a hex file to a SysEx file:

So my question is would the same thing be feasible using the arduino MIDIUSB library (which I believe is around 1Kb)? Can I simply add the MIDIUSB.h header file to the caterina bootloader and then get down to business making another option to flash the avr via the midi received over USB? I also want to retain the regular USB bootloader, so either method would work. (using an atmega32u4 btw)

I've never written a bootloader before and I don't mind investing the time to learn and study that, but what I'm wondering is if you can foresee any problems with using the MIDIUSB library in the bootloader. I am aware that I need to take precautions to avoid bricking the microcontroller if there is an error with the flashing.

Finally, if you're wondering why I want to do this, it's just an easier way for users/builders of arduino/avr based midi controller projects to upgrade the firmware without having to download the Arduino IDE. Internet browsers all support MIDI now, so it would be cool if people could just plug in their arduino/avr based midi controller to their computer via usb and then open a webpage which can talk to their midi controller over and do firmware upgrades over midi. I think the only other options to update firmware over the internet is with a wifi sheild and OTA.

Caterina uses the LUFA project for USB support. See lufa/Demos/Device/ClassDriver/MIDI at master · abcminiuser/lufa · GitHub for a LUFA MIDI example.

Getting the MIDIUSB library to work will probably be a bit more involved, because you need PluggableUSB support as well (see the USB-related files in ArduinoCore-avr/cores/arduino at master · arduino/ArduinoCore-avr · GitHub). Since the bootloader already uses LUFA, it's probably easiest to keep it.

Pieter