cfg: add stm32 flash driver alias
[openocd.git] / src / flash / startup.tcl
blobb8d280b8e75fb97e100da4c4f0ca19746720a602
1 # Defines basic Tcl procs for OpenOCD flash module
4 # program utility proc
5 # usage: program filename
6 # optional args: verify, reset and address
9 proc program {filename args} {
11 foreach arg $args {
12 if {[string equal $arg "verify"]} {
13 set verify 1
14 } elseif {[string equal $arg "reset"]} {
15 set reset 1
16 } else {
17 set address $arg
21 # make sure init is called
22 if {[catch {init}] != 0} {
23 echo "** OpenOCD init Failed **"
24 shutdown
25 return
28 # reset target and call any init scripts
29 if {[catch {reset init}] != 0} {
30 echo "** Unable to reset target **"
31 shutdown
32 return
35 # start programming phase
36 echo "** Programming Started **"
37 if {[info exists address]} {
38 set flash_args "$filename $address"
39 } else {
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]} {
46 # verify phase
47 echo "** Verify Started **"
48 if {[catch {eval verify_image $flash_args}] == 0} {
49 echo "** Verified OK **"
50 } else {
51 echo "** Verify Failed **"
55 if {[info exists reset]} {
56 # reset target if requested
57 # also disable target polling, we are shutting down anyway
58 poll off
59 echo "** Resetting Target **"
60 reset run
62 } else {
63 echo "** Programming Failed **"
66 # shutdown OpenOCD
67 shutdown
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.
75 proc stm32f0x args {
76 eval stm32f1x $args
79 # stm32f3x uses the same flash driver as the stm32f1x
80 # this alias enables the use of either name.
81 proc stm32f3x args {
82 eval stm32f1x $args
85 # stm32f4x uses the same flash driver as the stm32f2x
86 # this alias enables the use of either name.
87 proc stm32f4x args {
88 eval stm32f2x $args
91 # ease migration to updated flash driver
92 proc stm32x args {
93 echo "DEPRECATED! use 'stm32f1x $args' not 'stm32x $args'"
94 eval stm32f1x $args
97 proc stm32f2xxx args {
98 echo "DEPRECATED! use 'stm32f2x $args' not 'stm32f2xxx $args'"
99 eval stm32f2x $args