Help! JTAGKey, OpenOCD, Atmel 920T, Atmel AT49BV640D and CFI

I am having trouble writing to external Atmel Flash…

Config File:

#daemon configuration
telnet_port 4444
gdb_port 3333
deamon_starup attach

#interface
interface ft2232
ft2232_device_desc "Amontec JTAGkey A"
ft2232_layout jtagkey
ft2232_vid_pid 0x0403 0xcff8
jtag_speed 0
#use combined on interfaces or targets that can't set TRST/SRST separately
reset_config trst_and_srst srst_pulls_trst

#jtag scan chain
#format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
jtag_device 4 0x1 0xf 0xe

#jtag nTRST and nSRST delay
jtag_nsrst_delay 250
jtag_ntrst_delay 250

#target configuration
daemon_startup reset

#target <type> <endianess> <reset mode>
target arm920t little reset_halt 0 arm920t
working_area 0 0x200000 0x100000 nobackup
run_and_halt_time 0 5000

#flash configuration
#flash bank <driver> <base>     <size>   <chip_width> <bus_width> [driver_options ...]
# Chip Width:
# 1 - 1byte  ( 8bit bus)
# 2 - 2bytes (16bit bus)
# 4 - 4bytes (32bit bus)
flash bank  cfi 0x10000000 0x800000 2 2 0
# jedec_probe

# For more information about the configuration files, take a look at:
# http://openfacts.berlios.de/index-en.phtml?title=Open+On-Chip+Debugger
# or
# http://www.amontec.com/sdk4arm.shtml

I have a board when using ‘OpenOCD (2008-04-19) svn: 592’ and the JTAGKey I can break the code, read Flash and RAM but cannot write to Flash.

When I probe the Flash I get some warnings:

> flash probe 0
Address translation failure
Address translation failure
Address translation failure
Address translation failure
Address translation failure
Address translation failure
expected one protection register field, but found 255
Address translation failure
Address translation failure
flash 'cfi' found at 0x10000000

When I do a flash info it fails to detect that the sectors are protected but returns all the relevant information:

> flash info 0
#0: cfi at 0x10000000, size 0x00800000, buswidth 2, chipwidth 2
        #0: 0x00000000 (0x2000 8kB) protection state unknown
        #1: 0x00002000 (0x2000 8kB) protection state unknown
        #2: 0x00004000 (0x2000 8kB) protection state unknown
        #3: 0x00006000 (0x2000 8kB) protection state unknown
        #4: 0x00008000 (0x2000 8kB) protection state unknown
        #5: 0x0000a000 (0x2000 8kB) protection state unknown
        #6: 0x0000c000 (0x2000 8kB) protection state unknown
        #7: 0x0000e000 (0x2000 8kB) protection state unknown
        #8: 0x00010000 (0x10000 64kB) protection state unknown
        #9: 0x00020000 (0x10000 64kB) protection state unknown
        #10: 0x00030000 (0x10000 64kB) protection state unknown
        #11: 0x00040000 (0x10000 64kB) protection state unknown
        #12: 0x00050000 (0x10000 64kB) protection state unknown
        #13: 0x00060000 (0x10000 64kB) protection state unknown
        #14: 0x00070000 (0x10000 64kB) protection state unknown
        #15: 0x00080000 (0x10000 64kB) protection state unknown
        #16: 0x00090000 (0x10000 64kB) protection state unknown
        #17: 0x000a0000 (0x10000 64kB) protection state unknown
        #18: 0x000b0000 (0x10000 64kB) protection state unknown
        #19: 0x000c0000 (0x10000 64kB) protection state unknown
        #20: 0x000d0000 (0x10000 64kB) protection state unknown
        #21: 0x000e0000 (0x10000 64kB) protection state unknown
        #22: 0x000f0000 (0x10000 64kB) protection state unknown
        #23: 0x00100000 (0x10000 64kB) protection state unknown
        #24: 0x00110000 (0x10000 64kB) protection state unknown
        #25: 0x00120000 (0x10000 64kB) protection state unknown
        #26: 0x00130000 (0x10000 64kB) protection state unknown
        #27: 0x00140000 (0x10000 64kB) protection state unknown
        #28: 0x00150000 (0x10000 64kB) protection state unknown
        #29: 0x00160000 (0x10000 64kB) protection state unknown
        #30: 0x00170000 (0x10000 64kB) protection state unknown
        #31: 0x00180000 (0x10000 64kB) protection state unknown
        #32: 0x00190000 (0x10000 64kB) protection state unknown
        #33: 0x001a0000 (0x10000 64kB) protection state unknown
        #34: 0x001b0000 (0x10000 64kB) protection state unknown
        #35: 0x001c0000 (0x10000 64kB) protection state unknown
        #36: 0x001d0000 (0x10000 64kB) protection state unknown
        #37: 0x001e0000 (0x10000 64kB) protection state unknown
        #38: 0x001f0000 (0x10000 64kB) protection state unknown
        #39: 0x00200000 (0x10000 64kB) protection state unknown
        #40: 0x00210000 (0x10000 64kB) protection state unknown
        #41: 0x00220000 (0x10000 64kB) protection state unknown
        #42: 0x00230000 (0x10000 64kB) protection state unknown
        #43: 0x00240000 (0x10000 64kB) protection state unknown
        #44: 0x00250000 (0x10000 64kB) protection state unknown
        #45: 0x00260000 (0x10000 64kB) protection state unknown
        #46: 0x00270000 (0x10000 64kB) protection state unknown
        #47: 0x00280000 (0x10000 64kB) protection state unknown
        #48: 0x00290000 (0x10000 64kB) protection state unknown
        #49: 0x002a0000 (0x10000 64kB) protection state unknown
        #50: 0x002b0000 (0x10000 64kB) protection state unknown
        #51: 0x002c0000 (0x10000 64kB) protection state unknown
        #52: 0x002d0000 (0x10000 64kB) protection state unknown
        #53: 0x002e0000 (0x10000 64kB) protection state unknown
        #54: 0x002f0000 (0x10000 64kB) protection state unknown
        #55: 0x00300000 (0x10000 64kB) protection state unknown
        #56: 0x00310000 (0x10000 64kB) protection state unknown
        #57: 0x00320000 (0x10000 64kB) protection state unknown
        #58: 0x00330000 (0x10000 64kB) protection state unknown
        #59: 0x00340000 (0x10000 64kB) protection state unknown
        #60: 0x00350000 (0x10000 64kB) protection state unknown
        #61: 0x00360000 (0x10000 64kB) protection state unknown
        #62: 0x00370000 (0x10000 64kB) protection state unknown
        #63: 0x00380000 (0x10000 64kB) protection state unknown
        #64: 0x00390000 (0x10000 64kB) protection state unknown
        #65: 0x003a0000 (0x10000 64kB) protection state unknown
        #66: 0x003b0000 (0x10000 64kB) protection state unknown
        #67: 0x003c0000 (0x10000 64kB) protection state unknown
        #68: 0x003d0000 (0x10000 64kB) protection state unknown
        #69: 0x003e0000 (0x10000 64kB) protection state unknown
        #70: 0x003f0000 (0x10000 64kB) protection state unknown
        #71: 0x00400000 (0x10000 64kB) protection state unknown
        #72: 0x00410000 (0x10000 64kB) protection state unknown
        #73: 0x00420000 (0x10000 64kB) protection state unknown
        #74: 0x00430000 (0x10000 64kB) protection state unknown
        #75: 0x00440000 (0x10000 64kB) protection state unknown
        #76: 0x00450000 (0x10000 64kB) protection state unknown
        #77: 0x00460000 (0x10000 64kB) protection state unknown
        #78: 0x00470000 (0x10000 64kB) protection state unknown
        #79: 0x00480000 (0x10000 64kB) protection state unknown
        #80: 0x00490000 (0x10000 64kB) protection state unknown
        #81: 0x004a0000 (0x10000 64kB) protection state unknown
        #82: 0x004b0000 (0x10000 64kB) protection state unknown
        #83: 0x004c0000 (0x10000 64kB) protection state unknown
        #84: 0x004d0000 (0x10000 64kB) protection state unknown
        #85: 0x004e0000 (0x10000 64kB) protection state unknown
        #86: 0x004f0000 (0x10000 64kB) protection state unknown
        #87: 0x00500000 (0x10000 64kB) protection state unknown
        #88: 0x00510000 (0x10000 64kB) protection state unknown
        #89: 0x00520000 (0x10000 64kB) protection state unknown
        #90: 0x00530000 (0x10000 64kB) protection state unknown
        #91: 0x00540000 (0x10000 64kB) protection state unknown
        #92: 0x00550000 (0x10000 64kB) protection state unknown
        #93: 0x00560000 (0x10000 64kB) protection state unknown
        #94: 0x00570000 (0x10000 64kB) protection state unknown
        #95: 0x00580000 (0x10000 64kB) protection state unknown
        #96: 0x00590000 (0x10000 64kB) protection state unknown
        #97: 0x005a0000 (0x10000 64kB) protection state unknown
        #98: 0x005b0000 (0x10000 64kB) protection state unknown
        #99: 0x005c0000 (0x10000 64kB) protection state unknown
        #100: 0x005d0000 (0x10000 64kB) protection state unknown
        #101: 0x005e0000 (0x10000 64kB) protection state unknown
        #102: 0x005f0000 (0x10000 64kB) protection state unknown
        #103: 0x00600000 (0x10000 64kB) protection state unknown
        #104: 0x00610000 (0x10000 64kB) protection state unknown
        #105: 0x00620000 (0x10000 64kB) protection state unknown
        #106: 0x00630000 (0x10000 64kB) protection state unknown
        #107: 0x00640000 (0x10000 64kB) protection state unknown
        #108: 0x00650000 (0x10000 64kB) protection state unknown
        #109: 0x00660000 (0x10000 64kB) protection state unknown
        #110: 0x00670000 (0x10000 64kB) protection state unknown
        #111: 0x00680000 (0x10000 64kB) protection state unknown
        #112: 0x00690000 (0x10000 64kB) protection state unknown
        #113: 0x006a0000 (0x10000 64kB) protection state unknown
        #114: 0x006b0000 (0x10000 64kB) protection state unknown
        #115: 0x006c0000 (0x10000 64kB) protection state unknown
        #116: 0x006d0000 (0x10000 64kB) protection state unknown
        #117: 0x006e0000 (0x10000 64kB) protection state unknown
        #118: 0x006f0000 (0x10000 64kB) protection state unknown
        #119: 0x00700000 (0x10000 64kB) protection state unknown
        #120: 0x00710000 (0x10000 64kB) protection state unknown
        #121: 0x00720000 (0x10000 64kB) protection state unknown
        #122: 0x00730000 (0x10000 64kB) protection state unknown
        #123: 0x00740000 (0x10000 64kB) protection state unknown
        #124: 0x00750000 (0x10000 64kB) protection state unknown
        #125: 0x00760000 (0x10000 64kB) protection state unknown
        #126: 0x00770000 (0x10000 64kB) protection state unknown
        #127: 0x00780000 (0x10000 64kB) protection state unknown
        #128: 0x00790000 (0x10000 64kB) protection state unknown
        #129: 0x007a0000 (0x10000 64kB) protection state unknown
        #130: 0x007b0000 (0x10000 64kB) protection state unknown
        #131: 0x007c0000 (0x10000 64kB) protection state unknown
        #132: 0x007d0000 (0x10000 64kB) protection state unknown
        #133: 0x007e0000 (0x10000 64kB) protection state unknown
        #134: 0x007f0000 (0x10000 64kB) protection state unknown

cfi information:

mfr: 0x001f, id:0x02de
qry: 'QRY', pri_id: 0x0003, pri_addr: 0x0041, alt_id: 0x0000, alt_addr: 0x0000
Vcc min: 2.7, Vcc max: 3.6, Vpp min: 9.0, Vpp max: a.0
typ. word write timeout: 16, typ. buf write timeout: 4, typ. block erase timeout: 512, typ. chip erase timeout: 1
max. word write timeout: 256, max. buf write timeout: 64, max. block erase timeout: 4096, max. chip erase timeout: 1
size: 0x800000, interface desc: 1, max buffer write size: 2

intel primary algorithm extend information:
pri: 'PRI', version: 1.0
feature_support: 0x186, suspend_cmd_support: 0x80, blk_status_reg_mask: 0x303
Vcc opt: f.f, Vpp opt: f.f
protection_fields: 255, prot_reg_addr: 0xffff, factory pre-programmed: -2147483648, user programmable: -2147483648

When I unprotect and try to write a word the following happens:

> flash protect 0 0 134 off
cleared protection for sectors 0 through 134 on flash bank 0
> flash fillw 0x10000000 0xAA55AA55 1
Address translation failure
Address translation failure
Address translation failure
status register: 0x82
Block Lock-Bit Detected, Operation Abort
Address translation failure
Address translation failure
couldn't erase block 0 of flash bank at base 0x10000000
failed erasing sectors 0 to 0 (-902)
>

I presume the problem is that Atmel flash is not supported but see that there are Atmel functions in the code but it uses the intel ones???

This is the output from OpenOCD:
C:\Test>openocd-ftd2xx.exe -f ubm.cfg
Open On-Chip Debugger (2008-04-19 12:00) svn: 592
URL: http://svn.berlios.de/svnroot/repos/openocd/trunk
Info:    options.c:50 configuration_output_handler(): Command deamon_starup not found
Info:    options.c:50 configuration_output_handler(): jtag_speed: 0, 0
Info:    options.c:50 configuration_output_handler(): Open On-Chip Debugger (2008-04-19 12:00) svn: 592
Info:    jtag.c:1376 jtag_examine_chain(): JTAG device found: 0x05b0203f (Manufacturer: 0x01f, Part: 0x5b02, Version: 0x0)
Info:    jtag.c:1376 jtag_examine_chain(): JTAG device found: 0x05b0203f (Manufacturer: 0x01f, Part: 0x5b02, Version: 0x0)
Info:    options.c:50 configuration_output_handler(): nSRST pulls nTRST, falling back to "reset run_and_halt"
Info:    server.c:78 add_connection(): accepting 'telnet' connection from 0
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Warning: cfi.c:382 cfi_read_intel_pri_ext(): expected one protection register field, but found 255
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Warning: cfi.c:382 cfi_read_intel_pri_ext(): expected one protection register field, but found 255
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   flash.c:873 get_flash_bank_by_addr(): No flash at address 0x00000000

Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   cfi.c:284 cfi_intel_wait_status_busy(): status register: 0x82
Error:   cfi.c:286 cfi_intel_wait_status_busy(): Block Lock-Bit Detected, Operation Abort
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   cfi.c:681 cfi_intel_erase(): couldn't erase block 0 of flash bank at base 0x10000000
Error:   flash.c:116 flash_driver_erase(): failed erasing sectors 0 to 0 (-902)
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   cfi.c:284 cfi_intel_wait_status_busy(): status register: 0x82
Error:   cfi.c:286 cfi_intel_wait_status_busy(): Block Lock-Bit Detected, Operation Abort
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   cfi.c:681 cfi_intel_erase(): couldn't erase block 0 of flash bank at base 0x10000000
Error:   flash.c:116 flash_driver_erase(): failed erasing sectors 0 to 0 (-902)
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   cfi.c:284 cfi_intel_wait_status_busy(): status register: 0x82
Error:   cfi.c:286 cfi_intel_wait_status_busy(): Block Lock-Bit Detected, Operation Abort
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   cfi.c:681 cfi_intel_erase(): couldn't erase block 0 of flash bank at base 0x10000000
Error:   flash.c:116 flash_driver_erase(): failed erasing sectors 0 to 1 (-902)
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Warning: cfi.c:382 cfi_read_intel_pri_ext(): expected one protection register field, but found 255
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   cfi.c:284 cfi_intel_wait_status_busy(): status register: 0x82
Error:   cfi.c:286 cfi_intel_wait_status_busy(): Block Lock-Bit Detected, Operation Abort
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   armv4_5_mmu.c:57 armv4_5_mmu_translate_va(): Address translation failure
Error:   cfi.c:681 cfi_intel_erase(): couldn't erase block 0 of flash bank at base 0x10000000
Error:   flash.c:116 flash_driver_erase(): failed erasing sectors 0 to 0 (-902)