2012-01-03 15:42:49 -06:00
|
|
|
# script for stm32f1x family
|
2008-07-04 12:33:46 -05:00
|
|
|
|
2009-09-21 13:48:22 -05:00
|
|
|
if { [info exists CHIPNAME] } {
|
2011-10-29 16:32:17 -05:00
|
|
|
set _CHIPNAME $CHIPNAME
|
2009-09-21 13:48:22 -05:00
|
|
|
} else {
|
2012-01-03 15:42:49 -06:00
|
|
|
set _CHIPNAME stm32f1x
|
2008-11-30 16:25:43 -06:00
|
|
|
}
|
|
|
|
|
2009-09-21 13:48:22 -05:00
|
|
|
if { [info exists ENDIAN] } {
|
2011-10-29 16:32:17 -05:00
|
|
|
set _ENDIAN $ENDIAN
|
2009-09-21 13:48:22 -05:00
|
|
|
} else {
|
2011-10-29 16:32:17 -05:00
|
|
|
set _ENDIAN little
|
2008-11-30 16:25:43 -06:00
|
|
|
}
|
|
|
|
|
2009-06-30 06:50:04 -05:00
|
|
|
# Work-area is a space in RAM used for flash programming
|
|
|
|
# By default use 16kB
|
2009-06-29 17:08:34 -05:00
|
|
|
if { [info exists WORKAREASIZE] } {
|
2011-10-29 16:32:17 -05:00
|
|
|
set _WORKAREASIZE $WORKAREASIZE
|
2009-06-29 17:08:34 -05:00
|
|
|
} else {
|
2011-10-29 16:32:17 -05:00
|
|
|
set _WORKAREASIZE 0x4000
|
2009-06-29 17:08:34 -05:00
|
|
|
}
|
|
|
|
|
2009-06-30 06:50:04 -05:00
|
|
|
# JTAG speed should be <= F_CPU/6. F_CPU after reset is 8MHz, so use F_JTAG = 1MHz
|
2010-03-15 10:37:43 -05:00
|
|
|
adapter_khz 1000
|
2008-07-04 12:33:46 -05:00
|
|
|
|
2010-03-15 10:41:30 -05:00
|
|
|
adapter_nsrst_delay 100
|
2008-03-09 04:28:12 -05:00
|
|
|
jtag_ntrst_delay 100
|
|
|
|
|
|
|
|
#jtag scan chain
|
2011-10-29 16:32:17 -05:00
|
|
|
if { [info exists CPUTAPID] } {
|
2008-11-30 16:25:43 -06:00
|
|
|
set _CPUTAPID $CPUTAPID
|
|
|
|
} else {
|
|
|
|
# See STM Document RM0008
|
|
|
|
# Section 26.6.3
|
|
|
|
set _CPUTAPID 0x3ba00477
|
|
|
|
}
|
|
|
|
jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
|
|
|
|
|
2011-10-29 16:32:17 -05:00
|
|
|
if { [info exists BSTAPID] } {
|
2009-11-01 04:58:48 -06:00
|
|
|
# FIXME this never gets used to override defaults...
|
2008-11-30 16:25:43 -06:00
|
|
|
set _BSTAPID $BSTAPID
|
|
|
|
} else {
|
|
|
|
# See STM Document RM0008
|
2009-11-01 04:58:48 -06:00
|
|
|
# Section 29.6.2
|
2009-04-02 16:17:27 -05:00
|
|
|
# Low density devices, Rev A
|
2009-04-23 09:03:42 -05:00
|
|
|
set _BSTAPID1 0x06412041
|
2009-04-02 16:17:27 -05:00
|
|
|
# Medium density devices, Rev A
|
2009-04-23 09:03:42 -05:00
|
|
|
set _BSTAPID2 0x06410041
|
2009-04-02 16:17:27 -05:00
|
|
|
# Medium density devices, Rev B and Rev Z
|
2009-04-23 09:03:42 -05:00
|
|
|
set _BSTAPID3 0x16410041
|
2011-02-17 14:51:32 -06:00
|
|
|
set _BSTAPID4 0x06420041
|
2009-04-02 16:17:27 -05:00
|
|
|
# High density devices, Rev A
|
2011-02-17 14:51:32 -06:00
|
|
|
set _BSTAPID5 0x06414041
|
2009-07-01 05:29:10 -05:00
|
|
|
# Connectivity line devices, Rev A and Rev Z
|
2011-02-17 14:51:32 -06:00
|
|
|
set _BSTAPID6 0x06418041
|
2010-12-22 11:20:11 -06:00
|
|
|
# XL line devices, Rev A
|
2011-02-17 14:51:32 -06:00
|
|
|
set _BSTAPID7 0x06430041
|
2011-08-24 15:13:35 -05: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 13:48:22 -05:00
|
|
|
}
|
2009-11-01 04:58:48 -06:00
|
|
|
jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID1 \
|
|
|
|
-expected-id $_BSTAPID2 -expected-id $_BSTAPID3 \
|
2010-12-22 11:20:11 -06:00
|
|
|
-expected-id $_BSTAPID4 -expected-id $_BSTAPID5 \
|
2011-08-24 15:13:35 -05:00
|
|
|
-expected-id $_BSTAPID6 -expected-id $_BSTAPID7 \
|
|
|
|
-expected-id $_BSTAPID8 -expected-id $_BSTAPID9
|
2008-11-30 16:25:43 -06:00
|
|
|
|
2009-09-04 00:17:03 -05:00
|
|
|
set _TARGETNAME $_CHIPNAME.cpu
|
2008-11-30 16:25:43 -06:00
|
|
|
target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
|
|
|
|
|
2009-11-08 10:52:40 -06:00
|
|
|
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
|
2008-07-28 01:08:05 -05:00
|
|
|
|
2010-12-22 11:20:11 -06:00
|
|
|
# flash size will be probed
|
2009-11-18 04:15:52 -06:00
|
|
|
set _FLASHNAME $_CHIPNAME.flash
|
2011-07-28 05:45:09 -05:00
|
|
|
flash bank $_FLASHNAME stm32f1x 0x08000000 0 0 0 $_TARGETNAME
|
2010-12-02 07:12:48 -06:00
|
|
|
|
|
|
|
# if srst is not fitted use SYSRESETREQ to
|
|
|
|
# perform a soft reset
|
|
|
|
cortex_m3 reset_config sysresetreq
|