index.tcl Config Target index.tcl OpenOCD debugger index.tcl    

Target Status

set form_address [formfetch form_address] set form_action [formfetch form_action] if {[string compare $form_action "Halt"]==0} { append console [encode [capture_catch "halt"]] } if {[string compare $form_action "Resume"]==0} { append console [encode [capture_catch "resume"]] } if {[string compare $form_action "Reset and run"]==0} { append console [encode [capture_catch "reset run"]] } if {[string compare $form_action "Power on"]==0} { append console [encode [capture_catch "power on"]] } if {[string compare $form_action "Power off"]==0} { append console [encode [capture_catch "power off"]] } append console [encode [capture_catch poll]]


]]>
Target status shows that status of the connected target.

Current target - selected target configuration.

Startup - whether or not the target script ran to completion. Note that even if the target is disconnected, powered down or unresponsive, the startup script will still run to completion. Startup - OK does not mean that the target is fully operational, simply that the configuration script did not contain syntax errors for instance. See log for details.

Target power - Detects power on target.
If the JTAG cable is not connected, or the target has no power, then no target power will be detected.

Power on - Turn on ZY1000 target power relay.

Power off - Turn off ZY1000 target power relay.

Type "help power" in telnet for command to control power relay.

Reboot ZY1000 - Reboots ZY1000 unit. Type "help reboot" in telnet.

]]>
targets.tcl documentation.tcl Target config quick start guide The reset init script is crucial. It will set up e.g. MMU, chip select registers, etc. after a reset. The init.cfg (reset init script) is embedded into the openocd.cfg file in the sampls Zylin provides.

Writing an openocd.cfg from scratch is a non-trivial exercise, but fortunally it only has to be done once for a target and afterwards it rarely if ever needs to be changed. ]]> Quick start guide on how to configure a target. reload.tcl index.tcl Reload Config Scripts set form_action [formfetch form_action] if {[string compare $form_action "Reload"]==0} { append buffer "Reloading Config Scripts...

" reboot }

]]>
Restart ZY1000 to reload selected target config script.
flashinfo.tcl Flash flashinfo.tcl Flash Information flashinfo.tcl Configured flash banks:

set flash_return [ocd_flash_banks] if {[llength $flash_return]!=0} { append buffer [encode [flash banks]] set form_action [formfetch form_action] if {[string compare $form_action "Reset CPU and probe flash"]==0} { append console [encode [capture_catch "reset init"]] append buffer [encode [capture_catch "flash probe 0"]] append buffer [encode [capture_catch "flash info 0"]] } } else { append buffer "No flash bank configured." }

foreach a [ocd_flash_banks] { append buffer "Flash bank at [format "0x%08x size 0x%08x" $a(base) $a(size)]: "
"> ">
}
]]>
Here you will find information about the flash chips that you have in your configuration.

Reset CPU and probe flash - This will reset the CPU and show you more detailed information about your flash. This includes information about the different sectors in the flash, and the flash driver used.

]]>
flash.tcl flashinfo.tcl Program / Verify Flash set form_offset [formfetch form_offset] set form_action [formfetch form_action] set form_type [formfetch form_type] set post "" catch {set post $post_data} err if {[string compare $form_offset ""]==0} { set form_offset 0 } if {[string compare $form_type ""]==0} { set form_type "" } set data "" append buffer {
} set action_reset [expr {[string length $form_action]!=0}] set action_flash [expr {[string compare $form_action "Flash"]==0 || [string compare $form_action "Flash and verify"]==0}] set action_verify [expr {[string compare $form_action "Verify"]==0 || [string compare $form_action "Flash and verify"]==0}] if {$action_reset} { append console [encode [capture_catch "reset init"]] } append buffer {} append buffer {} append buffer ""
File
Offset
Type
 
 

if {$action_flash||$action_verify} { catch {writeform form_filecontent $upload_filename} result append console [encode $result] } append buffer "
" if {$action_flash} { append console [encode [capture_catch "halt"]] append buffer "" if {[catch {capture_catch {eval "flash write_image erase $upload_filename $form_offset $form_type"}} result]} { append buffer "Flash write failed
" append console [encode $result] } else { append buffer [encode $result] append buffer "Flash write succeed
" } append buffer "
" } if {$action_verify} { append console [encode [capture_catch "halt"]] append buffer "" if {[catch {capture_catch {eval "verify_image $upload_filename $form_offset $form_type"}} result]} { append buffer "Verify failed
" append console [encode $result] } else { append buffer [encode $result] append buffer "Verify succeed
" } append buffer "
" }

]]>
Program and/or verify the flash on your target.

Flash - Halt CPU, automatically erase flash if required and program flash with image.

Flash and verify - Programs the flash and verifies the programmed flash content is correct.

Verify - Halt CPU and verify image in flash or RAM.

Offset - This value is added to the address of the image.
Binary images start at address 0 by default, whereas elf and ihex have addresses encoded into the image.
Typically 0 for elf/ihex and the address to write the image to for binary files.

]]>
production.tcl flashinfo.tcl Production set form_action [formfetch form_action] set form_serialnumber [formfetch form_serialnumber] append buffer [production_info]
if {[string compare $form_action "Upload firmware"]==0} { set wrotedata [catch {writeform form_filecontent $upload_filename} result] append buffer [encode $result] if {$wrotedata==0} { append buffer "
Running production procedure

" append buffer "
Reset and init:
" append console [encode [capture_catch {catch "production $upload_filename $form_serialnumber"}]] } } if {[string compare $form_action "Test"]==0} { append buffer "
Running production test. Output from first 10 seconds printed below.

" append console [encode [capture_catch {catch production_test}]] } if {[string compare $form_action "Power on"]==0} { append console [encode [capture_catch "power on"]] } if {[string compare $form_action "Power off"]==0} { append console [encode [capture_catch "power off"]] } append buffer {

Firmware file(raw binary)

} append buffer {

Serial number

}
 
 
     

]]>
Upload firmware - Power cycle target, reset target and program raw binary file to flash bank 0, offset 0 and verify flash programming. Leave target powered on.

Test - Power up target, run 10 second target test. Output is provided via the DCC output channel.

Power on - Power on target.

Power off - Power off target.

Serial number - A target script can use this string in the production procedure. Type "help production" for more info.

]]>
erase.tcl erase.tcl Erase Flash flashinfo.tcl set form_address [formfetch form_address] set form_length [formfetch form_length] set form_action [formfetch form_action] if {[string compare $form_length ""]==0} { set form_length 0x10000 } if {[string compare $form_address ""]==0} { if {[catch {[zy1000_flash]} result]==0} { set form_address "0x[tohex $result]" } } if {[string compare $form_address ""]!=0} { if {[string compare $form_action "Erase"]==0} { append buffer "" append console [encode [capture_catch { reset init flash erase_address $form_address $form_length}]] append buffer } }
Address
Length
 
 

]]>
Note that flash programming will erase flash if required.

Reset and init CPU, then erase address range.

The length field is specified in number of bytes.

]]>
run.tcl run.tcl Run program flashinfo.tcl set form_address [formfetch form_address] set form_action [formfetch form_action] if {[string compare $form_action "Run from address"]==0} { append console [encode [capture_catch "halt"]] append console [encode [capture_catch "wait_halt"]] append console [encode [capture_catch "resume $form_address"]] } if {[string compare $form_action "Halt"]==0} { append console [encode [capture_catch "halt"]] append console [encode [capture_catch "wait_halt"]] } if {[string compare $form_action "Reset and run"]==0} { append console [encode [capture_catch "reset run"]] } if {[string compare $form_action "Reset and init"]==0} { append console [encode [capture_catch "reset init"]] } append console [encode [capture_catch poll]]
Address
 
 

]]>
Reset and run - reset CPU and let it run.

Halt - halt CPU.

Run from address - halt CPU and resume from address. Default is resume from current address.

Reset and init - reset CPU and run init script.

]]>
browsemem.tcl Memory browsemem.tcl Browse / Edit Memory browsemem.tcl set form_address [formfetch form_address] set form_length [formfetch form_length] set form_type [formfetch form_type] set form_action [formfetch form_action] set form_value [formfetch form_value] if {[string compare $form_length ""]==0} { set form_length 0 } if {$form_length<=0} { set form_length 0x80 } if {$form_length>0x1000} { set form_length 0x1000 } if {[string compare $form_type ""]==0} { set form_type mdw } if {[string compare $form_type "mdw"]==0} { set wordsize 4 set modify_cmd mww } if {[string compare $form_type "mdh"]==0} { set wordsize 2 set modify_cmd mwh } if {[string compare $form_type "mdb"]==0} { set wordsize 1 set modify_cmd mwb } if {[string compare $form_address ""]!=0} { if {[string compare $form_action "Previous"]==0} { # Kludge! Work around problems parsing hex in Jim Tcl expressions incr form_address ; set form_address [expr $form_address-1] if {$form_address-$form_length>0} { set form_address "0x[tohex [expr $form_address-$form_length]]" } else { set form_address "0x0" } } if {[string compare $form_action "Next"]==0} { # Kludge! Work around problems parsing hex in Jim Tcl expressions incr form_address ; set form_address [expr $form_address-1] set form_address "0x[tohex [expr $form_address+$form_length]]" } if {[string compare $form_action "Modify"]==0} { append console [capture_catch "$modify_cmd $form_address $form_value"] } if {[string compare $form_action "Fill"]==0} { append console [capture_catch "$modify_cmd $form_address $form_value $form_length"] } }
Address
Length">
Value    
Type
 
 
   

Memory:

if {[string compare $form_address ""]!=0} { append console [encode [capture_catch halt]] append buffer [encode [capture_catch "$form_type $form_address [expr $form_length]"]] } ]]> Browse and edit target memory.
Length is in bytes, maximum 4096 bytes.

An error message is shown when trying to browse or edit memory which cases a CPU fault.

CPU will be halted if required.

Modify - Will modify only one byte, half-word or word starting at Address.

Fill - Will fill the specified region with the specified value.

Refresh - Display the content of the specified memory area.

]]>
downloadmem.tcl browsemem.tcl Download Memory Range set form_address [formfetch form_address] set form_length [formfetch form_length] set form_action [formfetch form_action]
Address
Length
 
 
if {[string compare $form_action "Download"]==0} { append console [encode [capture_catch "reset init"]] append console [encode [capture_catch "dump_image /tmp/dump.bin $form_address $form_length"]]
} ]]>
Note that download memory can take a long time(potentially minutes for megabytes at low JTAG clk speeds).

Once the memory is downloaded a link is available on the page to download the file from ZY1000 to your PC. ]]> openocd.tcl OpenOCD openocd.tcl Run Command openocd.tcl set form_command [formfetch form_command] set form_edittext "" if {[string length $form_command]>0} { catch {capture_catch {eval "$form_command"}} form_edittext } append buffer {

} "\n" append buffer {Command
} append buffer {
} append buffer {
} append buffer {
} append buffer {
} "\n" ]]> Run tcl statement(s). Add "ocd_" prefix to OpenOCD commands otherwise there will be no output, e.g. "reset init" use "ocd_reset init".

Click here to download log.

To download log you can also use commands like "wget http://append buffer [ip]/ram/log", or point your web browser to said address.

You can also execute tcl commands using curl from your developer PC:

curl --form form_command=ocd_version append buffer [ip]runtcl.tcl ]]>
guiupload.tcl openocd.tcl Upload File to ZY1000 set form_filename [formfetch form_filename]; set form_action [formfetch form_action]; #set form_filecontent [formfetch form_filecontent]; append buffer {
} append buffer
if {[string compare $form_action "Upload"]==0} { if {[catch {writeform form_filecontent $form_filename} result]==0} { append buffer [encode $result] } else { append buffer Wrote $form_filename } } append buffer {} append buffer {
Filename on ZY1000
File to upload
} append buffer {
 
 
} append buffer {
} append buffer {
} ]]>
The ZY1000 has three filing systems "/rom", "/ram" and "/config". "/rom" is a read only filing embedded into the firmware.

Use "/ram" to store temporary files.

You can browse filing systems and download files by pointing your web browser to:

You can also upload files using e.g. curl from the command line. Example:

curl --form form_filecontent=@/tmp/myfile.elf --form form_filename=/ram/myfile.elf append buffer [ip]upload.tcl

If you have a tftp server installed on your development PC, you can access files on your developer PC using a /tftp/ip/ prefix to the file to be accessed on your developer PC. Note that if you do not increase the default packet size for your tftp server, then the performance will be very poor. Normal performance is about 500-600kBytes/s.

cp /tftp/10.0.0.106/build/src/openocd /ram/test ]]>
targets.tcl documentation.tcl Target config quick start guide The reset init script is crucial. It will set up e.g. MMU, chip select registers, etc. after a reset. The init.cfg (reset init script) is embedded into the openocd.cfg file in the sampls Zylin provides.

Writing an openocd.cfg from scratch is a non-trivial exercise, but fortunally it only has to be done once for a target and afterwards it rarely if ever needs to be changed. ]]> Quick start guide on how to configure a target. index.tcl index.tcl terminal.tcl UART forwarding set form_baudrate [formfetch form_baudrate] if {[string length $form_baudrate]==0} { set form_baudrate [ocd_uart] set form_baudrate [string range $form_baudrate 0 [expr [string length $form_baudrate]-2]] } set form_action [formfetch form_action]

Target baudrate:

if {[string compare $form_action "Set baudrate"]==0} { append console [encode [ocd_uart $form_baudrate]] }

Simple UART

This terminal window is purely for illustrative purposes. Use telnet or a terminal program to talk to the target over TCP/IP for anything but trivial case of reading/writing a few lines of texts in simple tests.

]]> telnet append buffer [ip] 5555 or connect via TCP/IP from e.g. HyperTerminal.

Type "help uart" in telnet for information on how to set uart speed for target. Normally the uart speed is set from the target configuration script by adding an "uart N", where N is the baudrate. ]]>