calling script procedures

Hi,

I have added a tcl procedure at the top in sam7x256.cfg file like this:

proc program_flash {flashfile} {

arm7_9 dcc_downloads enable

halt

wait_halt

sleep 10

poll

flash probe 0

flash erase_sector 0 0 15

at91sam7 gpnvm 0 set

at91sam7 gpnvm 2 set

flash write_bank 0 $flashfile 0x0

sleep 10

shutdown

}

if I call this procedure from a telnet session like:

program_flash myfile.bin

it works, but if I try to call this from the command line e.g.

openocd -f jtagkey.cfg -f sam7x256.cfg --command “program_flash myfile.bin”

it complains about halt, wait_halt etc is not a valid command. I have read the documentation and this forum but I can’t figure out the problem.

Some info say that I should use the $_TARGETNAME but I can’t figure out how in the context above, where should the target name be used. Some info says that I should use something like

$_TARGETNAME configure -event …

but what event should I use to program the flash…

Any help appreciated

You need to supply an “init” command before any other if you want to use them from the command line. If you use telnet, that’s not required, as OpenOCD executes that command AFTER all the command line parameters have been processed.

So try

-f interface/… -f target/… -c “init” -c “whatever_you_want”

4/3!!