-
-$_TARGETNAME configure -event reset-start {
- # Reset clock is MSI (4 MHz)
- adapter speed 480
-}
-
-$_TARGETNAME configure -event examine-end {
- # DBGMCU_CR |= DBG_STANDBY | DBG_STOP
- mmw 0xE0044004 0x00000006 0
-
- # Stop watchdog counters during halt
- # DBGMCU_APB1_FZ |= DBG_IWDG_STOP | DBG_WWDG_STOP
- mmw 0xE0044008 0x00001800 0
-}
-
-$_TARGETNAME configure -event halted {
- set secure [is_secure]
-
- if {$secure} {
- set secure_str "Secure"
- ahb_ap_secure_access
- } else {
- set secure_str "Non-Secure"
- ahb_ap_non_secure_access
- }
-
- # print the secure state only when it changes
- set _TARGETNAME [target current]
- global $_TARGETNAME.secure
-
- if {![info exists $_TARGETNAME.secure] || $secure != [set $_TARGETNAME.secure]} {
- echo "CPU in $secure_str state"
- # update saved security state
- set $_TARGETNAME.secure $secure
- }
-}
-
-$_TARGETNAME configure -event gdb-flash-erase-start {
- set use_secure_workarea 0
- # check if FLASH_OPTR.TZEN is enabled
- set FLASH_OPTR [mrw 0x40022040]
- if {[expr {$FLASH_OPTR & 0x80000000}] == 0} {
- echo "TZEN option bit disabled"
- ahb_ap_non_secure_access
- } else {
- ahb_ap_secure_access
- echo "TZEN option bit enabled"
-
- # check if FLASH_OPTR.RDP is not Level 0.5
- if {[expr {$FLASH_OPTR & 0xFF}] != 0x55} {
- set use_secure_workarea 1
- }
- }
-
- set _TARGETNAME [target current]
- set workarea_addr [$_TARGETNAME cget -work-area-phys]
- echo "workarea_addr $workarea_addr"
-
- if {$use_secure_workarea} {
- set workarea_addr [expr {$workarea_addr | 0x10000000}]
- } else {
- set workarea_addr [expr {$workarea_addr & ~0x10000000}]
- }
-
- $_TARGETNAME configure -work-area-phys $workarea_addr
-}
-
-$_TARGETNAME configure -event trace-config {
- # Set TRACE_IOEN; TRACE_MODE is set to async; when using sync
- # change this value accordingly to configure trace pins
- # assignment
- mmw 0xE0044004 0x00000020 0
-}