How to use the tcl port?

Hi

I don’t understand how I should make use of the tcl port? (using Ubuntu)

I tried to connect to it with

telnet localhost 6666

And it accepts more or less the same commands as when I’m connected top the real telnet port (4444).

Let’s say I would like to write a script that flashes the mcu,

and let’s say that this works in a telnet session.

reset halt
flash probe 0
stm32x mass_erase 0
flash write_bank 0 main.bin 0
reset halt

How do I put that in a tcl script that can be called from command line?

Thanks

Johan

Hi Johan,

Just add a function in your openocd.cfg:

progflash {} {

reset halt

flash probe 0

stm32x mass_erase 0

flash write_bank 0 main.bin 0

reset halt

}

Then telnet to TCL port or telnet port and simply execute progflash\r

The telnet port will pass back text status info, like “wrote: x bytes” etc…

However, I am not sure what the TCL interface sends back or is supposed to send back. Simple an ASCII status code that is passed back from flash write_xx through to the caller would be ideal. I think the developers may have considered JSON at some point, read that in an old discussion somewhere…

Cheers,

Martin.

martind:
Then telnet to TCL port or telnet port and simply execute progflash\r

The telnet port will pass back text status info, like “wrote: x bytes” etc…

However, I am not sure what the TCL interface sends back or is supposed to send back. Simple an ASCII status code that is passed back from flash write_xx through to the caller would be ideal. I think the developers may have considered JSON at some point, read that in an old discussion somewhere…

Thanks for the input,

it seems hard to find out if all went well…

Today I use a perl wrapper for the telnet port.

http://fun-tech.se/stm32/PerlTelnet/index.php

And there I have the possibility to parse the output from each command.

(even thou this example just prints it)

I believed that you could do something like that but with tcl.

BR

Johan