2012-01-03 15:42:49 -06:00
|
|
|
# script for stm32f2x family
|
2011-06-06 04:51:38 -05:00
|
|
|
|
2013-08-06 07:12:10 -05:00
|
|
|
#
|
|
|
|
# stm32 devices support both JTAG and SWD transports.
|
|
|
|
#
|
|
|
|
source [find target/swj-dp.tcl]
|
2015-02-09 08:04:52 -06:00
|
|
|
source [find mem_helper.tcl]
|
2013-08-06 07:12:10 -05:00
|
|
|
|
2011-06-06 04:51:38 -05:00
|
|
|
if { [info exists CHIPNAME] } {
|
2011-10-29 16:32:17 -05:00
|
|
|
set _CHIPNAME $CHIPNAME
|
2011-06-06 04:51:38 -05:00
|
|
|
} else {
|
2012-01-03 15:42:49 -06:00
|
|
|
set _CHIPNAME stm32f2x
|
2011-06-06 04:51:38 -05:00
|
|
|
}
|
|
|
|
|
2014-12-09 07:06:21 -06:00
|
|
|
set _ENDIAN little
|
2011-06-06 04:51:38 -05:00
|
|
|
|
|
|
|
# Work-area is a space in RAM used for flash programming
|
|
|
|
# By default use 64kB
|
|
|
|
if { [info exists WORKAREASIZE] } {
|
2011-10-29 16:32:17 -05:00
|
|
|
set _WORKAREASIZE $WORKAREASIZE
|
2011-06-06 04:51:38 -05:00
|
|
|
} else {
|
2011-10-29 16:32:17 -05:00
|
|
|
set _WORKAREASIZE 0x10000
|
2011-06-06 04:51:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# JTAG speed should be <= F_CPU/6. F_CPU after reset is 8MHz, so use F_JTAG = 1MHz
|
2011-07-15 05:05:37 -05:00
|
|
|
#
|
|
|
|
# Since we may be running of an RC oscilator, we crank down the speed a
|
|
|
|
# bit more to be on the safe side. Perhaps superstition, but if are
|
|
|
|
# running off a crystal, we can run closer to the limit. Note
|
|
|
|
# that there can be a pretty wide band where things are more or less stable.
|
2019-08-23 08:51:00 -05:00
|
|
|
adapter speed 1000
|
2011-06-06 04:51:38 -05:00
|
|
|
|
2019-08-23 08:51:00 -05:00
|
|
|
adapter srst delay 100
|
2014-03-01 12:40:54 -06:00
|
|
|
if {[using_jtag]} {
|
2013-08-06 07:12:10 -05:00
|
|
|
jtag_ntrst_delay 100
|
|
|
|
}
|
2011-06-06 04:51:38 -05:00
|
|
|
|
|
|
|
#jtag scan chain
|
2011-10-29 16:32:17 -05:00
|
|
|
if { [info exists CPUTAPID] } {
|
2011-06-06 04:51:38 -05:00
|
|
|
set _CPUTAPID $CPUTAPID
|
|
|
|
} else {
|
2013-09-28 05:23:15 -05:00
|
|
|
if { [using_jtag] } {
|
|
|
|
# See STM Document RM0033
|
|
|
|
# Section 32.6.3 - corresponds to Cortex-M3 r2p0
|
|
|
|
set _CPUTAPID 0x4ba00477
|
|
|
|
} {
|
|
|
|
set _CPUTAPID 0x2ba01477
|
|
|
|
}
|
2011-06-06 04:51:38 -05:00
|
|
|
}
|
2013-08-06 07:12:10 -05:00
|
|
|
|
|
|
|
swj_newdap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
|
2018-03-23 15:17:29 -05:00
|
|
|
dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
|
2011-06-06 04:51:38 -05:00
|
|
|
|
2014-03-01 12:40:54 -06:00
|
|
|
if {[using_jtag]} {
|
2016-03-11 15:16:04 -06:00
|
|
|
jtag newtap $_CHIPNAME bs -irlen 5
|
2013-08-06 07:12:10 -05:00
|
|
|
}
|
2011-06-06 04:51:38 -05:00
|
|
|
|
|
|
|
set _TARGETNAME $_CHIPNAME.cpu
|
2018-03-23 15:17:29 -05:00
|
|
|
target create $_TARGETNAME cortex_m -endian $_ENDIAN -dap $_CHIPNAME.dap
|
2011-06-06 04:51:38 -05:00
|
|
|
|
|
|
|
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
|
|
|
|
|
|
|
|
set _FLASHNAME $_CHIPNAME.flash
|
2011-07-28 05:45:09 -05:00
|
|
|
flash bank $_FLASHNAME stm32f2x 0 0 0 0 $_TARGETNAME
|
2019-01-21 11:24:12 -06:00
|
|
|
flash bank $_CHIPNAME.otp stm32f2x 0x1fff7800 0 0 0 $_TARGETNAME
|
2011-06-06 04:51:38 -05:00
|
|
|
|
2015-01-10 04:19:26 -06:00
|
|
|
reset_config srst_nogate
|
|
|
|
|
2013-09-28 05:23:15 -05:00
|
|
|
if {![using_hla]} {
|
|
|
|
# if srst is not fitted use SYSRESETREQ to
|
|
|
|
# perform a soft reset
|
|
|
|
cortex_m reset_config sysresetreq
|
|
|
|
}
|
2015-02-09 08:04:52 -06:00
|
|
|
|
|
|
|
$_TARGETNAME configure -event examine-end {
|
|
|
|
# DBGMCU_CR |= DBG_STANDBY | DBG_STOP | DBG_SLEEP
|
|
|
|
mmw 0xE0042004 0x00000007 0
|
|
|
|
|
|
|
|
# Stop watchdog counters during halt
|
2015-11-11 05:54:19 -06:00
|
|
|
# DBGMCU_APB1_FZ |= DBG_IWDG_STOP | DBG_WWDG_STOP
|
|
|
|
mmw 0xE0042008 0x00001800 0
|
2015-02-09 08:04:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
$_TARGETNAME configure -event trace-config {
|
|
|
|
# Set TRACE_IOEN; TRACE_MODE is set to async; when using sync
|
|
|
|
# change this value accordingly to configure trace pins
|
|
|
|
# assignment
|
|
|
|
mmw 0xE0042004 0x00000020 0
|
|
|
|
}
|