Trouble Using OpenOCD for AT91SAM7XC512

I’m stumped on how to use OpenOCD and Bus Blaster to write to my AT91SAM7XC512

The document “using open source tools for at91sam7s cross development” appears to be very outdated as many of the commands have different parameters now. Many of the command names appears to have changed as well. Many guides I found are completely useless, since many of the commands they have used no longer exist, such as “jtag_device”.

Running this in a cfg

interface ft2232
ft2232_device_desc "Dual RS232-HS"
ft2232_layout jtagkey
ft2232_vid_pid 0x0403 0x6010

jtag_khz 30000

results in

Open On-Chip Debugger 0.4.0 (2010-02-22-19:05)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.berlios.de/doc/doxygen/bugs.html
30000 kHz
Info : max TCK change to: 30000 kHz
Info : clock speed 30000 kHz
Warn : There are no enabled taps.  AUTO PROBING MIGHT NOT WORK!!
Warn : AUTO auto0.tap - use "jtag newtap auto0 tap -expected-id 0x7f1f1f1f ..."
Warn : AUTO auto0.tap - use "... -irlen 2"
Error: auto0.tap: IR capture error; saw 0x0003 not 0x0001
Info : JTAG tap: auto0.tap tap/device found: 0x7f1f1f1f (mfg: 0x78f, part: 0xf1f1, ver: 0x7)
Error: auto0.tap: IR capture error; saw 0x0003 not 0x0001
Command handler execution failed
Warn : jtag initialization failed; try 'jtag init' again.
Warn : gdb services need one or more targets defined

and if I tie JTAGSEL to enable boundary scan

Open On-Chip Debugger 0.4.0 (2010-02-22-19:05)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.berlios.de/doc/doxygen/bugs.html
30000 kHz
Info : max TCK change to: 30000 kHz
Info : clock speed 30000 kHz
Warn : There are no enabled taps.  AUTO PROBING MIGHT NOT WORK!!
Warn : AUTO auto0.tap - use "jtag newtap auto0 tap -expected-id 0x0b63207f ..."
Warn : AUTO auto0.tap - use "... -irlen 2"
Error: auto0.tap: IR capture error; saw 0x0003 not 0x0001
Info : JTAG tap: auto0.tap tap/device found: 0x0b63207f (mfg: 0x03f, part: 0xb632, ver: 0x0)
Error: auto0.tap: IR capture error; saw 0x0003 not 0x0001
Command handler execution failed
Warn : jtag initialization failed; try 'jtag init' again.
Warn : gdb services need one or more targets defined

Note, my target is powered and appears to be responding, as I am able to see its identifiers

Also notice the line “Error: auto0.tap: IR capture error; saw 0x0003 not 0x0001”

From the OpenOCD manual says “The bit pattern loaded by the TAP into the JTAG shift register on entry to the ir capture state, such as 0x01. JTAG requires the two LSBs of this value to be 01.”

So I added the line

jtag newtap at91samx512 cpu -irlen 4 -ircapture 0x1 -irmask 0x1 -expected-id 0x7f1f1f1f

or if the jumper is in

jtag newtap at91samx512 cpu -irlen 4 -ircapture 0x1 -irmask 0x1 -expected-id 0x0b63207f

and then got

Open On-Chip Debugger 0.4.0 (2010-02-22-19:05)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.berlios.de/doc/doxygen/bugs.html
30000 kHz
Warn : at91samx512.cpu: nonstandard IR mask
Info : max TCK change to: 30000 kHz
Info : clock speed 30000 kHz
Error: JTAG scan chain interrogation failed: all ones
Error: Check JTAG interface, timings, target power, etc.
Error: JTAG scan chain interrogation failed: all ones
Error: Check JTAG interface, timings, target power, etc.
Command handler execution failed
Warn : jtag initialization failed; try 'jtag init' again.
Warn : gdb services need one or more targets defined

I double checked the power, and also even tried 2000 kHz instead of 30000 kHz

Also note that I am specifying at91sam7x512 instead of at91sam7xc512 because OpenOCD told me I should (I forgot when I got an warning, but it did tell me to use x instead of xc)

it got the ID just fine at 30000 kHz, I think the speed and connections and power are all fine. I can still use SAM-BA with the TST and ERASE pins.

Can anybody help me simply write a .bin file into my AT91SAM7XC512?

Hi I just got home and got started again, I noticed something

I changed my cfg to

interface ft2232
ft2232_device_desc "Dual RS232-HS"
ft2232_layout jtagkey
ft2232_vid_pid 0x0403 0x6010

jtag_khz 2000

reset_config srst_only srst_pulls_trst

if { [info exists CHIPNAME] } {
   set  _CHIPNAME $CHIPNAME
} else {
   set  _CHIPNAME sam7x512
}

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

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

jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0x1 -expected-id $_CPUTAPID

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

$_TARGETNAME configure -event reset-init {
	# disable watchdog
	mww 0xfffffd44 0x00008000
	# enable user reset
	mww 0xfffffd08 0xa5000001
	# CKGR_MOR : enable the main oscillator
	mww 0xfffffc20 0x00000601
	sleep 10
	# CKGR_PLLR: 96.1097 MHz
	mww 0xfffffc2c 0x00481c0e
	sleep 10
	# PMC_MCKR : MCK = PLL / 2 ~= 48 MHz
	mww 0xfffffc30 0x00000007
	sleep 10
	# MC_FMR: flash mode (FWS=1,FMCN=60)
	mww 0xffffff60 0x003c0100
	sleep 100
}

$_TARGETNAME configure -work-area-phys 0x00200000 -work-area-size 0x4000 -work-area-backup 0

#flash bank <driver> <base_addr> <size> <chip_width> <bus_width> <target_number> [<target_name> <banks> <sectors_per_bank> <pages_per_sector> <page_size> <num_nvmbits> <ext_freq_khz>]
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME at91sam7 0 0 0 0 $_TARGETNAME 0 0 0 0 0 0 0 18432

and got

Open On-Chip Debugger 0.4.0 (2010-02-22-19:05)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.berlios.de/doc/doxygen/bugs.html
2000 kHz
srst_only srst_pulls_trst srst_gates_jtag srst_open_drain
Warn : sam7x512.cpu: nonstandard IR mask
Info : max TCK change to: 30000 kHz
Info : clock speed 2000 kHz
Info : JTAG tap: sam7x512.cpu tap/device found: 0x3f0f0f0f (mfg: 0x787, part: 0xf0f0, ver: 0x3)
Info : Embedded ICE version 1
Info : sam7x512.cpu: hardware has 2 breakpoint/watchpoint units

after a long time of waiting for something to happen

target state: halted
target halted in Thumb state due to breakpoint, current mode: Supervisor
cpsr: 0x600000f3 pc: 0x00003ff1

And then nothing else happens, which I guess is expected since I didn’t really tell it to do anything, correct?

Also I noticed that I need to disconnect my JTAG entirely before powering up my MCU or else I will get the error

Error: JTAG scan chain interrogation failed: all ones
Error: Check JTAG interface, timings, target power, etc.
Error: JTAG scan chain interrogation failed: all ones
Error: Check JTAG interface, timings, target power, etc.

Is there any way to re-use OpenOCD without constantly physically disconnecting-reconnecting my JTAG cable?

Also 30000 KHz does seem to cause problems, 2000 KHz works