Open Klave is an open source operating system for the Akai MPK2 keyboard series, including the MPK 225, MPK249, and the MPK261. This site explains how to get and compile Open Klave from source, as well as how to get precompiled binary .syx files you can load onto your keyboard directly over USB using the stock bootloader.
This site includes detailed developer notes on reverse engineering and building a bare metal operating system for the STM32 architecture. These notes include tips for starting out with GDB and Ghidra, compile time testing for hardware projects with different target chips than the host, and techniques for reversing sub-systems of a PCB and creating small proofs of concept that can be translated to C.