summaryrefslogtreecommitdiff
path: root/src/tcl
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-07-09 15:22:05 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-07-09 15:22:05 +0000
commit66410d2537bad8e455e803d1868e7de6bf8cabbd (patch)
tree7f49709672e23ed31eacffd26cd7929d88c46650 /src/tcl
parent525de2ed3d019bccffe3f060b3fee7baa5487425 (diff)
downloadopenocd+libswd-66410d2537bad8e455e803d1868e7de6bf8cabbd.tar.gz
openocd+libswd-66410d2537bad8e455e803d1868e7de6bf8cabbd.tar.bz2
openocd+libswd-66410d2537bad8e455e803d1868e7de6bf8cabbd.tar.xz
openocd+libswd-66410d2537bad8e455e803d1868e7de6bf8cabbd.zip
"flash banks" is now implemented in Tcl on top of "flash_banks". openocd_throw prefix is no longer required when executing OpenOCD commands from tcl.
git-svn-id: svn://svn.berlios.de/openocd/trunk@779 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/tcl')
-rw-r--r--src/tcl/commands.tcl46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/tcl/commands.tcl b/src/tcl/commands.tcl
index a2cf0812..a25badcc 100644
--- a/src/tcl/commands.tcl
+++ b/src/tcl/commands.tcl
@@ -12,3 +12,49 @@ proc board_produce {filename serialnumber} {
proc board_test {} {
echo "Production test not implemented"
}
+
+# Show flash in human readable form
+# This is an example of a human readable form of a low level fn
+proc flash_banks_pretty {} {
+ set i 0
+ set result ""
+ foreach {a} [flash_banks] {
+ if {$i > 0} {
+ set result "$result\n"
+ }
+ set result [format "$result#%d: %s at 0x%08x, size 0x%08x, buswidth %d, chipwidth %d" $i [lindex $a 0] [lindex $a 1] [lindex $a 2] [lindex $a 3] [lindex $a 4]]
+ set i [expr $i+1]
+ }
+ return $result
+}
+
+# We need to explicitly redirect this to the OpenOCD command
+# as Tcl defines the exit proc
+proc exit {} {
+ openocd_throw exit
+}
+
+# If a fn is unknown to Tcl, we try to execute it as an OpenOCD command
+proc unknown {args} {
+
+ # This is uglier than it needs to be since the "flash banks" is really
+ # a single command. For now only "flash banks" has been converted from
+ # C to Tcl as an example, but if we do decide to go down this path, then
+ # some more generic scheme will be put in place here.
+ #
+ # Help texts need a makeover. There needs to be help texts for
+ # tcl procs + perhaps some work w.r.t. making the help command
+ # format things prettier.
+ if {[string compare [lindex $args 0] flash]==0 && [string compare [lindex $args 1] banks]==0} {
+ return [flash_banks_pretty]
+ }
+
+ # We print out as we run the command
+ if {[string length $args]>0} {
+ openocd_throw "$args"
+ }
+ # The primary return value have been set by "openocd" above,
+ # so we need to clear it, lest we print out the output from
+ # the command twice.
+ return ""
+}