amdm37x.cfg 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. # SPDX-License-Identifier: GPL-2.0-or-later
  2. #
  3. # Copyright (C) 2010-2011 by Karl Kurbjun
  4. # Copyright (C) 2009-2011 by Øyvind Harboe
  5. # Copyright (C) 2009 by David Brownell
  6. # Copyright (C) 2009 by Magnus Lundin
  7. #
  8. # TI AM/DM37x Technical Reference Manual (Version R)
  9. # http://www.ti.com/lit/ug/sprugn4r/sprugn4r.pdf
  10. #
  11. # This script is based on the AM3517 initialization. It should be considered
  12. # preliminary since it needs more complete testing and only the basic
  13. # operations work.
  14. #
  15. ###############################################################################
  16. # User modifiable parameters
  17. ###############################################################################
  18. # This script uses the variable CHIPTYPE to determine whether this is an AM35x
  19. # or DM37x target. If CHIPTYPE is not set it will error out.
  20. if { [info exists CHIPTYPE] } {
  21. if { [info exists CHIPNAME] } {
  22. set _CHIPNAME $CHIPNAME
  23. } else {
  24. set _CHIPNAME $CHIPTYPE
  25. }
  26. switch $CHIPTYPE {
  27. dm37x {
  28. # Primary TAP: ICEPick-C (JTAG route controller) and boundary scan
  29. set _JRC_TAPID "-expected-id 0x2b89102f -expected-id 0x1b89102f -expected-id 0x0b89102f"
  30. }
  31. am35x {
  32. # Primary TAP: ICEPick-C (JTAG route controller) and boundary scan
  33. set _JRC_TAPID "-expected-id 0x0b7ae02f -expected-id 0x0b86802f"
  34. }
  35. default {
  36. error "ERROR: CHIPTYPE was set, but it was not set to a valid value. Acceptable values are \"dm37x\" or \"am35x\"."
  37. }
  38. }
  39. } else {
  40. error "ERROR: CHIPTYPE was not defined. Please set CHIPTYPE to \"am35x\" for the AM35x or \"dm37x\" for the DM37x series in the board configuration."
  41. }
  42. # Run the adapter at the fastest acceptable speed with the slowest possible
  43. # core clock.
  44. adapter speed 10
  45. ###############################################################################
  46. # JTAG setup
  47. # The OpenOCD commands are described in the TAP Declaration section
  48. # http://openocd.org/doc/html/TAP-Declaration.html
  49. ###############################################################################
  50. # The AM/DM37x has an ICEPick module in it like many of TI's other devices. More
  51. # can be read about this module in sprugn4r in chapter 27: "Debug and
  52. # Emulation". The module is used to route the JTAG chain to the various
  53. # subsystems in the chip.
  54. source [find target/icepick.cfg]
  55. # The TAP order should be described from the TDO connection in OpenOCD to the
  56. # TDI pin. The OpenOCD FAQ describes this in more detail:
  57. # http://openocd.org/doc/html/FAQ.html
  58. # From SPRUGN4R CH27 the available secondary TAPs are in this order from TDO:
  59. #
  60. # Device | TAP number
  61. # ---------|------------
  62. # DAP | 3
  63. # Sequencer| 2 Note: The sequencer is an ARM968
  64. # DSP | 1
  65. # D2D | 0
  66. #
  67. # Right now the only secondary tap enabled is the DAP so the rest are left
  68. # undescribed.
  69. ######
  70. # Start of Chain Description
  71. # The Secondary TAPs all have enable functions defined for use with the ICEPick
  72. # Only the DAP is enabled. The AM37xx does not have the Sequencer or DSP but
  73. # the TAP numbers for ICEPick do not change.
  74. #
  75. # TODO: A disable function should also be added.
  76. ######
  77. # Secondary TAP: DAP is closest to the TDO output
  78. # The TAP enable event also needs to be described
  79. jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -disable
  80. jtag configure $_CHIPNAME.cpu -event tap-enable \
  81. "icepick_c_tapenable $_CHIPNAME.jrc 3"
  82. # These taps are only present in the DM37x series.
  83. if { $CHIPTYPE == "dm37x" } {
  84. # Secondary TAP: Sequencer (ARM968) it is not in the chain by default
  85. # The ICEPick can be used to enable it in the chain.
  86. jtag newtap $_CHIPNAME arm2 -irlen 4 -ircapture 0x1 -irmask 0x0f -disable
  87. jtag configure $_CHIPNAME.arm2 -event tap-enable \
  88. "icepick_c_tapenable $_CHIPNAME.jrc 2"
  89. # Secondary TAP: C64x+ DSP - it is not in the chain by default (-disable)
  90. # The ICEPick can be used to enable it in the chain.
  91. jtag newtap $_CHIPNAME dsp -irlen 38 -ircapture 0x25 -irmask 0x3f -disable
  92. jtag configure $_CHIPNAME.dsp -event tap-enable \
  93. "icepick_c_tapenable $_CHIPNAME.jrc 1"
  94. }
  95. # Secondary TAP: D2D it is not in the chain by default (-disable)
  96. # The ICEPick can be used to enable it in the chain.
  97. # This IRLEN is probably incorrect - not sure where the documentation is.
  98. jtag newtap $_CHIPNAME d2d -irlen 4 -ircapture 0x1 -irmask 0x0f -disable
  99. jtag configure $_CHIPNAME.d2d -event tap-enable \
  100. "icepick_c_tapenable $_CHIPNAME.jrc 0"
  101. # Primary TAP: ICEPick - it is closest to TDI so last in the chain
  102. eval "jtag newtap $_CHIPNAME jrc -irlen 6 -ircapture 0x1 -irmask 0x3f $_JRC_TAPID"
  103. ######
  104. # End of Chain Description
  105. ######
  106. ######
  107. # Start JTAG TAP events
  108. ######
  109. # some TCK tycles are required to activate the DEBUG power domain
  110. jtag configure $_CHIPNAME.jrc -event post-reset "runtest 100"
  111. # Enable the DAP TAP
  112. jtag configure $_CHIPNAME.jrc -event setup "jtag tapenable $_CHIPNAME.dap"
  113. ######
  114. # End JTAG TAP events
  115. ######
  116. ###############################################################################
  117. # Target Setup:
  118. # This section is described in the OpenOCD documentation under CPU Configuration
  119. # http://openocd.org/doc/html/CPU-Configuration.html
  120. ###############################################################################
  121. # Create the CPU target to be used with GDB: Cortex-A8, using DAP
  122. set _TARGETNAME $_CHIPNAME.cpu
  123. dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
  124. target create $_TARGETNAME cortex_a -dap $_CHIPNAME.dap
  125. # The DM37x has 64K of SRAM starting at address 0x4020_0000. Allow the first
  126. # 16K to be used as a scratchpad for OpenOCD.
  127. $_TARGETNAME configure -work-area-phys 0x40200000 -work-area-size 0x4000
  128. ######
  129. # Start Target Reset Event Setup:
  130. ######
  131. # Set the JTAG clock down to 10 kHz to be sure that it will work with the
  132. # slowest possible core clock (16.8MHz/2 = 8.4MHz). It is OK to speed up
  133. # *after* PLL and clock tree setup.
  134. $_TARGETNAME configure -event "reset-start" { adapter speed 10 }
  135. # Describe the reset assert process for openocd - this is asserted with the
  136. # ICEPick
  137. $_TARGETNAME configure -event "reset-assert" {
  138. global _CHIPNAME
  139. # assert warm system reset through ICEPick
  140. icepick_c_wreset $_CHIPNAME.jrc
  141. }
  142. # After the reset is asserted we need to re-initialize debugging and speed up
  143. # the JTAG clock.
  144. $_TARGETNAME configure -event reset-assert-post {
  145. global _TARGETNAME
  146. amdm37x_dbginit $_TARGETNAME
  147. adapter speed 1000
  148. }
  149. $_TARGETNAME configure -event gdb-attach {
  150. global _TARGETNAME
  151. amdm37x_dbginit $_TARGETNAME
  152. echo "Halting target"
  153. halt
  154. }
  155. ######
  156. # End Target Reset Event Setup:
  157. ######
  158. ###############################################################################
  159. # Target Functions
  160. # Add any functions needed for the target here
  161. ###############################################################################
  162. # Run this to enable invasive debugging. This is run automatically in the
  163. # reset sequence.
  164. proc amdm37x_dbginit {target} {
  165. # General Cortex-A8 debug initialisation
  166. cortex_a dbginit
  167. # Enable DBGEN signal. This signal is described in the ARM v7 TRM, but
  168. # access to the signal appears to be implementation specific. TI does not
  169. # describe this register much except a quick line that states DBGEM (sic) is
  170. # at this address and this bit.
  171. $target mww phys 0x5401d030 0x00002000
  172. }