2 # Configuration script for Cypress PSoC6 family of microcontrollers (CY8C6xxx)
3 # PSoC6 is a dual-core device with CM0+ and CM4 cores. Both cores share
4 # the same Flash/RAM/MMIO address space.
7 source [find target/swj-dp.tcl]
12 if { [info exists CHIPNAME] } {
13 set _CHIPNAME $CHIPNAME
19 set TARGET $_CHIPNAME.cpu
21 swj_newdap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf
22 dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
24 # Is CM0 Debugging enabled ?
26 if { [info exists ENABLE_CM0] } {
27 set _ENABLE_CM0 $ENABLE_CM0
32 # Is CM4 Debugging enabled ?
34 if { [info exists ENABLE_CM4] } {
35 set _ENABLE_CM4 $ENABLE_CM4
40 global _WORKAREASIZE_CM0
41 if { [info exists WORKAREASIZE_CM0] } {
42 set _WORKAREASIZE_CM0 $WORKAREASIZE_CM0
44 set _WORKAREASIZE_CM0 0x4000
47 global _WORKAREASIZE_CM4
48 if { [info exists WORKAREASIZE_CM4] } {
49 set _WORKAREASIZE_CM4 $WORKAREASIZE_CM4
51 set _WORKAREASIZE_CM4 0x4000
54 global _WORKAREAADDR_CM0
55 if { [info exists WORKAREAADDR_CM0] } {
56 set _WORKAREAADDR_CM0 $WORKAREAADDR_CM0
58 set _WORKAREAADDR_CM0 0x08000000
61 global _WORKAREAADDR_CM4
62 if { [info exists WORKAREAADDR_CM4] } {
63 set _WORKAREAADDR_CM4 $WORKAREAADDR_CM4
65 set _WORKAREAADDR_CM4 0x08000000
68 proc init_reset { mode } {
77 # Utility to make 'reset halt' work as reset;halt on a target
78 # It does not prevent running code after reset
79 proc psoc6_deassert_post { target } {
80 # PSoC6 cleared AP registers including TAR during reset
81 # Force examine to synchronize OpenOCD target status
85 if { $RESET_MODE ne "run" } {
88 set st [$target curstate]
89 if { $st eq "reset" } {
90 # we assume running state follows
91 # if reset accidentally halts, waiting is useless
92 catch { $target arp_waitstate running 100 }
93 set st [$target curstate]
95 if { $st eq "running" } {
96 echo "$target: Ran after reset and before halt..."
102 if { $_ENABLE_CM0 } {
103 target create ${TARGET}.cm0 cortex_m -dap $_CHIPNAME.dap -ap-num 1 -coreid 0
104 ${TARGET}.cm0 configure -work-area-phys $_WORKAREAADDR_CM0 -work-area-size $_WORKAREASIZE_CM0 -work-area-backup 0
106 flash bank main_flash_cm0 psoc6 0x10000000 0 0 0 ${TARGET}.cm0
107 flash bank work_flash_cm0 psoc6 0x14000000 0 0 0 ${TARGET}.cm0
108 flash bank super_flash_user_cm0 psoc6 0x16000800 0 0 0 ${TARGET}.cm0
109 flash bank super_flash_nar_cm0 psoc6 0x16001A00 0 0 0 ${TARGET}.cm0
110 flash bank super_flash_key_cm0 psoc6 0x16005A00 0 0 0 ${TARGET}.cm0
111 flash bank super_flash_toc2_cm0 psoc6 0x16007C00 0 0 0 ${TARGET}.cm0
113 ${TARGET}.cm0 cortex_m reset_config sysresetreq
114 ${TARGET}.cm0 configure -event reset-deassert-post "psoc6_deassert_post ${TARGET}.cm0"
117 if { $_ENABLE_CM4 } {
118 target create ${TARGET}.cm4 cortex_m -dap $_CHIPNAME.dap -ap-num 2 -coreid 1
119 ${TARGET}.cm4 configure -work-area-phys $_WORKAREAADDR_CM4 -work-area-size $_WORKAREASIZE_CM4 -work-area-backup 0
121 flash bank main_flash_cm4 psoc6 0x10000000 0 0 0 ${TARGET}.cm4
122 flash bank work_flash_cm4 psoc6 0x14000000 0 0 0 ${TARGET}.cm4
123 flash bank super_flash_user_cm4 psoc6 0x16000800 0 0 0 ${TARGET}.cm4
124 flash bank super_flash_nar_cm4 psoc6 0x16001A00 0 0 0 ${TARGET}.cm4
125 flash bank super_flash_key_cm4 psoc6 0x16005A00 0 0 0 ${TARGET}.cm4
126 flash bank super_flash_toc2_cm4 psoc6 0x16007C00 0 0 0 ${TARGET}.cm4
128 ${TARGET}.cm4 cortex_m reset_config vectreset
129 ${TARGET}.cm4 configure -event reset-deassert-post "psoc6_deassert_post ${TARGET}.cm4"
132 if { $_ENABLE_CM0 } {
133 # Use CM0+ by default on dual-core devices
134 targets ${TARGET}.cm0