STM32H562RGT6 - Non-secure Bank 2 sectors cannot be erased individually when TrustZone is enabled
- September 25, 2026
- 0 replies
- 5 views
Hello,
I am using an STM32H562RGT6 (1 MB Flash) on a custom board.
When TrustZone is enabled, the non-secure area of Bank 2 can be programmed successfully, but it cannot be erased sector by sector. The erase operation only works when performing a full mass erase. If I attempt to erase individual sectors, the operation appears to complete without error, but the flash contents remain programmed.
My development environment is:
- STM32CubeIDE 2.2.0
- STM32CubeMX 6.18.1
- STM32CubeProgrammer 2.23.0
I have attached the current Option Bytes configuration.
This issue becomes particularly significant during debugging, when updating the non-secure firmware. Since the old contents are not actually erased, the programming operation results in a verify mismatch.
I have also noticed some inconsistencies in the flash memory configuration:
When enabling TrustZone (TZEN = 0xB4):
SECWM1_PENDis automatically set to0x7F, covering flash up to address0x080FE000.SECWM2_PSTRT = 0x00andSECWM2_PEND = 0x7F, covering flash from0x08080000to0x0817E000.
This configuration appears to assume a larger flash memory size and does not seem consistent with a device featuring only 1 MB of Flash.
As an additional test, I used STM32CubeProgrammer 2.15.0, which incorrectly identifies the device as Device ID 0x484 with 2 MB Flash. Without changing the Option Bytes configuration, I requested the erase of sector 128 (address 0x08100000). Surprisingly, this operation correctly erased the sector located at 0x08080000.
Based on these observations, I am wondering whether:
- I am missing a required TrustZone or flash configuration setting.
- There is a known issue in the flash sector mapping for 1 MB STM32H562 devices.
- A software patch is required to ensure correct and consistent behavior according to the actual flash size of the device.
Could you please clarify whether this behavior is expected and advise on the correct configuration or workaround?
Thank you for your support.
Best regards,
Riccardo Angeli
