stm32mp15x.cfg 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. # SPDX-License-Identifier: GPL-2.0-or-later
  2. # STMicroelectronics STM32MP15x (Single/Dual Cortex-A7 plus Cortex-M4)
  3. # http://www.st.com/stm32mp1
  4. # HLA does not support multi-cores nor custom CSW nor AP other than 0
  5. if { [using_hla] } {
  6. echo "ERROR: HLA transport cannot work with this target."
  7. echo "ERROR: To use STLink switch to DAP mode, as in \"board/stm32mp15x_dk2.cfg\"."
  8. shutdown
  9. }
  10. source [find target/swj-dp.tcl]
  11. if { [info exists CHIPNAME] } {
  12. set _CHIPNAME $CHIPNAME
  13. } else {
  14. set _CHIPNAME stm32mp15x
  15. }
  16. if { [info exists CPUTAPID] } {
  17. set _CPUTAPID $CPUTAPID
  18. } else {
  19. if { [using_jtag] } {
  20. set _CPUTAPID 0x6ba00477
  21. } else {
  22. set _CPUTAPID 0x6ba02477
  23. }
  24. }
  25. # Chip Level TAP Controller, only in jtag mode
  26. if { [info exists CLCTAPID] } {
  27. set _CLCTAPID $CLCTAPID
  28. } else {
  29. set _CLCTAPID 0x06500041
  30. }
  31. swj_newdap $_CHIPNAME tap -expected-id $_CPUTAPID -irlen 4
  32. if { [using_jtag] } {
  33. jtag newtap $_CHIPNAME.clc tap -expected-id $_CLCTAPID -irlen 5
  34. }
  35. dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.tap -ignore-syspwrupack
  36. # FIXME: Cortex-M code requires target accessible during reset, but this is not possible in STM32MP1
  37. # so defer-examine it until the reset framework get merged
  38. # NOTE: keep ap-num and dbgbase to speed-up examine after reset
  39. # NOTE: do not change the order of target create
  40. target create $_CHIPNAME.ap1 mem_ap -dap $_CHIPNAME.dap -ap-num 1
  41. target create $_CHIPNAME.ap2 mem_ap -dap $_CHIPNAME.dap -ap-num 2
  42. target create $_CHIPNAME.axi mem_ap -dap $_CHIPNAME.dap -ap-num 0
  43. target create $_CHIPNAME.cpu0 cortex_a -dap $_CHIPNAME.dap -ap-num 1 -coreid 0 -dbgbase 0xE00D0000
  44. target create $_CHIPNAME.cpu1 cortex_a -dap $_CHIPNAME.dap -ap-num 1 -coreid 1 -dbgbase 0xE00D2000
  45. target create $_CHIPNAME.cm4 cortex_m -dap $_CHIPNAME.dap -ap-num 2 -defer-examine
  46. targets $_CHIPNAME.cpu0
  47. target smp $_CHIPNAME.cpu0 $_CHIPNAME.cpu1
  48. $_CHIPNAME.cpu0 cortex_a maskisr on
  49. $_CHIPNAME.cpu1 cortex_a maskisr on
  50. $_CHIPNAME.cpu0 cortex_a dacrfixup on
  51. $_CHIPNAME.cpu1 cortex_a dacrfixup on
  52. cti create $_CHIPNAME.cti.sys -dap $_CHIPNAME.dap -ap-num 1 -baseaddr 0xE0094000
  53. cti create $_CHIPNAME.cti.cpu0 -dap $_CHIPNAME.dap -ap-num 1 -baseaddr 0xE00D8000
  54. cti create $_CHIPNAME.cti.cpu1 -dap $_CHIPNAME.dap -ap-num 1 -baseaddr 0xE00D9000
  55. cti create $_CHIPNAME.cti.cm4 -dap $_CHIPNAME.dap -ap-num 2 -baseaddr 0xE0043000
  56. swo create $_CHIPNAME.swo -dap $_CHIPNAME.dap -ap-num 1 -baseaddr 0xE0083000
  57. tpiu create $_CHIPNAME.tpiu -dap $_CHIPNAME.dap -ap-num 1 -baseaddr 0xE0093000
  58. # interface does not work while srst is asserted
  59. # this is target specific, valid for every board
  60. # Errata "2.3.5 Incorrect reset of glitch-free kernel clock switch" requires
  61. # srst to force VDDCORE power cycle or pull srst_core. Both cases reset the
  62. # debug unit, behavior equivalent to "srst_pulls_trst"
  63. reset_config srst_gates_jtag srst_pulls_trst
  64. adapter speed 5000
  65. adapter srst pulse_width 200
  66. # bootrom has an internal timeout of 1 second for detecting the boot flash.
  67. # wait at least 1 second to guarantee we are out of bootrom
  68. adapter srst delay 1100
  69. add_help_text axi_secure "Set secure mode for following AXI accesses"
  70. proc axi_secure {} {
  71. $::_CHIPNAME.dap apsel 0
  72. $::_CHIPNAME.dap apcsw 0x10006000
  73. }
  74. add_help_text axi_nsecure "Set non-secure mode for following AXI accesses"
  75. proc axi_nsecure {} {
  76. $::_CHIPNAME.dap apsel 0
  77. $::_CHIPNAME.dap apcsw 0x30006000
  78. }
  79. axi_secure
  80. proc dbgmcu_enable_debug {} {
  81. # set debug enable bits in DBGMCU_CR to get ap2 and cm4 visible
  82. catch {$::_CHIPNAME.ap1 mww 0xe0081004 0x00000007}
  83. # freeze watchdog 1 and 2 on cores halted
  84. catch {$::_CHIPNAME.ap1 mww 0xe008102c 0x00000004}
  85. catch {$::_CHIPNAME.ap1 mww 0xe008104c 0x00000008}
  86. }
  87. proc toggle_cpu0_dbg_claim0 {} {
  88. # toggle CPU0 DBG_CLAIM[0]
  89. $::_CHIPNAME.ap1 mww 0xe00d0fa0 1
  90. $::_CHIPNAME.ap1 mww 0xe00d0fa4 1
  91. }
  92. proc detect_cpu1 {} {
  93. set cpu1_prsr [$::_CHIPNAME.ap1 read_memory 0xE00D2314 32 1]
  94. set dual_core [expr {$cpu1_prsr & 1}]
  95. if {! $dual_core} {$::_CHIPNAME.cpu1 configure -defer-examine}
  96. }
  97. proc rcc_enable_traceclk {} {
  98. $::_CHIPNAME.ap2 mww 0x5000080c 0x301
  99. }
  100. # FIXME: most of handler below will be removed once reset framework get merged
  101. $_CHIPNAME.ap1 configure -event reset-deassert-pre {adapter deassert srst deassert trst;catch {dap init};catch {$::_CHIPNAME.dap apid 1}}
  102. $_CHIPNAME.ap2 configure -event reset-deassert-pre {dbgmcu_enable_debug;rcc_enable_traceclk}
  103. $_CHIPNAME.cpu0 configure -event reset-deassert-pre {$::_CHIPNAME.cpu0 arp_examine}
  104. $_CHIPNAME.cpu1 configure -event reset-deassert-pre {$::_CHIPNAME.cpu1 arp_examine allow-defer}
  105. $_CHIPNAME.cpu0 configure -event reset-deassert-post {toggle_cpu0_dbg_claim0}
  106. $_CHIPNAME.cm4 configure -event reset-deassert-post {$::_CHIPNAME.cm4 arp_examine;if {[$::_CHIPNAME.ap2 curstate] == "halted"} {$::_CHIPNAME.cm4 arp_poll;$::_CHIPNAME.cm4 arp_poll;$::_CHIPNAME.cm4 arp_halt}}
  107. $_CHIPNAME.ap1 configure -event examine-start {dap init}
  108. $_CHIPNAME.ap2 configure -event examine-start {dbgmcu_enable_debug}
  109. $_CHIPNAME.cpu0 configure -event examine-end {detect_cpu1}
  110. $_CHIPNAME.ap2 configure -event examine-end {rcc_enable_traceclk;$::_CHIPNAME.cm4 arp_examine}