AT91SAML128 with Amontec Jtag Key and IAR

I’m not able to configure my test card (AT91SAM7-STK) with OpenOCD (0.1.0), JtagKey (Amontec) and IAR (GDB server). Here is my configuration file :

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

telnet_port 4444
gdb_port 3333

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

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

if { [info exists CPUTAPID ] } {
   set _CPUTAPID $CPUTAPID
} else {
  # force an error till we get a good number
#   set _CPUTAPID 0x05B1E03F
   set _CPUTAPID 0x3F0F0F0F
}

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

#jtag scan chain
jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID

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

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

flash bank at91sam7 0 0 0 0 0

I connect to my card but I’m not able to write to flash either with a telnet connection (flash write_bank kill OpenOCD), or via IAR IDE. Here are message from IAR IDE :

Wed Feb 18 18:59:09 2009: Loaded macro file: C:\Program Files\IAR Systems\Embedded Workbench 5.0 Evaluation\ARM\config\flashloader\Atmel\FlashAT91SAM7Lxx.mac
Wed Feb 18 18:59:10 2009:  (FlashAT91SAM7Lxx.mac)------------------------------- FLASH EFC2 Download V1.1
Wed Feb 18 18:59:10 2009:  (FlashAT91SAM7Lxx.mac)------------------------------- 12/Jun/2007
Wed Feb 18 18:59:10 2009: (FlashAT91SAM7Lxx.mac)  -------------------------------- AT91C_MC_FMR  0x00000000
Wed Feb 18 18:59:10 2009: (FlashAT91SAM7Lxx.mac)  -------------------------------- AT91C_MC_FSR  0x00000001
Wed Feb 18 18:59:10 2009: (FlashAT91SAM7Lxx.mac)  Lock Bits ---------------------- AT91C_MC_FRR  0x00000000
Wed Feb 18 18:59:10 2009: (FlashAT91SAM7Lxx.mac)  -------------------------------- AT91C_MC_FSR  0x00000001
Wed Feb 18 18:59:10 2009: (FlashAT91SAM7Lxx.mac)  GNVM Bits ---------------------- AT91C_MC_FRR  0x00000002
Wed Feb 18 18:59:10 2009: (FlashAT91SAM7Lxx.mac) The flash Bit GPNVM1 Is set
Wed Feb 18 18:59:10 2009: (FlashAT91SAM7Lxx.mac) RAM at0x0000 0000
Wed Feb 18 18:59:10 2009: (FlashAT91SAM7Lxx.mac)  Watchdog Disable 
Wed Feb 18 18:59:11 2009: 5780 bytes downloaded and verified (4.82 Kbytes/sec)
Wed Feb 18 18:59:11 2009: Loaded debugee: C:\Program Files\IAR Systems\Embedded Workbench 5.0 Evaluation\ARM\config\flashloader\Atmel\FlashAT91SAM7Lxx.out
Wed Feb 18 18:59:11 2009: Target reset
Wed Feb 18 18:59:11 2009: (FlashAT91SAM7Lxx.mac) --------execUserFlashReset()
Wed Feb 18 18:59:11 2009: R13 0x00004000
Wed Feb 18 18:59:11 2009: PC 0x002FFBA4
Wed Feb 18 18:59:11 2009: (FlashAT91SAM7Lxx.mac) RAM at0x0000 0000
Wed Feb 18 18:59:11 2009: ADD 0xE59FF018
Wed Feb 18 18:59:11 2009: ADD 0xE59FF019
Wed Feb 18 18:59:11 2009: Downloader Version 1.3
Wed Feb 18 18:59:11 2009: Flash: AT91SAM7L At:0x100000
Wed Feb 18 18:59:11 2009: Flash:27330745 Unknowndevice!!!
Wed Feb 18 18:59:11 2009: Flash:page=0 Size=256
Wed Feb 18 18:59:48 2009: Fatal error: Error receiving packet. Connection Lost ?
 

Session aborted!
Wed Feb 18 18:59:49 2009: Non-zero or missing exit code.
Wed Feb 18 18:59:50 2009: Warning: Code still contains old breakpoints

Is there something wrong with my configuration?

Thanks a lot.

Rob

I found my errors after a lot of readings, so I will post modifications for those who can be interested. First of all there was an error in my OpenOCD configuration file in the mapping and size of flash memory. I modified it with :

$_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x00100000 -work-area-size 0x20000 -work-area-backup 0

Then I discovered a problem with my configuration of IAR flash loader. I need to change the configuration of the Base flash loader to 0x100000.

With those two modifications and some other configurations with SAM-BA, I am now able to debug my program.

Rob