EmbeddedRelated.com
Forums

Using ARM JTAG Instructions in Debug Mode to Read and Write Memory

Started by Neil Jacobson October 1, 2009
Hello Folks,

I am writing what I thought to be a simple application to read and
write memory using the ARM JTAG Scan Chain instructions.  What I am
finding is that I can read and write registers without issue but whan
I try to use system speed instructions (as required) to do the memory
accesses - all hell breaks loose.

My sequences are simple enough

IR SCAN_N
DR x10 (scan chain 1)
IR INTEST
DR MOV R8 #0 sysspeed = 0
go to RTI for 1 TCK
DR LDR R0 [R8] sysspeed = 0
go to RTI for 1 TCK
DR MOV R0 R0 sysspeed = 0 (NOP)
go to RTI for 2 TCK
DR <address value to load in R0>
go to RTI for 2 TCK

So now I have a read address in R0
I have been able to use STR R0 [R8] in a sequence similar to the above
to read it out and verify
that I loaded the value

Now I want to read the address pointed to by R0
This is where the lights go out (as it were)

IR SCAN_N
DR x10
IR INTEST
DR MOV R0, R0 sysspeed = 0
go to RTI for 1 TCK
DR MOV R0, R0 sysspeed = 1
go to RTI for 1 TCK
LDR R1,[R0]  sysspeed = 0
go to RTI for 1 TCK
IR RESTART
go to RTI for 1 TCK pulse

So now R1 should have the contents of the address that was in R0
Let's shift it out

IR SCAN_N
DR x10
IR INTEST
DR MOV R8 #0 sysspeed = 0
go to RTI for 1 TCK
DR STR R1 [R8] sysspeed = 0
go to RTI for 1 TCK
DR MOV R0 R0 sysspeed = 0 (NOP)
go to RTI for 2 TCK
DR <shift out contents of R1>
go to RTI for 1 TCK

It doesn't work!  I get random stuff or zeroes.  Obviously I'm doing
something wrong
The TCK I have is pretty slow (330KHz).  If I insert a debug status
register check (on scan chain 2) after the
RESTART and associated IDLE I see that DBGACK does not appear to come
high but mREQ does.
Why would that be?  Is that a slow TCK issue?  If it is - is there a
workaround for that?

I do notice that the sysspeed bit is set on the outbound (TDO) bits
as I shift in that first MOV R8 #0 instruction after the RESTART.  I
should also note that when I say go to RTI, in my algorithm above.

Thanks for any help you can provide in revealing the error of my
ways.  And please, buying or downloading a solution is not an option -
I need to know the correct algorithm.

Thanks again