This is an automated email from Gerrit.

Paul Fertser (fercer...@gmail.com) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/2492

-- gerrit

commit f56e748b6cdc897c07785b43d77455d97218fa65
Author: Paul Fertser <fercer...@gmail.com>
Date:   Fri Jan 23 11:38:31 2015 +0300

    flash/startup: extend "program" command to accept "dontexit"
    
    This optional argument tells OpenOCD to stay running after finishing
    (either succesfully, or with an error) the programming sequence. It
    can be useful when flashing is controlled via Telnet or RPC to avoid
    restarting OpenOCD.
    
    Change-Id: I6ecaf33ff985eea9a9cd02ff644a74403ae3e1e5
    Signed-off-by: Paul Fertser <fercer...@gmail.com>

diff --git a/doc/openocd.texi b/doc/openocd.texi
index c5975c9..0962d56 100644
--- a/doc/openocd.texi
+++ b/doc/openocd.texi
@@ -4911,7 +4911,7 @@ comamnd or the flash driver then it defaults to 0xff.
 @end deffn
 
 @anchor{program}
-@deffn Command {program} filename [verify] [reset] [offset]
+@deffn Command {program} filename [verify] [reset] [dontexit] [offset]
 This is a helper script that simplifies using OpenOCD as a standalone
 programmer. The only required parameter is @option{filename}, the others are 
optional.
 @xref{Flash Programming}.
diff --git a/src/flash/startup.tcl b/src/flash/startup.tcl
index b8d280b..cffc536 100644
--- a/src/flash/startup.tcl
+++ b/src/flash/startup.tcl
@@ -3,16 +3,27 @@
 #
 # program utility proc
 # usage: program filename
-# optional args: verify, reset and address
+# optional args: verify, reset, dontexit and address
 #
 
+proc program_error {description dontexit} {
+       if {$dontexit == 0} {
+               shutdown
+       }
+
+       error $description
+}
+
 proc program {filename args} {
+       set dontexit 0
 
        foreach arg $args {
                if {[string equal $arg "verify"]} {
                        set verify 1
                } elseif {[string equal $arg "reset"]} {
                        set reset 1
+               } elseif {[string equal $arg "dontexit"]} {
+                       set dontexit 1
                } else {
                        set address $arg
                }
@@ -20,16 +31,12 @@ proc program {filename args} {
 
        # make sure init is called
        if {[catch {init}] != 0} {
-               echo "** OpenOCD init Failed **"
-               shutdown
-               return
+               program_error "** OpenOCD init failed **" 0
        }
 
        # reset target and call any init scripts
        if {[catch {reset init}] != 0} {
-               echo "** Unable to reset target **"
-               shutdown
-               return
+               program_error "** Unable to reset target **" $dontexit
        }
 
        # start programming phase
@@ -48,7 +55,7 @@ proc program {filename args} {
                        if {[catch {eval verify_image $flash_args}] == 0} {
                                echo "** Verified OK **"
                        } else {
-                               echo "** Verify Failed **"
+                               program_error "** Verify Failed **" $dontexit
                        }
                }
 
@@ -60,15 +67,17 @@ proc program {filename args} {
                        reset run
                }
        } else {
-               echo "** Programming Failed **"
+               program_error "** Programming Failed **" $dontexit
        }
 
-       # shutdown OpenOCD
-       shutdown
+       if {$dontexit == 0} {
+               shutdown
+       }
+       return
 }
 
-add_help_text program "write an image to flash, address is only required for 
binary images. verify, reset are optional"
-add_usage_text program "<filename> \[address\] \[verify\] \[reset\]"
+add_help_text program "write an image to flash, address is only required for 
binary images. verify, reset, dontexit are optional"
+add_usage_text program "<filename> \[address\] \[verify\] \[reset\] 
\[dontexit\]"
 
 # stm32f0x uses the same flash driver as the stm32f1x
 # this alias enables the use of either name.

-- 

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to