How to reset a device after flashing it?

Hi,

with the following flash-script I am able to flash my at91sam7x but after flashing it doesn’t reset. I have to unpower und repower it for doing a reset OR I start an OpenOCD connection, open the commandline and send resume. Which changes do I have to make in order to do an automatic reset of the device after flashing it?

telnet_port 4444
gdb_port 3333

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

proc program_flash {flashname} {
   halt
   sleep 10
   arm7_9 dcc_downloads enable
   sleep 10
   poll
	 
   flash protect 0 0 1 off
	 
   flash probe 0

   flash write_bank 0 $flashname 0x0
	 
   init_reset run
   sleep 200
   resume
   sleep 200
   shutdown
}

reset_config srst_only srst_pulls_trst

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

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 0xf -expected-id $_CPUTAPID

set _TARGETNAME [format "%s.cpu" $_CHIPNAME]

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 : bypass the main oscillator, use external clock
	mww 0xfffffc20 0x00000602	
	sleep 10
	
	#  no need for PLL: do not use this
	# CKGR_PLLR: 96.1097 MHz
	#mww 0xfffffc2c 0x00481c0e 	
	#sleep 10
	
	# PMC_MCKR : MCK = main clock = 24,576 MHz; use without divider
	mww 0xfffffc30 0x00000001	
	sleep 10
	# MC_FMR: flash mode (FWS=1,FMCN=40)
	mww 0xffffff60 0x00280100	
	sleep 100
   
  program_flash main.bin
}

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

set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME at91sam7 0 0 0 0 0 0 0 0 0 0 0 0 24576

echo "MPW Target: $_TARGETNAME"
set _FLASHFILE main.bin

init
reset init

Bennm:
Hi,

with the following flash-script I am able to flash my at91sam7x but after flashing it doesn’t reset. I have to unpower und repower it for doing a reset OR I start an OpenOCD connection, open the commandline and send resume. Which changes do I have to make in order to do an automatic reset of the device after flashing it?

init

reset init

I usally do

  • reset halt

  • reset run

But is the reset pin connected in your jtag connector?

BR

Johan

Just “reset” will suffice =]