2012-01-03 21:42:49 +00:00
|
|
|
# script for stm32f1x family
|
2008-07-04 17:33:46 +00:00
|
|
|
|
2013-08-06 12:12:10 +00:00
|
|
|
#
|
|
|
|
# stm32 devices support both JTAG and SWD transports.
|
|
|
|
#
|
|
|
|
source [find target/swj-dp.tcl]
|
2015-02-09 14:04:52 +00:00
|
|
|
source [find mem_helper.tcl]
|
2013-08-06 12:12:10 +00:00
|
|
|
|
2009-09-21 18:48:22 +00:00
|
|
|
if { [info exists CHIPNAME] } {
|
2011-10-29 21:32:17 +00:00
|
|
|
set _CHIPNAME $CHIPNAME
|
2009-09-21 18:48:22 +00:00
|
|
|
} else {
|
2012-01-03 21:42:49 +00:00
|
|
|
set _CHIPNAME stm32f1x
|
2008-11-30 22:25:43 +00:00
|
|
|
}
|
|
|
|
|
2014-12-09 13:06:21 +00:00
|
|
|
set _ENDIAN little
|
2008-11-30 22:25:43 +00:00
|
|
|
|
2009-06-30 11:50:04 +00:00
|
|
|
# Work-area is a space in RAM used for flash programming
|
2013-05-04 21:09:15 +00:00
|
|
|
# By default use 4kB (as found on some STM32F100s)
|
2009-06-29 22:08:34 +00:00
|
|
|
if { [info exists WORKAREASIZE] } {
|
2011-10-29 21:32:17 +00:00
|
|
|
set _WORKAREASIZE $WORKAREASIZE
|
2009-06-29 22:08:34 +00:00
|
|
|
} else {
|
2013-05-04 21:09:15 +00:00
|
|
|
set _WORKAREASIZE 0x1000
|
2009-06-29 22:08:34 +00:00
|
|
|
}
|
|
|
|
|
2008-03-09 09:28:12 +00:00
|
|
|
#jtag scan chain
|
2011-10-29 21:32:17 +00:00
|
|
|
if { [info exists CPUTAPID] } {
|
2008-11-30 22:25:43 +00:00
|
|
|
set _CPUTAPID $CPUTAPID
|
|
|
|
} else {
|
2013-09-28 10:23:15 +00:00
|
|
|
if { [using_jtag] } {
|
|
|
|
# See STM Document RM0008 Section 26.6.3
|
|
|
|
set _CPUTAPID 0x3ba00477
|
|
|
|
} {
|
|
|
|
# this is the SW-DP tap id not the jtag tap id
|
|
|
|
set _CPUTAPID 0x1ba01477
|
|
|
|
}
|
2008-11-30 22:25:43 +00:00
|
|
|
}
|
2013-08-06 12:12:10 +00:00
|
|
|
|
|
|
|
swj_newdap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
|
2008-11-30 22:25:43 +00:00
|
|
|
|
2011-10-29 21:32:17 +00:00
|
|
|
if { [info exists BSTAPID] } {
|
2009-11-01 10:58:48 +00:00
|
|
|
# FIXME this never gets used to override defaults...
|
2008-11-30 22:25:43 +00:00
|
|
|
set _BSTAPID $BSTAPID
|
|
|
|
} else {
|
|
|
|
# See STM Document RM0008
|
2009-11-01 10:58:48 +00:00
|
|
|
# Section 29.6.2
|
2009-04-02 21:17:27 +00:00
|
|
|
# Low density devices, Rev A
|
2009-04-23 14:03:42 +00:00
|
|
|
set _BSTAPID1 0x06412041
|
2009-04-02 21:17:27 +00:00
|
|
|
# Medium density devices, Rev A
|
2009-04-23 14:03:42 +00:00
|
|
|
set _BSTAPID2 0x06410041
|
2009-04-02 21:17:27 +00:00
|
|
|
# Medium density devices, Rev B and Rev Z
|
2009-04-23 14:03:42 +00:00
|
|
|
set _BSTAPID3 0x16410041
|
2011-02-17 20:51:32 +00:00
|
|
|
set _BSTAPID4 0x06420041
|
2009-04-02 21:17:27 +00:00
|
|
|
# High density devices, Rev A
|
2011-02-17 20:51:32 +00:00
|
|
|
set _BSTAPID5 0x06414041
|
2009-07-01 10:29:10 +00:00
|
|
|
# Connectivity line devices, Rev A and Rev Z
|
2011-02-17 20:51:32 +00:00
|
|
|
set _BSTAPID6 0x06418041
|
2010-12-22 17:20:11 +00:00
|
|
|
# XL line devices, Rev A
|
2011-02-17 20:51:32 +00:00
|
|
|
set _BSTAPID7 0x06430041
|
2011-08-24 20:13:35 +00:00
|
|
|
# VL line devices, Rev A and Z In medium-density and high-density value line devices
|
|
|
|
set _BSTAPID8 0x06420041
|
|
|
|
# VL line devices, Rev A
|
|
|
|
set _BSTAPID9 0x06428041
|
2009-09-21 18:48:22 +00:00
|
|
|
}
|
2013-08-06 12:12:10 +00:00
|
|
|
|
2014-03-01 18:40:54 +00:00
|
|
|
if {[using_jtag]} {
|
2013-09-28 10:23:15 +00:00
|
|
|
swj_newdap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID1 \
|
2009-11-01 10:58:48 +00:00
|
|
|
-expected-id $_BSTAPID2 -expected-id $_BSTAPID3 \
|
2010-12-22 17:20:11 +00:00
|
|
|
-expected-id $_BSTAPID4 -expected-id $_BSTAPID5 \
|
2011-08-24 20:13:35 +00:00
|
|
|
-expected-id $_BSTAPID6 -expected-id $_BSTAPID7 \
|
|
|
|
-expected-id $_BSTAPID8 -expected-id $_BSTAPID9
|
2013-08-06 12:12:10 +00:00
|
|
|
}
|
2008-11-30 22:25:43 +00:00
|
|
|
|
2009-09-04 05:17:03 +00:00
|
|
|
set _TARGETNAME $_CHIPNAME.cpu
|
2013-02-01 15:34:51 +00:00
|
|
|
target create $_TARGETNAME cortex_m -endian $_ENDIAN -chain-position $_TARGETNAME
|
2008-11-30 22:25:43 +00:00
|
|
|
|
2009-11-08 16:52:40 +00:00
|
|
|
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
|
2008-07-28 06:08:05 +00:00
|
|
|
|
2010-12-22 17:20:11 +00:00
|
|
|
# flash size will be probed
|
2009-11-18 10:15:52 +00:00
|
|
|
set _FLASHNAME $_CHIPNAME.flash
|
2011-07-28 10:45:09 +00:00
|
|
|
flash bank $_FLASHNAME stm32f1x 0x08000000 0 0 0 $_TARGETNAME
|
2010-12-02 13:12:48 +00:00
|
|
|
|
2013-08-06 12:12:10 +00:00
|
|
|
# JTAG speed should be <= F_CPU/6. F_CPU after reset is 8MHz, so use F_JTAG = 1MHz
|
|
|
|
adapter_khz 1000
|
|
|
|
|
|
|
|
adapter_nsrst_delay 100
|
2014-03-01 18:40:54 +00:00
|
|
|
if {[using_jtag]} {
|
2013-08-06 12:12:10 +00:00
|
|
|
jtag_ntrst_delay 100
|
|
|
|
}
|
|
|
|
|
2015-01-10 10:19:26 +00:00
|
|
|
reset_config srst_nogate
|
|
|
|
|
2013-09-28 10:23:15 +00:00
|
|
|
if {![using_hla]} {
|
|
|
|
# if srst is not fitted use SYSRESETREQ to
|
|
|
|
# perform a soft reset
|
|
|
|
cortex_m reset_config sysresetreq
|
|
|
|
}
|
2015-02-09 14:04:52 +00:00
|
|
|
|
|
|
|
$_TARGETNAME configure -event examine-end {
|
|
|
|
# DBGMCU_CR |= DBG_WWDG_STOP | DBG_IWDG_STOP |
|
|
|
|
# DBG_STANDBY | DBG_STOP | DBG_SLEEP
|
|
|
|
mmw 0xE0042004 0x00000307 0
|
|
|
|
}
|
|
|
|
|
|
|
|
$_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
|
|
|
|
}
|