stm32.cfg 1.75 KB
Newer Older
ntfreak's avatar
ntfreak committed
1
2
# script for stm32

3
4
5
if { [info exists CHIPNAME] } {
   set  _CHIPNAME $CHIPNAME
} else {
6
7
8
   set  _CHIPNAME stm32
}

9
10
11
if { [info exists ENDIAN] } {
   set  _ENDIAN $ENDIAN
} else {
12
13
14
   set  _ENDIAN little
}

15
16
# Work-area is a space in RAM used for flash programming
# By default use 16kB
17
18
19
20
21
22
if { [info exists WORKAREASIZE] } {
   set  _WORKAREASIZE $WORKAREASIZE
} else {
   set  _WORKAREASIZE 0x4000
}

23
24
# JTAG speed should be <= F_CPU/6. F_CPU after reset is 8MHz, so use F_JTAG = 1MHz
jtag_khz 1000
ntfreak's avatar
ntfreak committed
25

ntfreak's avatar
ntfreak committed
26
27
28
29
jtag_nsrst_delay 100
jtag_ntrst_delay 100

#jtag scan chain
30
31
32
33
34
35
36
37
38
39
if { [info exists CPUTAPID ] } {
   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

if { [info exists BSTAPID ] } {
40
   # FIXME this never gets used to override defaults...
41
42
43
   set _BSTAPID $BSTAPID
} else {
  # See STM Document RM0008
44
  # Section 29.6.2
45
  # Low density devices, Rev A
46
  set _BSTAPID1 0x06412041
47
  # Medium density devices, Rev A
48
  set _BSTAPID2 0x06410041
49
  # Medium density devices, Rev B and Rev Z
50
  set _BSTAPID3 0x16410041
51
  # High density devices, Rev A
52
  set _BSTAPID4 0x06414041
53
54
  # Connectivity line devices, Rev A and Rev Z
  set _BSTAPID5 0x06418041
55
}
56
57
58
jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID1 \
	-expected-id $_BSTAPID2 -expected-id $_BSTAPID3 \
	-expected-id $_BSTAPID4 -expected-id $_BSTAPID5
59

60
set _TARGETNAME $_CHIPNAME.cpu
61
62
target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME

63
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
oharboe's avatar
oharboe committed
64

65
flash bank stm32x 0 0 0 0 $_TARGETNAME
ntfreak's avatar
ntfreak committed
66
67

# For more information about the configuration files, take a look at:
68
# openocd.texi