SparkFun Forums 

Where electronics enthusiasts find answers.

Open source ARM Debugger
By tomkcook
#193976
I'm completely new to JTAG and OpenOCD, so sorry if this is a stupid question. Can someone point me towards a suitable OpenOCD configuration for the ATSAM3X8E?

I've got a prototype board we're building with a SAM3X (the ATSAM3X8EA-AU, to be exact) on it, with JTAG pins broken out to a header. I've connected the JTAG pins to a Raspberry Pi as described at https://github.com/synthetos/PiOCD/wiki ... TAG-Dongle. I'm running OpenOCD as:
Code: Select all
sudo openocd -s /usr/local/share/openocd -f raspberrypi-due.tcl
and raspberrypi-due.tcl contains this:
Code: Select all
source [find interface/raspberrypi2-native.cfg]
set _CHIPNAME sam3

source [find target/at91sam3ax_8x.cfg]
$_TARGETNAME configure -event gdb-attach {reset init }
After some initial confusion over the difference between pin numbers and GPIO numbers, now when I try to run OpenOCD, I get this:
Code: Select all
Open On-Chip Debugger 0.10.0+dev-00093-g6b2acc0 (2017-03-17-16:47)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
BCM2835 GPIO config: tck = 11, tms = 25, tdi = 10, tdo = 9
BCM2835 GPIO nums: swclk = 25, swdio = 24
BCM2835 GPIO config: trst = 7
trst_only separate trst_push_pull
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
adapter speed: 500 kHz
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
cortex_m reset_config sysresetreq
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : JTAG and SWD modes enabled
Info : clock speed 500 kHz
Info : JTAG tap: sam3.cpu tap/device found: 0x05b2b03f (mfg: 0x01f (Atmel), part: 0x5b2b, ver: 0x0)
Warn : JTAG tap: sam3.cpu       UNEXPECTED: 0x05b2b03f (mfg: 0x01f (Atmel), part: 0x5b2b, ver: 0x0)
Error: JTAG tap: sam3.cpu  expected 1 of 1: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
Error: Trying to use configured scan chain anyway...
Error: sam3.cpu: IR capture error; saw 0x09 not 0x01
Warn : Bypassing JTAG setup events due to errors
Error: Invalid ACK (7) in DAP response
Error: JTAG-DP STICKY ERROR
Error: Invalid ACK (7) in DAP response
Error: JTAG-DP STICKY ERROR
and this last error is repeated at some length. It seems that the chip is reporting a different identifier to what OpenOCD expects for this part.

Can someone point me to towards a suitable configuration for this part, please?
By tomkcook
#193984
Note I've got some of these issues sorted by mucking with the target configuration file. I'm now using this:
Code: Select all
if { [info exists CHIPNAME] } {
   set _CHIPNAME $CHIPNAME
} else {
   set _CHIPNAME sam3
}

if { [info exists ENDIAN] } {
   set _ENDIAN $ENDIAN
} else {
   set _ENDIAN little
}

if { [info exists WORKAREASIZE] } {
   set _WORKAREASIZE $WORKAREASIZE
} else {
   set _WORKAREASIZE 0x4000
}

if { [info exists CPUTAPID] } {
   set _CPUTAPID $CPUTAPID
} else {
   set _CPUTAPID 0x05b2b03f
}

jtag newtap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID

set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME cortex_m -endian $_ENDIAN -chain-position $_TARGETNAME

$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0

$_TARGETNAME configure -event gdb-flash-erase-start {
    halt
}

adapter_khz 500
adapter_nsrst_delay 100
if {[using_jtag]} {
   jtag_ntrst_delay 100
}

if {![using_hla]} {
   # if srst is not fitted use SYSRESETREQ to
   # perform a soft reset
   cortex_m reset_config sysresetreq
}
It now recognises the chip okay (and I've checked that the TAPID matches what's given in section 11.5.8 of the SAM3X datasheet). But I still get:
Code: Select all
Open On-Chip Debugger 0.10.0+dev-00093-g6b2acc0 (2017-03-17-16:47)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
BCM2835 GPIO config: tck = 11, tms = 25, tdi = 10, tdo = 9
BCM2835 GPIO config: srst = 7
srst_only separate srst_gates_jtag srst_push_pull connect_deassert_srst
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
adapter speed: 500 kHz
RCLK - adaptive
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
cortex_m reset_config sysresetreq
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : JTAG only mode enabled (specify swclk and swdio gpio to add SWD mode)
Info : RCLK (adaptive clock speed) not supported - fallback to 10 kHz
Info : JTAG tap: sam3.cpu tap/device found: 0x05b2b03f (mfg: 0x01f (Atmel), part: 0x5b2b, ver: 0x0)
Error: Invalid ACK (7) in DAP response
Error: JTAG-DP STICKY ERROR
Error: Invalid ACK (7) in DAP response
Error: JTAG-DP STICKY ERROR
...repeated about 40 times...
Error: Could not initialize the debug port