2019-05-14 05:21 AM
Hi everyone,
we have a bootloader that writes new application code to the flash bank 2 in an STM32H7 and afterwards swaps the banks to execute the new code. The procedure for swapping is something like this:
unlock OPTLOCK
set SWAP_BANK_OPT
set OPTSTART
lock OPTLOCK
system reset
This works fine with a Level 0 readout protection (RDP). However it is not working with a RDP level 2.
The reference manual states that only the SWAP_BANK_OPT bit is adjustable when RDP2 is set. It also states that you have to unlock OPTLOCK before changing SWAP_BANK_OPT.
Does this mean if OPTLOCK is set (locked) when RDP2 is active you can not change SWAP_BANK_OPT since you can not modfiy OPTLOCK?
So the solution to use SWAP_BANK_OPT would be to unlock OPTLOCK before activating RDP2?
Is there any other reason that would prevent IAP when RDP2 is set?
2019-05-14 05:40 AM
RM doesn't mention any relation (that I can find) between RDP level 2 and OPTLOCK.
OPTLOCK should be unlockable in any level or RDP.
Are you sure you are following the correct procedure?
[Cick Show More]
From RM0433:
To change the SWAP_BANK bit (for example to apply a new firmware update), respect the sequence below:
The SWAP_BANK bit in FLASH_OPTCR is read-only and cannot be modified by the application software.
The SWAP_BANK_OPT option bit in FLASH_OPTSR_PRG can be modified whatever the RDP level (i.e. even in level 2), thus allowing advanced firmware upgrade in any level of readout protection.
2019-05-14 05:44 AM
Also, the errata describes an issue with bank swapping for revision Y parts. Make sure you are not affected.