traveo2_8m_psvp.cfg 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. #
  2. # Copyright (C) <2019-2021>
  3. # <Cypress Semiconductor Corporation (an Infineon company)>
  4. #
  5. # Configuration script for Cypress TRAVEO™II B-H family of microcontrollers.
  6. # TRAVEO™II B-H is a triple-core device with CM0+ and 2xCM7 cores. All cores share
  7. # the same Flash/RAM/MMIO address space.
  8. #
  9. source [find target/swj-dp.tcl]
  10. source [find mem_helper.tcl]
  11. source [find target/infineon/common/common_ifx.cfg]
  12. source [find target/infineon/cat1/func_mxs40.cfg]
  13. namespace import ifx::*
  14. namespace import mxs40::*
  15. if {[using_jtag]} {
  16. adapter speed 1000
  17. } else {
  18. adapter speed 2000
  19. }
  20. adapter srst delay 25
  21. adapter srst pulse_width 5
  22. global _CHIPNAME
  23. if { [info exists CHIPNAME] } {
  24. set _CHIPNAME $CHIPNAME
  25. } else {
  26. set _CHIPNAME traveo2_8m
  27. }
  28. set TARGET_VARIANT TVIIBH8M
  29. # (large_sector_num << 16) | small_sector_num
  30. set ${_CHIPNAME}::MAIN_FLASH_SIZE_OVERRIDE [ expr {(30 << 16) | 8} ]
  31. set ${_CHIPNAME}::WORK_FLASH_SIZE_OVERRIDE [ expr {(96 << 16) | 512} ]
  32. if { ![info exists HYPERFLASH_FLASHLOADER] } {
  33. set HYPERFLASH_FLASHLOADER {../flm/cypress/traveo2/TV2BH_8M_HyperFlash.elf}
  34. }
  35. if { ![info exists HYPERRAM_FLASHLOADER] } {
  36. set HYPERRAM_FLASHLOADER {../flm/cypress/traveo2/TV2BH_8M_HyperRAM.elf}
  37. }
  38. if { ![info exists DUALQUADSPI_FLASHLOADER] } {
  39. set DUALQUADSPI_FLASHLOADER {../flm/cypress/traveo2/TV2BH_8M_DualQuadSPI.elf}
  40. }
  41. global _ENABLE_ACQUIRE
  42. global _ENABLE_POWER_SUPPLY
  43. if { [adapter name] eq "kitprog3" } {
  44. if { [info exists ENABLE_ACQUIRE] } {
  45. set _ENABLE_ACQUIRE $ENABLE_ACQUIRE
  46. } else {
  47. if {[using_jtag]} {
  48. set _ENABLE_ACQUIRE 0
  49. echo "** Test Mode acquire disabled (not supported in JTAG mode)"
  50. } else {
  51. set _ENABLE_ACQUIRE 1
  52. }
  53. }
  54. if { [info exists ENABLE_POWER_SUPPLY] } {
  55. set _ENABLE_POWER_SUPPLY $ENABLE_POWER_SUPPLY
  56. } else {
  57. set _ENABLE_POWER_SUPPLY 0
  58. }
  59. } else {
  60. set _ENABLE_ACQUIRE 0
  61. set _ENABLE_POWER_SUPPLY 0
  62. echo "** Test Mode acquire not supported by selected adapter"
  63. }
  64. if { $_ENABLE_ACQUIRE } {
  65. echo "** Auto-acquire enabled, use \"set ENABLE_ACQUIRE 0\" to disable"
  66. kitprog3 acquire_config on 3 0 2
  67. }
  68. if { $_ENABLE_POWER_SUPPLY } {
  69. echo "** Enabling target power ($_ENABLE_POWER_SUPPLY mV) \"set ENABLE_POWER_SUPPLY 0\" to disable"
  70. kitprog3 power_config on $_ENABLE_POWER_SUPPLY
  71. }
  72. global TARGET
  73. set TARGET $_CHIPNAME.cpu
  74. swj_newdap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf
  75. dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
  76. # Set CSW[27], which according to ARM ADI v5 appendix E1.4 maps to AHB signal
  77. # HPROT[3], which according to AMBA AHB/ASB/APB specification chapter 3.7.3
  78. # makes the data access cacheable. This allows reading and writing data in the
  79. # CPU cache from the debugger, which is far more useful than going straight to
  80. # RAM when operating on typical variables, and is generally no worse when
  81. # operating on special memory locations.
  82. $_CHIPNAME.dap apsel 2
  83. $_CHIPNAME.dap apcsw [expr {(1 << 24) | (1 << 25) | (1 << 27) | (1 << 29) | (1 << 31)}]
  84. $_CHIPNAME.dap apsel 3
  85. $_CHIPNAME.dap apcsw [expr {(1 << 24) | (1 << 25) | (1 << 27) | (1 << 29) | (1 << 31)}]
  86. proc init_reset { mode } {
  87. global RESET_MODE
  88. set RESET_MODE $mode
  89. if {[using_jtag]} {
  90. jtag arp_init-reset
  91. }
  92. }
  93. #proc chip_protection {} {
  94. # set protection [ expr [mrw 0x402020C4]]
  95. # set ret "X"
  96. #
  97. # switch $protection {
  98. # 1 { set ret "VIRGIN" }
  99. # 2 { set ret "NORMAL" }
  100. # 3 { set ret "SECURE" }
  101. # 4 { set ret "DEAD" }
  102. # default { set ret "UNKNOWN" }
  103. # }
  104. #
  105. # return $ret
  106. #}
  107. proc enable_cm7x {} {
  108. mww 0x40261244 0x80000000
  109. mww 0x40261248 0x80000000
  110. mww 0x4020040C 15
  111. mww 0x4020000C 15
  112. mww 0x40201200 0x05FA0001
  113. mww 0x40201200 0x05FA0003
  114. mww 0x40201210 0x05FA0001
  115. mww 0x40201210 0x05FA0003
  116. }
  117. # Utility to make 'reset halt' work as reset;halt on a target
  118. # It does not prevent running code after reset
  119. proc reset_deassert_post { target } {
  120. global _ENABLE_ACQUIRE
  121. global RESET_MODE
  122. if { $RESET_MODE ne "run" } {
  123. if { [string match "*cm0" $target] } {
  124. if { $_ENABLE_ACQUIRE } {
  125. catch { acquire traveo2_8m.cpu.cm0 }
  126. }
  127. # catch {
  128. # echo "** SFlash SiliconID: 0x[format %08X [mrw 0x17000000]]"
  129. # echo "** Flash Boot version: 0x[format %08X [mrw 0x17002004]]"
  130. # echo "** Chip Protection: [chip_protection]"
  131. # }
  132. }
  133. # TRAVEO™II cleared AP registers including TAR during reset
  134. # Force examine to synchronize OpenOCD target status
  135. $target arp_examine
  136. $target arp_poll
  137. $target arp_poll
  138. set st [$target curstate]
  139. if { $st eq "reset" } {
  140. # we assume running state follows
  141. # if reset accidentally halts, waiting is useless
  142. catch { $target arp_waitstate running 100 }
  143. set st [$target curstate]
  144. }
  145. if { $st eq "running" } {
  146. echo "** $target: Ran after reset and before halt..."
  147. if [string match "*cm0" $target ] {
  148. if { $_ENABLE_ACQUIRE == 0 } {
  149. sleep 100
  150. traveo2 reset_halt
  151. } else {
  152. $target arp_halt
  153. }
  154. } else {
  155. $target arp_halt
  156. }
  157. $target arp_waitstate halted 100
  158. }
  159. }
  160. }
  161. proc acquire { target } {
  162. global _ENABLE_ACQUIRE
  163. if { $_ENABLE_ACQUIRE == 0 } {
  164. echo "----------------------------------------------------------------"
  165. echo "Test Mode acquire disabled. Use 'set ENABLE_ACQUIRE 1' to enable"
  166. echo "----------------------------------------------------------------"
  167. error
  168. }
  169. # acquire will leave CPU in running state
  170. # openocd does not expect this
  171. kitprog3 acquire_psoc
  172. # we need to re-examine and halt target manually
  173. ${target} arp_examine
  174. ${target} arp_poll
  175. ${target} arp_poll
  176. # Ensure target has stopped on WFI instruction
  177. set loops 200
  178. while { $loops } {
  179. set sleeping [ expr {[mrw 0xE000EDF0] & 0x00040000} ]
  180. if { $sleeping } break
  181. set loops [ expr {$loops - 1} ]
  182. sleep 10
  183. }
  184. if { $sleeping } {
  185. ${target} arp_halt
  186. ${target} arp_waitstate halted 100
  187. echo "** Device acquired successfully"
  188. return
  189. }
  190. echo "-----------------------------------------------"
  191. echo "Failed to acquire Traveo-II device in Test Mode"
  192. echo "-----------------------------------------------"
  193. error
  194. }
  195. target create ${TARGET}.cm0 cortex_m -dap $_CHIPNAME.dap -ap-num 1 -coreid 0
  196. ${TARGET}.cm0 configure -work-area-phys 0x28000800 -work-area-size 0x8000 -work-area-backup 0
  197. ${TARGET}.cm0 cortex_m reset_config sysresetreq
  198. ${TARGET}.cm0 configure -event examine-end "display_info traveo22 ${_CHIPNAME}_main0_cm0 ${_CHIPNAME}_work_cm0; enable_cm7x"
  199. ${TARGET}.cm0 configure -event reset-deassert-post "catch {reset_deassert_post ${TARGET}.cm0}; enable_cm7x"
  200. target create ${TARGET}.cm70 cortex_m -dap $_CHIPNAME.dap -ap-num 2 -coreid 1
  201. ${TARGET}.cm70 configure -work-area-phys 0x28000800 -work-area-size 0x8000 -work-area-backup 0
  202. ${TARGET}.cm70 cortex_m reset_config vectreset
  203. ${TARGET}.cm70 configure -event reset-deassert-post "catch {reset_deassert_post ${TARGET}.cm70}"
  204. target create ${TARGET}.cm71 cortex_m -dap $_CHIPNAME.dap -ap-num 3 -coreid 2
  205. ${TARGET}.cm71 configure -work-area-phys 0x28000800 -work-area-size 0x8000 -work-area-backup 0
  206. ${TARGET}.cm71 cortex_m reset_config vectreset
  207. ${TARGET}.cm71 configure -event reset-deassert-post "catch {reset_deassert_post ${TARGET}.cm71}"
  208. flash bank ${_CHIPNAME}_main0_cm0 traveo22 0x10000000 0 0 0 ${TARGET}.cm0
  209. flash bank ${_CHIPNAME}_main1_cm0 traveo22 0x10400000 [ expr {(30 << 16) | 8} ] 0 0 ${TARGET}.cm0
  210. flash bank ${_CHIPNAME}_work_cm0 traveo22 0x14000000 0 0 0 ${TARGET}.cm0
  211. flash bank ${_CHIPNAME}_super_cm0 traveo22 0x17000000 0 0 0 ${TARGET}.cm0
  212. flash bank ${_CHIPNAME}_efuse_cm0 traveo22_efuse 0x90700000 1024 1 1 ${TARGET}.cm0 external
  213. flash bank ${_CHIPNAME}_main0_cm70 virtual 0x10000000 0 0 0 ${TARGET}.cm70 ${_CHIPNAME}_main0_cm0
  214. flash bank ${_CHIPNAME}_main1_cm70 virtual 0x10400000 0 0 0 ${TARGET}.cm70 ${_CHIPNAME}_main1_cm0
  215. flash bank ${_CHIPNAME}_work_cm70 virtual 0x14000000 0 0 0 ${TARGET}.cm70 ${_CHIPNAME}_work_cm0
  216. flash bank ${_CHIPNAME}_super_cm70 virtual 0x17000000 0 0 0 ${TARGET}.cm70 ${_CHIPNAME}_super_cm0
  217. flash bank ${_CHIPNAME}_efuse_cm70 virtual 0x90700000 1024 1 1 ${TARGET}.cm70 ${_CHIPNAME}_efuse_cm0 external
  218. flash bank ${_CHIPNAME}_main0_cm71 virtual 0x10000000 0 0 0 ${TARGET}.cm71 ${_CHIPNAME}_main0_cm0
  219. flash bank ${_CHIPNAME}_main1_cm71 virtual 0x10400000 0 0 0 ${TARGET}.cm71 ${_CHIPNAME}_main1_cm0
  220. flash bank ${_CHIPNAME}_work_cm71 virtual 0x14000000 0 0 0 ${TARGET}.cm71 ${_CHIPNAME}_work_cm0
  221. flash bank ${_CHIPNAME}_super_cm71 virtual 0x17000000 0 0 0 ${TARGET}.cm71 ${_CHIPNAME}_super_cm0
  222. flash bank ${_CHIPNAME}_efuse_cm71 virtual 0x90700000 1024 1 1 ${TARGET}.cm71 ${_CHIPNAME}_efuse_cm0 external
  223. if { [info exists ENABLE_HYPERFLASH] } {
  224. set _ENABLE_HYPERFLASH $ENABLE_HYPERFLASH
  225. } else {
  226. set _ENABLE_HYPERFLASH 0
  227. }
  228. if { $_ENABLE_HYPERFLASH } {
  229. flash bank ${_CHIPNAME}_hyperflash_cm0 cmsis_flash 0x60000000 0x1000000 4 4 ${TARGET}.cm0 $HYPERFLASH_FLASHLOADER 0x1000
  230. flash bank ${_CHIPNAME}_hyperflash_cm70 virtual 0x60000000 0 0 0 ${TARGET}.cm70 ${_CHIPNAME}_hyperflash_cm0
  231. flash bank ${_CHIPNAME}_hyperflash_cm71 virtual 0x60000000 0 0 0 ${TARGET}.cm71 ${_CHIPNAME}_hyperflash_cm0
  232. }
  233. if { [info exists ENABLE_DUALQUADSPI] } {
  234. set _ENABLE_DUALQUADSPI $ENABLE_DUALQUADSPI
  235. } else {
  236. set _ENABLE_DUALQUADSPI 0
  237. }
  238. if { $_ENABLE_DUALQUADSPI } {
  239. flash bank ${_CHIPNAME}_qspi_cm0 cmsis_flash 0x60000000 0x4000000 4 4 ${TARGET}.cm0 $DUALQUADSPI_FLASHLOADER 0x1000
  240. flash bank ${_CHIPNAME}_qspi_cm70 virtual 0x60000000 0 0 0 ${TARGET}.cm70 ${_CHIPNAME}_qspi_cm0
  241. flash bank ${_CHIPNAME}_qspi_cm71 virtual 0x60000000 0 0 0 ${TARGET}.cm71 ${_CHIPNAME}_qspi_cm0
  242. }
  243. proc enable_hyperram { {xip_base 0x64000000} } {
  244. global HYPERRAM_FLASHLOADER
  245. catch {
  246. load_image $HYPERRAM_FLASHLOADER 0x28000800
  247. reg pc 0x28000800
  248. reg sp 0x28010000
  249. reg r0 $xip_base
  250. reg r1 0
  251. reg r2 3
  252. resume 0x28000800
  253. wait_halt
  254. mrw $xip_base
  255. echo "** HyperRAM mapped to address [format 0x%08X $xip_base]"
  256. }
  257. }
  258. targets ${TARGET}.cm0
  259. proc erase_all {} {
  260. lset banks [flash list]
  261. for {set i [expr {[llength $banks] - 1}]} { $i >= 0 } { set i [expr {$i - 1}]} {
  262. set bank [lindex $banks $i]
  263. if { $bank(name) != "virtual" } {
  264. flash erase_sector $i 0 last
  265. }
  266. }
  267. }