Background on Building .hex Files for Pixhawk FMU

When Ardupilot Mission Planner uploads firmware to a Pixhawk flight controller, I assume it accesses a .hex file which can be used to upload machine code to, say, an STM32F427 microcontroller. This .hex file, of course, must have been built at some point. In the interest of adding new features:

-How best should one attempt building a .hex for a given platform (ex. Pixhawk 1 with FMUv2
consisting of an STM32F427) from modified source code?


Good day, hex files are used for boards that are no native for ardupilot like omnibusā€¦ kakuteā€¦ etc, ardupilot firmware have the extension apj.
The extension for px4 firmware is .px