flash/stm32l4x: fix auto-probe when RDP is promoted from 0 to 0.5
authorTarek BOCHKATI <tarek.bouchkati@gmail.com>
Mon, 28 Feb 2022 12:55:26 +0000 (13:55 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 19 Mar 2022 09:13:55 +0000 (09:13 +0000)
commitab43721be6ff7470ff8b9771c95c1d5661a5a689
tree0a719e9d31fb384b2103fbb4add9bdf94933c181
parent9cdbe61aab418bdf75bc443b16ce4cdf96732e3e
flash/stm32l4x: fix auto-probe when RDP is promoted from 0 to 0.5

Considering this use case: (using STM32 L5 or U5)
 1- first probe : TZEN enabled, RDP level 0
    flash_regs_base |= STM32L5_REGS_SEC_OFFSET => 0x50022000
 2- the user promotes the RDP to level 0.5
 3- the second probe, fails to read OPTR using secure flags_regs_base:
    used OPTR address is 0x50022040

Step 3 fails because when RDP is level 0.5, we should use Non-Secure
flash registers.
To fix this, always use NS flash regs to read OPTR in probe functions.

Fixes: 80d323c6e82b (flash/stm32l4x: introduce auto-probe when OPTR is changed)
Change-Id: I296aa633972b0c410b927488c999584a07b912d3
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6864
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
src/flash/nor/stm32l4x.c