Openocd + Amontec JtagKey + STR9

Hi, I’m trying to program an STR9 with Amontec JtagKey, but I get this error:

Open On-Chip Debugger 0.1.0 (2009-02-27-15:31) Release


BUGS? Read http://svn.berlios.de/svnroot/repos/openocd/trunk/BUGS


$URL: https://kc8apf@svn.berlios.de/svnroot/repos/openocd/tags/openocd-0.1.0/src/openocd.c $
RCLK - adaptive
Error: RCLK not supported
Info : JTAG tap: str912.flash tap/device found: 0x04570041 (Manufacturer: 0x020, Part: 0x4570, Version: 0x0)
Info : JTAG Tap/device matched
Info : JTAG tap: str912.cpu tap/device found: 0xffffffff (Manufacturer: 0x7ff, Part: 0xffff, Version: 0xf)
Error: JTAG tap: str912.cpu             got: 0xffffffff (mfg: 0x7ff, part: 0xffff, ver: 0xf)
Error: JTAG tap: str912.cpu expected 1 of 1: 0x25966041 (mfg: 0x020, part: 0x5966, ver: 0x2)
Error: trying to validate configured JTAG chain anyway...
Error: Could not validate JTAG scan chain, IR mismatch, scan returned 0x000029. tap=str912.cpu pos=8 expected 0x1 got 0
Warn : Could not validate JTAG chain, continuing anyway...
Warn : TAP str912.cpu:
Warn : value captured during scan didn't pass the requested check:
Warn : captured: 0x00 check_value: 0x01 check_mask: 0x0f
Warn : in_handler: w/o "in_value", mismatch in SIR
Warn : TAP str912.cpu:
Warn : value captured during scan didn't pass the requested check:
Warn : captured: 0x03 check_value: 0x01 check_mask: 0x0f
Warn : in_handler: w/o "in_value", mismatch in SIR

I have to run my config file with root permission otherwise openocd can’t recognize the device. My config file is

#daemon configuration

telnet_port 4444
tcl_port 6666

gdb_port 3333



# GDB can also flash my flash!
gdb_memory_map enable
gdb_flash_program enable

#interface
interface ft2232
ft2232_device_desc "Amontec JTAGkey A"
ft2232_layout jtagkey
ft2232_vid_pid 0x0403 0xcff8

# script for str9

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

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

# jtag speed. We need to stick to 16kHz until we've finished reset.
jtag_rclk 16

jtag_nsrst_delay 100
jtag_ntrst_delay 100

#use combined on interfaces or targets that can't set TRST/SRST separately
reset_config trst_and_srst

if { [info exists FLASHTAPID ] } {
   set _FLASHTAPID $FLASHTAPID
} else {
   set _FLASHTAPID 0x04570041
}
jtag newtap $_CHIPNAME flash -irlen 8 -ircapture 0x1 -irmask 0x1 -expected-id $_FLASHTAPID

if { [info exists CPUTAPID ] } {
   set _CPUTAPID $CPUTAPID
} else {
   set _CPUTAPID 0x25966041
}
jtag newtap $_CHIPNAME cpu   -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID


if { [info exists BSTAPID ] } {
   set _BSTAPID $BSTAPID
} else {
   set _BSTAPID 0x1457f041
}
jtag newtap $_CHIPNAME bs    -irlen 5 -ircapture 0x1 -irmask 0x1 -expected-id $_BSTAPID

set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
target create $_TARGETNAME arm966e -endian $_ENDIAN -chain-position $_TARGETNAME -variant arm966e

$_TARGETNAME configure -event reset-start { jtag_rclk 16 }

$_TARGETNAME configure -event reset-init {
	# We can increase speed now that we know the target is halted.
	#jtag_rclk 3000
	
	# -- Enable 96K RAM
	# PFQBC enabled / DTCM & AHB wait-states disabled
	mww 0x5C002034 0x0191 

	str9x flash_config 0 4 2 0 0x80000
	flash protect 0 0 7 off
}

$_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x50000000 -work-area-size 16384 -work-area-backup 0

#flash bank str9x <base> <size> 0 0 <target#> <variant>
flash bank str9x 0x00000000 0x00080000 0 0 0
flash bank str9x 0x00080000 0x00008000 0 0 0

# For more information about the configuration files, take a look at:
# openocd.texi

I got this config file from the berlios site, but I don’t know why it doesn’t work.

Can anyone help me?

Thanks!

Good day,

I’ve also purchased the Amontec JTAGKey (tiny) and got the exact same error that you’re describing. Have you managed to resolve your problem?

My openOCD version:

Open On-Chip Debugger 1.0 (2009-03-18-22:26) svn:1417M, with

llibftd2xx 0.4.16

My config file is as follow:

source [find interface/amontec-tiny.cfg]

source [find target/str912.cfg]

Regards,

Frikkie Thirion

Hi there,

I’ve played a bit more with the configuration options, and it seems asif the problem is related to the JTAG speed.

The method that worked for me was to leave the default JTAG speed at 0, as defined in the supplied config files and right at the end of my config script to increase the JTAG speed. This seemed to do the trick.

Original output from OpenOCD, referencing the following files in my openocd.cfg:

source [find interface/amontec-tiny.cfg]

source [find target/str912.cfg]

jtag_speed: 0

RCLK - adaptive

str9x.c str9x_register_commands 76

str9x.c str9x_flash_bank_command 173

str9x.c str9x_build_block_list 93

str9x.c str9x_register_commands 76

str9x.c str9x_flash_bank_command 173

str9x.c str9x_build_block_list 93

Error: RCLK not supported

Info : JTAG tap: str912.flash tap/device found: 0x04570041 (Manufacturer: 0x020, Part: 0x4570, Version: 0x0)

Info : JTAG Tap/device matched

Info : JTAG tap: str912.cpu tap/device found: 0xffffffff (Manufacturer: 0x7ff, Part: 0xffff, Version: 0xf)

Error: JTAG tap: str912.cpu got: 0xffffffff (mfg: 0x7ff, part: 0xffff, ver: 0xf)

Error: JTAG tap: str912.cpu expected 1 of 1: 0x25966041 (mfg: 0x020, part: 0x5966, ver: 0x2)

Error: trying to validate configured JTAG chain anyway…

Error: Could not validate JTAG scan chain, IR mismatch, scan returned 0x000029. tap=str912.cpu pos=8 expected 0x1 got 0

Warn : Could not validate JTAG chain, continuing anyway…

OpenOCD output after the speed option was added to the config file:

source [find interface/amontec-tiny.cfg]

GDB can also flash my flash!

gdb_memory_map enable

gdb_flash_program enable

source [find target/str912.cfg]

jtag_khz 3000

RCLK - adaptive

RCLK - adaptive

str9x.c str9x_register_commands 76

str9x.c str9x_flash_bank_command 173

str9x.c str9x_build_block_list 93

str9x.c str9x_register_commands 76

str9x.c str9x_flash_bank_command 173

str9x.c str9x_build_block_list 93

3000 kHz

Info : JTAG tap: str912.flash tap/device found: 0x04570041 (Manufacturer: 0x020, Part: 0x4570, Version: 0x0)

Info : JTAG Tap/device matched

Info : JTAG tap: str912.cpu tap/device found: 0x25966041 (Manufacturer: 0x020, Part: 0x5966, Version: 0x2)

Info : JTAG Tap/device matched

Info : JTAG tap: str912.bs tap/device found: 0x2457f041 (Manufacturer: 0x020, Part: 0x457f, Version: 0x2)

Error: JTAG tap: str912.bs got: 0x2457f041 (mfg: 0x020, part: 0x457f, ver: 0x2)

Error: JTAG tap: str912.bs expected 1 of 1: 0x1457f041 (mfg: 0x020, part: 0x457f, ver: 0x1)

Error: trying to validate configured JTAG chain anyway…

Warn : no telnet port specified, using default port 4444

Warn : no gdb port specified, using default port 3333

Warn : no tcl port specified, using default port 6666

Warn : DBGACK set while target was in unknown state. Reset or initialize target.

target state: halted

target halted in ARM state due to breakpoint, current mode: Supervisor

cpsr: 0x600000d3 pc: 0x500021f0

Footnote:

My download speed has improved from 0.9kb/s to 28.070546 kb/s

:lol:

Regards,

-Frikkie Thirion

Hi frix,

thanks for your post. I followed your instructions and now I get

Open On-Chip Debugger 1.0 (2009-03-19-16:11) svn:1417

BUGS? Read http://svn.berlios.de/svnroot/repos/openocd/trunk/BUGS

$URL: http://svn.berlios.de/svnroot/repos/ope … /openocd.c $

RCLK - adaptive

3000 kHz

Info : JTAG tap: str912.flash tap/device found: 0x04570041 (Manufacturer: 0x020, Part: 0x4570, Version: 0x0)

Info : JTAG Tap/device matched

Info : JTAG tap: str912.cpu tap/device found: 0x25966041 (Manufacturer: 0x020, Part: 0x5966, Version: 0x2)

Info : JTAG Tap/device matched

Info : JTAG tap: str912.bs tap/device found: 0x2457f041 (Manufacturer: 0x020, Part: 0x457f, Version: 0x2)

Error: JTAG tap: str912.bs got: 0x2457f041 (mfg: 0x020, part: 0x457f, ver: 0x2)

Error: JTAG tap: str912.bs expected 1 of 1: 0x1457f041 (mfg: 0x020, part: 0x457f, ver: 0x1)

Error: trying to validate configured JTAG chain anyway…

Warn : no telnet port specified, using default port 4444

Warn : no gdb port specified, using default port 3333

Warn : no tcl port specified, using default port 6666

The problem seems solved, but now of course I want to write/erase the flash.

If I added one of the command listed in the manual like :

flash write_image, flash write_bank or also halt wait_halt, reset

I always have an “invalid command name”.

How can I program this STR9 microcontroller?

ok, if I add this line to the cfg file

flash write_bank 0 main.bin 0

I got an invalid command error

So I tried with a telnet connection and when I type

flash write_bank 0 main.bin 0

I got this:

flash writing failed with error code: 0xfffffc7a

error writing to flash at address 0x00000000 at offset 0x00000000 (-902)

Also I can’t make a GDB connection. This is the log file

RCLK - adaptive

3000 kHz

Info : JTAG tap: str912.flash tap/device found: 0x04570041 (Manufacturer: 0x020, Part: 0x4570, Version: 0x0)

Info : JTAG Tap/device matched

Info : JTAG tap: str912.cpu tap/device found: 0x25966041 (Manufacturer: 0x020, Part: 0x5966, Version: 0x2)

Info : JTAG Tap/device matched

Info : JTAG tap: str912.bs tap/device found: 0x2457f041 (Manufacturer: 0x020, Part: 0x457f, Version: 0x2)

Error: JTAG tap: str912.bs got: 0x2457f041 (mfg: 0x020, part: 0x457f, ver: 0x2)

Error: JTAG tap: str912.bs expected 1 of 1: 0x1457f041 (mfg: 0x020, part: 0x457f, ver: 0x1)

Error: trying to validate configured JTAG chain anyway…

Warn : no telnet port specified, using default port 4444

Warn : no gdb port specified, using default port 3333

Warn : no tcl port specified, using default port 6666

Warn : DBGACK set while target was in unknown state. Reset or initialize target.

target state: halted

target halted in ARM state due to breakpoint, current mode: Supervisor

cpsr: 0x20000013 pc: 0x50000098

Info : accepting ‘telnet’ connection from 0

target state: halted

target halted in ARM state due to breakpoint, current mode: Supervisor

cpsr: 0x20000013 pc: 0x50000098

Error: flash writing failed with error code: 0xfffffc7a

Error: error writing to flash at address 0x00000000 at offset 0x00000000 (-902)

Info : accepting ‘gdb’ connection from 0

Error: attempted ‘gdb’ connection rejected

and this is the output of the telnet session

flash write_bank 0 main.bin 0

flash writing failed with error code: 0xfffffc7a

error writing to flash at address 0x00000000 at offset 0x00000000 (-902)

called at file “command.c”, line 456

called at file “embedded:startup.tcl”, line 89

called at file “embedded:startup.tcl”, line 93

accepting ‘gdb’ connection from 0

attempted ‘gdb’ connection rejected

Good day,

Hope my reply can still be of service. The error code (-902) that you’ve received seems to be related to a flash sector that is still write protected. You also won’t get far if you haven’t performed the ‘flash_config’.

Regards,

Frikkie Thirion

Here is my updated command sequence (after battling 4 hours with it):

reset halt

str9x flash_config 0 4 2 0 0x80000

(Note: This is absolutely mandatory on the STR9 if you want any of the other flash

commands to work properly!)

flash protect 0 0 0 off

(Disable write protection on flash bank 0, sector 0)

flash protect_check 0

flash info 0

#0: str9x at 0x00000000, size 0x00080000, buswidth 0, chipwidth 0

0: 0x00000000 (0x10000 64kB) not protected

(Note: The status of bank 0 now indicates: not protected)

(Note: Use flash protect_check and flash info together to obtain consistent results)

flash erase_sector 0 0 0

flash erase_check 0

successfully checked erase state

0: 0x00000000 (0x10000 64kB) erased

flash write_image main.hex 0 ihex

wrote 33788 byte from file main.hex in 2.924507s (11.282617 kb/s)

I had the same problem (error -902) and I finally resolved it.

I am using LPC2106 and in my case the problem was in the flash bank command. My flash bank command was:

flash bank lpc2000 0x0 0x20000 0 0 0 lpc2000_v2 14740 calc_checksum

I changed that to:

flash bank lpc2000 0x0 0x20000 0 0 0 lpc2000_v1 14740 calc_checksum

and it worked.

Openocd manual for openocd 0.2.0 explains the difference between the two.

-Ananda