The current situation is that flashing via QGroundControl and/or the PX4 build system is not possible.
The architecture of flight controllers that use the H750 (or other ST value-line) MCU's is different, the value-line CPUs have limited flash for a vendor specific, and often secure, bootloader that provide functionality for exposing the external flash that is connected via QSPI. The PX4 code runs directly from external flash when the CPU is in memory mapped mode. Bootloaders often provide other functionality, such as USB Mass-Storage or USB-DFU support for firmware updates, methods to boot from SD cards, dual boot functionality, diagnostics, methods to erase/reset config/firmware/entire external flash, etc. Vendors also may use 'Option bytes' that enable ST's secure boot functionality.
I propose that support for the H750 with external QSPI flash is added to the PX4 bootloader codebase, and that it's build-scripts are updated so that it can build an EXST format images.
== Background ==
The H750 has a single 128k page of flash which contains the vendor's bootloader.
In the case of the H7EXTREME the PX4 firmware has to be updated using DFU mode of the SPRacing bootloader. The vendor bootloader is non-upgradable and is write protected. It should not be erased.
== Boot process ==
The PX4 boot process is currently:
- power on
- run vendor bootloader code
- vendor bootloader code looks for external flash chip and 'loadable firmware', copies it to ram and executes it.
- For PX4 the 'loadable firmware' the SPRacing SSBL is used, which enables memory mapped mode and jumps to whatever code is on the flash chip at the 'correct location'. The 'correct location' was as-defined by the PR for PX4 that added support for the SPRacingH7EXTREME - PX4/PX4-Autopilot#15385 and implemented in the SSBL code and the PX4 linker scripts.
The SSBL is here:
https://github.com/spracing/ssbl
The SSBL, when built, generates a binary image with an EXST block which contains an MD5 hash for firmware image for validation (validation only, no crypto keys involved).
The details of the EXST format are here:
https://github.com/betaflight/betaflight/blob/master/docs/EXST%20bootloader.md
The code/build steps for getting from a .elf to a .bin with EXST block is here:
linker script: https://github.com/spracing/ssbl/blob/master/src/main/link/stm32_ram_h750_exst_post.ld#L3-L28
makefile: https://github.com/spracing/ssbl/blob/master/Makefile#L434-L479
The definition of the 'correct address' is here:
https://github.com/spracing/ssbl/blob/master/src/main/main.c#L67-L68
i.e 0x90100000
.
The PX4 firmware address is influenced by the flash chip's page and block erase boundaries and the MCU's MPU granularity and the desire to reserve so space at the start of the flash chip for future use, such as partitioning information, etc.
== Key Implementation points ==
- Add SPRacingH7EXTREME target (just so it builds).
- Add support for building EXST firmware image.
- Add support for reading/writing the PX4 firmware to QSPI external flash instead of internal flash
- Add support for enabling memory mapped mode and jumping to PX4 firmware from external flash instead of internal flash.