Conversely, is it also an issue if the application core performs a program/erase operation while HSE is already performing a program/erase operation?
- Yes, it is an issue because no more flash operations can run at the same time.
If so, can this situation be prevented by checking not only bits 21:16 but also bits 29:24 of the HSE_CONFIG_GPR3 register before the application core starts the program/erase operation?
- Yes. This would help in situation when HSE is already programming the flash and application core want to also start another flash operation.
If this approach is not sufficient to prevent such conflicts, would using a critical section be the recommended solution for protecting these service requests?
- When HSE performs mentioned NVM operations (catalog format, key import…), application should not start other flash operations and should not access flash block which is being programmed by HSE. If anything like that is done by the interrupt handlers, yes, critical section would prevent this conflict.
Additionally, the tables do not explicitly describe the case where the application core is executing code from a code flash block while HSE is performing a program/erase operation on the same code flash block.
Is this scenario considered safe without any synchronization, or does it also require some form of protection?
- Code flash memory is being programmed by HSE only when HSE/SBAF installs/updates/recovers/erases HSE firmware. This is done either out of reset automatically or it is triggered by software.
HSE firmware is located it the end of code flash (in FULL_MEM version) or at the end of active and passive block (AB_SWAP version). It is expected that the application starts from lower flash blocks and it also waits until initialization is done and until HSE finishes the initialization (and possible flash operations). So, there’s no risk in this case. If application triggers an update of HSE firmware, it’s up to user to ensure that corresponding flash block is not access during this operation.
If protection is required for this scenario, what would be the recommended way to implement it?
- As described above – after reset, do not access flash block which contains HSE firmware until initialization is completed. And do not access the flash block when your software initiates HSE firmware update.