1 # Defines basic Tcl procs for OpenOCD flash module
5 # usage: program filename
6 # optional args: verify, reset, exit and address
9 proc program_error {description exit} {
18 proc program {filename args} {
22 if {[string equal $arg "verify"]} {
24 } elseif {[string equal $arg "reset"]} {
26 } elseif {[string equal $arg "exit"]} {
33 # make sure init is called
34 if {[catch {init}] != 0} {
35 program_error "** OpenOCD init failed **" 1
38 # reset target and call any init scripts
39 if {[catch {reset init}] != 0} {
40 program_error "** Unable to reset target **" $exit
43 # start programming phase
44 echo "** Programming Started **"
45 if {[info exists address]} {
46 set flash_args "$filename $address"
48 set flash_args "$filename"
51 if {[catch {eval flash write_image erase $flash_args}] == 0} {
52 echo "** Programming Finished **"
53 if {[info exists verify]} {
55 echo "** Verify Started **"
56 if {[catch {eval verify_image $flash_args}] == 0} {
57 echo "** Verified OK **"
59 program_error "** Verify Failed **" $exit
63 if {[info exists reset]} {
64 # reset target if requested
65 # also disable target polling, we are shutting down anyway
67 echo "** Resetting Target **"
71 program_error "** Programming Failed **" $exit
80 add_help_text program "write an image to flash, address is only required for binary images. verify, reset, exit are optional"
81 add_usage_text program "<filename> \[address\] \[verify\] \[reset\] \[exit\]"
83 # stm32f0x uses the same flash driver as the stm32f1x
84 # this alias enables the use of either name.
89 # stm32f3x uses the same flash driver as the stm32f1x
90 # this alias enables the use of either name.
95 # stm32f4x uses the same flash driver as the stm32f2x
96 # this alias enables the use of either name.
101 # ease migration to updated flash driver
103 echo "DEPRECATED! use 'stm32f1x $args' not 'stm32x $args'"
107 proc stm32f2xxx args {
108 echo "DEPRECATED! use 'stm32f2x $args' not 'stm32f2xxx $args'"