flash/stm32l4x: STM32L5 support programming when TZEN=1 and RDP=0x55
[fw/openocd] / tcl / target / stm32l5x.cfg
index 02297e36996fed5d0f7dd262874ff5b871d87886..0616df1cbabe7808f11483a4867be28f18ea1a8d 100644 (file)
@@ -173,7 +173,11 @@ $_TARGETNAME configure -event gdb-flash-erase-start {
        } {
                ahb_ap_secure_access
                echo "TZEN option bit enabled"
-               set use_secure_workarea 1
+
+               # check if FLASH_OPTR.RDP is not Level 0.5
+               if {[expr {$FLASH_OPTR & 0xFF}] != 0x55} {
+                       set use_secure_workarea 1
+               }
        }
 
        set workarea_addr [$_TARGETNAME cget -work-area-phys]