2 # Copyright (C) 2010-2011 by Karl Kurbjun
3 # Copyright (C) 2009-2011 by Øyvind Harboe
4 # Copyright (C) 2009 by David Brownell
5 # Copyright (C) 2009 by Magnus Lundin
8 # http://www.ti.com/litv/pdf/sprugn4b
10 # This script is based on the AM3517 initialization. It should be considered
11 # preliminary since it needs more complete testing and only the basic
15 ###############################################################################
16 # User modifiable parameters
17 ###############################################################################
19 # This script uses the variable CHIPTYPE to determine whether this is an AM35x
20 # or DM37x target. If CHIPTYPE is not set it will error out.
21 if { [info exists CHIPTYPE] } {
23 if { [info exists CHIPNAME] } {
24 set _CHIPNAME $CHIPNAME
26 set _CHIPNAME $CHIPTYPE
31 # Primary TAP: ICEpick-C (JTAG route controller) and boundary scan
32 set _JRC_TAPID "-expected-id 0x2b89102f -expected-id 0x1b89102f -expected-id 0x0b89102f"
35 # Primary TAP: ICEpick-C (JTAG route controller) and boundary scan
36 set _JRC_TAPID "-expected-id 0x0b7ae02f"
39 error "ERROR: CHIPTYPE was set, but it was not set to a valid value. Acceptable values are \"dm37x\" or \"am35x\"."
43 error "ERROR: CHIPTYPE was not defined. Please set CHIPTYPE to \"am35x\" for the AM35x or \"dm37x\" for the DM37x series in the board configuration."
46 # Run the adapter at the fastest acceptable speed with the slowest possible
50 ###############################################################################
52 # The OpenOCD commands are described in the TAP Declaration section
53 # http://openocd.berlios.de/doc/html/TAP-Declaration.html
54 ###############################################################################
56 # The AM/DM37x has an ICEpick module in it like many of TI's other devices. More
57 # can be read about this module in sprugn4b under chapter 27: "Debug and
58 # Emulation". The module is used to route the JTAG chain to the various
59 # subsystems in the chip.
60 source [find target/icepick.cfg]
62 # The TAP order should be described from the TDO connection in OpenOCD to the
63 # TDI pin. The OpenOCD FAQ describes this in more detail:
64 # http://openocd.berlios.de/doc/html/FAQ.html
66 # From SPRUGN4B CH27 the available secondary TAPs are in this order from TDO:
69 # ---------|------------
71 # Sequencer| 2 Note: The sequencer is an ARM968
75 # Right now the only secondary tap enabled is the DAP so the rest are left
79 # Start of Chain Description
80 # The Secondary TAPs all have enable functions defined for use with the ICEpick
81 # Only the DAP is enabled. The AM37xx does not have the Sequencer or DSP but
82 # the TAP numbers for ICEpick do not change.
84 # TODO: A disable function should also be added.
87 # Secondary TAP: DAP is closest to the TDO output
88 # The TAP enable event also needs to be described
89 jtag newtap $_CHIPNAME dap -irlen 4 -ircapture 0x1 -irmask 0xf -disable
90 jtag configure $_CHIPNAME.dap -event tap-enable \
91 "icepick_c_tapenable $_CHIPNAME.jrc 3"
93 # These taps are only present in the DM37x series.
94 if { $CHIPTYPE == "dm37x" } {
95 # Secondary TAP: Sequencer (ARM968) it is not in the chain by default
96 # The ICEpick can be used to enable it in the chain.
97 jtag newtap $_CHIPNAME arm2 -irlen 4 -ircapture 0x1 -irmask 0x0f -disable
98 jtag configure $_CHIPNAME.arm2 -event tap-enable \
99 "icepick_c_tapenable $_CHIPNAME.jrc 2"
101 # Secondary TAP: C64x+ DSP - it is not in the chain by default (-disable)
102 # The ICEpick can be used to enable it in the chain.
103 jtag newtap $_CHIPNAME dsp -irlen 38 -ircapture 0x25 -irmask 0x3f -disable
104 jtag configure $_CHIPNAME.dsp -event tap-enable \
105 "icepick_c_tapenable $_CHIPNAME.jrc 1"
108 # Secondary TAP: D2D it is not in the chain by default (-disable)
109 # The ICEpick can be used to enable it in the chain.
110 # This IRLEN is probably incorrect - not sure where the documentation is.
111 jtag newtap $_CHIPNAME d2d -irlen 4 -ircapture 0x1 -irmask 0x0f -disable
112 jtag configure $_CHIPNAME.d2d -event tap-enable \
113 "icepick_c_tapenable $_CHIPNAME.jrc 0"
115 # Primary TAP: ICEpick - it is closest to TDI so last in the chain
116 eval "jtag newtap $_CHIPNAME jrc -irlen 6 -ircapture 0x1 -irmask 0x3f $_JRC_TAPID"
119 # End of Chain Description
123 # Start JTAG TAP events
126 # some TCK tycles are required to activate the DEBUG power domain
127 jtag configure $_CHIPNAME.jrc -event post-reset "runtest 100"
130 jtag configure $_CHIPNAME.jrc -event setup "jtag tapenable $_CHIPNAME.dap"
133 # End JTAG TAP events
136 ###############################################################################
138 # This section is described in the OpenOCD documentation under CPU Configuration
139 # http://openocd.berlios.de/doc/html/CPU-Configuration.html
140 ###############################################################################
142 # Create the CPU target to be used with GDB: Cortex-A8, using DAP
143 set _TARGETNAME $_CHIPNAME.cpu
144 target create $_TARGETNAME cortex_a8 -chain-position $_CHIPNAME.dap
146 # The DM37x has 64K of SRAM starting at address 0x4020_0000. Allow the first
147 # 16K to be used as a scratchpad for OpenOCD.
149 $_TARGETNAME configure -work-area-phys 0x40200000 -work-area-size 0x4000
152 # Start Target Reset Event Setup:
155 # Set the JTAG clock down to 10 kHz to be sure that it will work with the
156 # slowest possible core clock (16.8MHz/2 = 8.4MHz). It is OK to speed up
157 # *after* PLL and clock tree setup.
159 $_TARGETNAME configure -event "reset-start" { adapter_khz 10 }
161 # Describe the reset assert process for openocd - this is asserted with the
163 $_TARGETNAME configure -event "reset-assert" {
167 # assert warm system reset through ICEPick
168 icepick_c_wreset $_CHIPNAME.jrc
171 # After the reset is asserted we need to re-initialize debugging and speed up
174 $_TARGETNAME configure -event reset-assert-post {
177 amdm37x_dbginit $_TARGETNAME
181 $_TARGETNAME configure -event gdb-attach {
184 amdm37x_dbginit $_TARGETNAME
186 echo "Halting target"
191 # End Target Reset Event Setup:
194 ###############################################################################
196 # Add any functions needed for the target here
197 ###############################################################################
199 # Run this to enable invasive debugging. This is run automatically in the
201 proc amdm37x_dbginit {target} {
202 # General Cortex A8 debug initialisation
205 # Enable DBGEN signal. This signal is described in the ARM v7 TRM, but
206 # access to the signal appears to be implementation specific. TI does not
207 # describe this register much except a quick line that states DBGEM (sic) is
208 # at this address and this bit.
209 $target mww phys 0x5401d030 0x00002000