1 # Defines basic Tcl procs for OpenOCD flash module
5 # usage: program filename
6 # optional args: verify, reset and address
9 proc program
{filename args
} {
12 if {[string equal
$arg "verify"]} {
14 } elseif
{[string equal
$arg "reset"]} {
21 # make sure init is called
22 if {[catch {init
}] != 0} {
23 echo
"** OpenOCD init Failed **"
28 # reset target and call any init scripts
29 if {[catch {reset init
}] != 0} {
30 echo
"** Unable to reset target **"
35 # start programming phase
36 echo
"** Programming Started **"
37 if {[info exists address
]} {
38 set flash_args
"$filename $address"
40 set flash_args
"$filename"
43 if {[catch {eval flash write_image erase
$flash_args}] == 0} {
44 echo
"** Programming Finished **"
45 if {[info exists verify
]} {
47 echo
"** Verify Started **"
48 if {[catch {eval verify_image
$flash_args}] == 0} {
49 echo
"** Verified OK **"
51 echo
"** Verify Failed **"
55 if {[info exists reset
]} {
56 # reset target if requested
57 # also disable target polling, we are shutting down anyway
59 echo
"** Resetting Target **"
63 echo
"** Programming Failed **"
70 add_help_text program
"write an image to flash, address is only required for binary images. verify, reset are optional"
71 add_usage_text program
"<filename> \[address\] \[verify\] \[reset\]"
73 # stm32f0x uses the same flash driver as the stm32f1x
74 # this alias enables the use of either name.
79 # stm32f3x uses the same flash driver as the stm32f1x
80 # this alias enables the use of either name.
85 # stm32f4x uses the same flash driver as the stm32f2x
86 # this alias enables the use of either name.
91 # ease migration to updated flash driver
93 echo
"DEPRECATED! use 'stm32f1x $args' not 'stm32x $args'"
97 proc stm32f2xxx args
{
98 echo
"DEPRECATED! use 'stm32f2x $args' not 'stm32f2xxx $args'"