We are adding an OTA procedure to our firmware that depends on a small loader at the start of flash which is responsible for programming the main application written to program flash at a higher address. The procedure works fine as it is, except that we are not finding it possible to use the Fast Programming feature.
According to the RM, before FSTPG programming can be used, the device must be mass erased. Yet, CPU1 is not permitted to perform this operation. We suspect that it may be possible to execute a mass erase from the C2 coprocessor, which could be acceptable, however, we don't want to lose the loader. The WRP bits in the option bytes would protect the loader...except that the documentation explains that setting WRP precludes any mass erase.
So, our question is this. Is there a way we can use FastProgramming from the user application code to improve the speed of programming our firmware?
FWIW, we checked the Cube sources and this code is doing the same thing we are. When we initiate the programming sequence, the MCU returns error code bits for FPRGERR, PGSERR and PGAERR.
> Is there a way we can use FastProgramming from the user application code to improve the speed of programming our firmware?
Without losing your loader in flash, no.
However, it would be possible to store your OTA code in RAM and execute from that. With it comes the risk of losing loader functionality on the device if the power gets interrupted during the update.
Generally, waiting a few extra seconds for flashing to complete is a relatively minor inconvenience. Erasing is typically the bulk of the time.