0570501c750ec30022e91e97f803dc533fa41b7b
[fw/openocd] / tcl / target / esp32s3.cfg
1 # SPDX-License-Identifier: GPL-2.0-or-later
2 #
3 # The ESP32-S3 only supports JTAG.
4 transport select jtag
5
6 set CPU_MAX_ADDRESS 0xFFFFFFFF
7 source [find bitsbytes.tcl]
8 source [find memory.tcl]
9 source [find mmr_helpers.tcl]
10
11 if { [info exists CHIPNAME] } {
12         set _CHIPNAME $CHIPNAME
13 } else {
14         set _CHIPNAME esp32s3
15 }
16
17 if { [info exists CPUTAPID] } {
18         set _CPUTAPID $CPUTAPID
19 } else {
20         set _CPUTAPID 0x120034e5
21 }
22
23 if { [info exists ESP32_S3_ONLYCPU] } {
24         set _ONLYCPU $ESP32_S3_ONLYCPU
25 } else {
26         set _ONLYCPU 2
27 }
28
29 set _CPU0NAME cpu0
30 set _CPU1NAME cpu1
31 set _TARGETNAME_0 $_CHIPNAME.$_CPU0NAME
32 set _TARGETNAME_1 $_CHIPNAME.$_CPU1NAME
33
34 jtag newtap $_CHIPNAME $_CPU0NAME -irlen 5 -expected-id $_CPUTAPID
35 if { $_ONLYCPU != 1 } {
36         jtag newtap $_CHIPNAME $_CPU1NAME -irlen 5 -expected-id $_CPUTAPID
37 } else {
38         jtag newtap $_CHIPNAME $_CPU1NAME -irlen 5 -disable -expected-id $_CPUTAPID
39 }
40
41 proc esp32s3_memprot_is_enabled { } {
42         # TODO: after https://review.openocd.org/c/openocd/+/7016 merged
43         return 0
44 }
45
46 # PRO-CPU
47 target create $_TARGETNAME_0 $_CHIPNAME -endian little -chain-position $_TARGETNAME_0 -coreid 0
48 # APP-CPU
49 if { $_ONLYCPU != 1 } {
50         target create $_TARGETNAME_1 $_CHIPNAME -endian little -chain-position $_TARGETNAME_1 -coreid 1
51         target smp $_TARGETNAME_0 $_TARGETNAME_1
52 }
53
54 $_TARGETNAME_0 xtensa maskisr on
55 $_TARGETNAME_0 xtensa smpbreak BreakIn BreakOut
56
57 $_TARGETNAME_0 configure -event gdb-attach {
58         $_TARGETNAME_0 xtensa smpbreak BreakIn BreakOut
59         # necessary to auto-probe flash bank when GDB is connected
60         halt 1000
61         if { [esp32s3_memprot_is_enabled] } {
62                 # 'reset halt' to disable memory protection and allow flasher to work correctly
63                 echo "Memory protection is enabled. Reset target to disable it..."
64                 reset halt
65     }
66 }
67 $_TARGETNAME_0 configure -event reset-assert-post { soft_reset_halt }
68
69 if { $_ONLYCPU != 1 } {
70         $_TARGETNAME_1 configure -event gdb-attach {
71                 $_TARGETNAME_1 xtensa smpbreak BreakIn BreakOut
72                 # necessary to auto-probe flash bank when GDB is connected
73                 halt 1000
74                 if { [esp32s3_memprot_is_enabled] } {
75                         # 'reset halt' to disable memory protection and allow flasher to work correctly
76                         echo "Memory protection is enabled. Reset target to disable it..."
77                         reset halt
78                 }
79         }
80         $_TARGETNAME_1 configure -event reset-assert-post { soft_reset_halt }
81 }
82
83 gdb_breakpoint_override hard