esp32s3.cfg 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. # SPDX-License-Identifier: GPL-2.0-or-later
  2. #
  3. # The ESP32-S3 only supports JTAG.
  4. transport select jtag
  5. set CPU_MAX_ADDRESS 0xFFFFFFFF
  6. source [find bitsbytes.tcl]
  7. source [find memory.tcl]
  8. source [find mmr_helpers.tcl]
  9. # Source the ESP common configuration file
  10. source [find target/esp_common.cfg]
  11. if { [info exists CHIPNAME] } {
  12. set _CHIPNAME $CHIPNAME
  13. } else {
  14. set _CHIPNAME esp32s3
  15. }
  16. if { [info exists CPUTAPID] } {
  17. set _CPUTAPID $CPUTAPID
  18. } else {
  19. set _CPUTAPID 0x120034e5
  20. }
  21. if { [info exists ESP32_S3_ONLYCPU] } {
  22. set _ONLYCPU $ESP32_S3_ONLYCPU
  23. } else {
  24. set _ONLYCPU 2
  25. }
  26. set _CPU0NAME cpu0
  27. set _CPU1NAME cpu1
  28. set _TARGETNAME_0 $_CHIPNAME.$_CPU0NAME
  29. set _TARGETNAME_1 $_CHIPNAME.$_CPU1NAME
  30. jtag newtap $_CHIPNAME $_CPU0NAME -irlen 5 -expected-id $_CPUTAPID
  31. if { $_ONLYCPU != 1 } {
  32. jtag newtap $_CHIPNAME $_CPU1NAME -irlen 5 -expected-id $_CPUTAPID
  33. } else {
  34. jtag newtap $_CHIPNAME $_CPU1NAME -irlen 5 -disable -expected-id $_CPUTAPID
  35. }
  36. proc esp32s3_memprot_is_enabled { } {
  37. # SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_0_REG
  38. if { [get_mmr_bit 0x600C10C0 0] != 0 } {
  39. return 1
  40. }
  41. # SENSITIVE_CORE_0_PIF_PMS_CONSTRAIN_0_REG
  42. if { [get_mmr_bit 0x600C1124 0] != 0 } {
  43. return 1
  44. }
  45. # SENSITIVE_CORE_1_PIF_PMS_CONSTRAIN_0_REG
  46. if { [get_mmr_bit 0x600C11D0 0] != 0 } {
  47. return 1
  48. }
  49. # IRAM0, SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_0_REG
  50. if { [get_mmr_bit 0x600C10D8 0] != 0 } {
  51. return 1
  52. }
  53. # DRAM0, SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_0_REG
  54. if { [get_mmr_bit 0x600C10FC 0] != 0 } {
  55. return 1
  56. }
  57. # SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_0_REG
  58. if { [get_mmr_bit 0x600C10E4 0] != 0 } {
  59. return 1
  60. }
  61. # SENSITIVE_CORE_1_IRAM0_PMS_MONITOR_0_REG
  62. if { [get_mmr_bit 0x600C10F0 0] != 0 } {
  63. return 1
  64. }
  65. # SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_0_REG
  66. if { [get_mmr_bit 0x600C1104 0] != 0 } {
  67. return 1
  68. }
  69. # SENSITIVE_CORE_1_DRAM0_PMS_MONITOR_0_REG
  70. if { [get_mmr_bit 0x600C1114 0] != 0 } {
  71. return 1
  72. }
  73. # SENSITIVE_CORE_0_PIF_PMS_MONITOR_0_REG
  74. if { [get_mmr_bit 0x600C119C 0] != 0 } {
  75. return 1
  76. }
  77. # SENSITIVE_CORE_1_PIF_PMS_MONITOR_0_REG
  78. if { [get_mmr_bit 0x600C1248 0] != 0 } {
  79. return 1
  80. }
  81. return 0
  82. }
  83. # PRO-CPU
  84. target create $_TARGETNAME_0 $_CHIPNAME -endian little -chain-position $_TARGETNAME_0 -coreid 0
  85. # APP-CPU
  86. if { $_ONLYCPU != 1 } {
  87. target create $_TARGETNAME_1 $_CHIPNAME -endian little -chain-position $_TARGETNAME_1 -coreid 1
  88. target smp $_TARGETNAME_0 $_TARGETNAME_1
  89. }
  90. $_TARGETNAME_0 xtensa maskisr on
  91. $_TARGETNAME_0 xtensa smpbreak BreakIn BreakOut
  92. $_TARGETNAME_0 configure -event examine-end {
  93. # Need to enable to set 'semihosting_basedir'
  94. arm semihosting enable
  95. arm semihosting_resexit enable
  96. if { [info exists _SEMIHOST_BASEDIR] } {
  97. if { $_SEMIHOST_BASEDIR != "" } {
  98. arm semihosting_basedir $_SEMIHOST_BASEDIR
  99. }
  100. }
  101. }
  102. if { $_ONLYCPU != 1 } {
  103. $_TARGETNAME_1 configure -event examine-end {
  104. # Need to enable to set 'semihosting_basedir'
  105. arm semihosting enable
  106. arm semihosting_resexit enable
  107. if { [info exists _SEMIHOST_BASEDIR] } {
  108. if { $_SEMIHOST_BASEDIR != "" } {
  109. arm semihosting_basedir $_SEMIHOST_BASEDIR
  110. }
  111. }
  112. }
  113. }
  114. $_TARGETNAME_0 configure -event gdb-attach {
  115. $_TARGETNAME_0 xtensa smpbreak BreakIn BreakOut
  116. # necessary to auto-probe flash bank when GDB is connected and generate proper memory map
  117. halt 1000
  118. if { [esp32s3_memprot_is_enabled] } {
  119. # 'reset halt' to disable memory protection and allow flasher to work correctly
  120. echo "Memory protection is enabled. Reset target to disable it..."
  121. reset halt
  122. }
  123. }
  124. $_TARGETNAME_0 configure -event reset-assert-post { soft_reset_halt }
  125. if { $_ONLYCPU != 1 } {
  126. $_TARGETNAME_1 configure -event gdb-attach {
  127. $_TARGETNAME_1 xtensa smpbreak BreakIn BreakOut
  128. # necessary to auto-probe flash bank when GDB is connected
  129. halt 1000
  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..."
  133. reset halt
  134. }
  135. }
  136. $_TARGETNAME_1 configure -event reset-assert-post { soft_reset_halt }
  137. }
  138. gdb_breakpoint_override hard
  139. source [find target/xtensa-core-esp32s3.cfg]