Flashing Problem with at91sam7s256

Dear all,

I am trying to program at91sam7s257 using this cfg file:

[#

For more information about the configuration files, take a

look at the “Open On-Chip Debugger (openocd)” documentation.

daemon configuration

telnet_port 4444

gdb_port 3333

tcl_port 6666

tell gdb our flash memory map

and enable flash programming

gdb_memory_map enable

gdb_flash_program enable

#########################################################

Interface, if you want to use an other interface

you must replace this section here.

source [find interface/arm-usb-ocd.cfg]

#########################################################

Target section, this example was tested with an

Olimex SAM7-P256 board.

Start slow, speed up after reset

jtag_khz 30

#use combined on interfaces or targets that can’t set TRST/SRST separately

reset_config srst_only srst_pulls_trst

if { [info exists CHIPNAME] } {

set _CHIPNAME $CHIPNAME

} else {

set _CHIPNAME sam7s256

}

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-start {

jtag_khz 30

}

###################### target end #########################

commands below are specific to AT91sam7 Flash Programming

---------------------------------------------------------

Flash write routine is in the script.ocd file within the project.

$_TARGETNAME configure -event reset-init “script script.ocd”

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

flash bank at91sam7 0 0 0 0 0 0 0 0 0 0 0 0 18432

init

reset init

]

but I get this error:

[lInfo : JTAG tap: sam7s256.cpu tap/device found: 0x3f0f0f0f (mfg: 0x787, part: 0xf0f0, ver: 0x3)

Warn : srst pulls trst - can not reset into halted mode. Issuing halt after reset.

target state: halted

target halted in Thumb state due to debug-request, current mode: Supervisor

cpsr: 0x600000b3 pc: 0x00200ace

core state: ARM

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

]

any idea how to solve this bug?

Best, Alireza[/list][/code]

Have you tried using openOCD’s stock config file for that target? I believe its at91sam7sx.cfg in the target directory. I’m not sure what instructions you have in your script.ocd file which you are calling.

Try this instead:

# daemon configuration
telnet_port 4444
gdb_port 3333
tcl_port 6666

gdb_memory_map enable
gdb_flash_program enable

source [find interface/arm-usb-ocd.cfg]

reset_config srst_only srst_pulls_trst

source [find target/at91sam7sx.cfg]

init
reset init

That should use the stock config file for the version of openOCD you have (which means it should have all the correct commands for that version), which will include the init routine, as well as config for flashing, pretty much everything your script file is doing…except…this by itself will not flash the part. You will have to do that by adding the relavent OpenOCD commands yourself.

I have tried using scripts to flash, with 3 different versions of openOCD, none have worked. (I have the same board as you btw). Only way I have managed to flash a part is by opening up telnet and manually using the flash command at address 0x00100000.

Also, you may want to check if certain lock bits are in place. You can do this via telnet as well (just to see what state your chip is in). I’m not sure what errors openOCD throws up if you try to program flash with locked flash sectors, it may not even tell you the sectors are locked.