1 # SPDX-License-Identifier: GPL-2.0-or-later
3 # The ESP32-S3 only supports JTAG.
6 set CPU_MAX_ADDRESS 0xFFFFFFFF
7 source [find bitsbytes.tcl]
8 source [find memory.tcl]
9 source [find mmr_helpers.tcl]
10 # Source the ESP common configuration file
11 source [find target/esp_common.cfg]
14 if { [info exists CHIPNAME] } {
15 set _CHIPNAME $CHIPNAME
20 if { [info exists CPUTAPID] } {
21 set _CPUTAPID $CPUTAPID
23 set _CPUTAPID 0x120034e5
26 if { [info exists ESP32_S3_ONLYCPU] } {
27 set _ONLYCPU $ESP32_S3_ONLYCPU
34 set _TARGETNAME_0 $_CHIPNAME.$_CPU0NAME
35 set _TARGETNAME_1 $_CHIPNAME.$_CPU1NAME
37 jtag newtap $_CHIPNAME $_CPU0NAME -irlen 5 -expected-id $_CPUTAPID
38 if { $_ONLYCPU != 1 } {
39 jtag newtap $_CHIPNAME $_CPU1NAME -irlen 5 -expected-id $_CPUTAPID
41 jtag newtap $_CHIPNAME $_CPU1NAME -irlen 5 -disable -expected-id $_CPUTAPID
44 proc esp32s3_memprot_is_enabled { } {
45 # SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_0_REG
46 if { [get_mmr_bit 0x600C10C0 0] != 0 } {
49 # SENSITIVE_CORE_0_PIF_PMS_CONSTRAIN_0_REG
50 if { [get_mmr_bit 0x600C1124 0] != 0 } {
53 # SENSITIVE_CORE_1_PIF_PMS_CONSTRAIN_0_REG
54 if { [get_mmr_bit 0x600C11D0 0] != 0 } {
57 # IRAM0, SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_0_REG
58 if { [get_mmr_bit 0x600C10D8 0] != 0 } {
61 # DRAM0, SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_0_REG
62 if { [get_mmr_bit 0x600C10FC 0] != 0 } {
65 # SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_0_REG
66 if { [get_mmr_bit 0x600C10E4 0] != 0 } {
69 # SENSITIVE_CORE_1_IRAM0_PMS_MONITOR_0_REG
70 if { [get_mmr_bit 0x600C10F0 0] != 0 } {
73 # SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_0_REG
74 if { [get_mmr_bit 0x600C1104 0] != 0 } {
77 # SENSITIVE_CORE_1_DRAM0_PMS_MONITOR_0_REG
78 if { [get_mmr_bit 0x600C1114 0] != 0 } {
81 # SENSITIVE_CORE_0_PIF_PMS_MONITOR_0_REG
82 if { [get_mmr_bit 0x600C119C 0] != 0 } {
85 # SENSITIVE_CORE_1_PIF_PMS_MONITOR_0_REG
86 if { [get_mmr_bit 0x600C1248 0] != 0 } {
93 target create $_TARGETNAME_0 $_CHIPNAME -endian little -chain-position $_TARGETNAME_0 -coreid 0
95 if { $_ONLYCPU != 1 } {
96 target create $_TARGETNAME_1 $_CHIPNAME -endian little -chain-position $_TARGETNAME_1 -coreid 1
97 target smp $_TARGETNAME_0 $_TARGETNAME_1
100 $_TARGETNAME_0 xtensa maskisr on
101 $_TARGETNAME_0 xtensa smpbreak BreakIn BreakOut
102 $_TARGETNAME_0 configure -event examine-end {
103 # Need to enable to set 'semihosting_basedir'
104 arm semihosting enable
105 arm semihosting_resexit enable
106 if { [info exists _SEMIHOST_BASEDIR] } {
107 if { $_SEMIHOST_BASEDIR != "" } {
108 arm semihosting_basedir $_SEMIHOST_BASEDIR
113 if { $_ONLYCPU != 1 } {
114 $_TARGETNAME_1 configure -event examine-end {
115 # Need to enable to set 'semihosting_basedir'
116 arm semihosting enable
117 arm semihosting_resexit enable
118 if { [info exists _SEMIHOST_BASEDIR] } {
119 if { $_SEMIHOST_BASEDIR != "" } {
120 arm semihosting_basedir $_SEMIHOST_BASEDIR
126 $_TARGETNAME_0 configure -event gdb-attach {
127 $_TARGETNAME_0 xtensa smpbreak BreakIn BreakOut
128 # necessary to auto-probe flash bank when GDB is connected and generate proper memory map
130 if { [esp32s3_memprot_is_enabled] } {
131 # 'reset halt' to disable memory protection and allow flasher to work correctly
132 echo "Memory protection is enabled. Reset target to disable it..."
136 $_TARGETNAME_0 configure -event reset-assert-post { soft_reset_halt }
138 if { $_ONLYCPU != 1 } {
139 $_TARGETNAME_1 configure -event gdb-attach {
140 $_TARGETNAME_1 xtensa smpbreak BreakIn BreakOut
141 # necessary to auto-probe flash bank when GDB is connected
143 if { [esp32s3_memprot_is_enabled] } {
144 # 'reset halt' to disable memory protection and allow flasher to work correctly
145 echo "Memory protection is enabled. Reset target to disable it..."
149 $_TARGETNAME_1 configure -event reset-assert-post { soft_reset_halt }
152 gdb_breakpoint_override hard
154 source [find target/xtensa-core-esp32s3.cfg]