STM32 bluepill as usb midi device - update firmware using SysEx?

Hi, I have midi controller based on the bluepill board. The idea is to flash a new firmware using usb midi rather than through the Arduino IDE. There would be a basic program which would write incoming midi stream to flash starting from a defined free address. I haven't done anything similar yet, so I any hints where to start would be helpful.

There is a project with similar feature described here: