Spurious RDPERR and RDSERR when all protection and security settings are off
I have a project running on an STM32H743IIK6. The program periodically tries to write to the last page of FLASH and the HAL fails fairly often. The failure is in the start of HAL_FLASHEx_Erase where it calls FLASH_WaitForLastOperation before beginning the erase operation. The FLASH_WaitForLastOperation fails because it detects either RDSERR2, or RDPERR2 errors in SR2 even though all security and protection settings are disabled.
In order to debug I enabled the FLASH_IRQHandler and enabled interrupts on RDSERR1, RDPERR1, RDSERR2 and RDPERR2. This interrupt is firing every few minutes, and the processor was just running some instructions out of the first flash bank. The instructions are usually just some FreeRTOS task switcher code, but it can be random.
Originally we thought it was related to running the CPU at 480MHz and possibly overheating; but we dropped to 400MHz and the problem has been observed on a virgin processor within 90 seconds of running while the CPU is still quite cold.
Processor:
STM32H743IIK6 Revision V
PLL Settings:
12MHz crystal on HSE
DIVM1 = /3
DIVN1 = x200
DIVP1 = /2
SYSCLK = 400MHz
FLASH Registers at point of failure (when FLASH_IRQHandler is invoked):
ACR = 0x00000002 (Latency=2 - calculated by STM32CubeMX)
CR1 = 0x01800031 (RDSERRIE1 | RDPERRIE1)
SR1 = 0x01010000 (RDSERR1 | EOP1)
OPTSR_CUR = 0x0BC6AAFF (SECURITY=0 | RDP=0xAA=Protection Level 0 - no protection)
PRAR_CUR1 = 0x000000FF (END1=0 | START1=0xFF)
SCAR_CUR1 = 0x000000FF (END1=0 | START1=0xFF)
WPSN_CUR1R = 0x000000FF (WRPSn1=0xFF)
Many thanks,
- Malcolm