tcl/target: add SPDX tag
[fw/openocd] / tcl / target / at91sam3XXX.cfg
1 # SPDX-License-Identifier: GPL-2.0-or-later
2
3 # script for ATMEL sam3, a Cortex-M3 chip
4 #
5 # at91sam3u4e
6 # at91sam3u2e
7 # at91sam3u1e
8 # at91sam3u4c
9 # at91sam3u2c
10 # at91sam3u1c
11 #
12 # at91sam3s4c
13 # at91sam3s4b
14 # at91sam3s4a
15 # at91sam3s2c
16 # at91sam3s2b
17 # at91sam3s2a
18 # at91sam3s1c
19 # at91sam3s1b
20 # at91sam3s1a
21 #
22 # at91sam3A4C
23 # at91sam3A8C
24 # at91sam3X4C
25 # at91sam3X4E
26 # at91sam3X8C
27 # at91sam3X8E
28 # at91sam3X8H
29
30 source [find target/swj-dp.tcl]
31
32 if { [info exists CHIPNAME] } {
33    set _CHIPNAME $CHIPNAME
34 } else {
35    set _CHIPNAME sam3
36 }
37
38 if { [info exists ENDIAN] } {
39    set _ENDIAN $ENDIAN
40 } else {
41    set _ENDIAN little
42 }
43
44 # Work-area is a space in RAM used for flash programming
45 # By default use 64kB
46 if { [info exists WORKAREASIZE] } {
47    set _WORKAREASIZE $WORKAREASIZE
48 } else {
49    set _WORKAREASIZE 0x4000
50 }
51
52 #jtag scan chain
53 if { [info exists CPUTAPID] } {
54    set _CPUTAPID $CPUTAPID
55 } else {
56    set _CPUTAPID 0x4ba00477
57 }
58
59 swj_newdap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
60 dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
61
62 set _TARGETNAME $_CHIPNAME.cpu
63 target create $_TARGETNAME cortex_m -endian $_ENDIAN -dap $_CHIPNAME.dap
64
65 # 16K is plenty, the smallest chip has this much
66 $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
67
68 $_TARGETNAME configure -event gdb-flash-erase-start {
69     halt
70 }
71
72 # JTAG speed should be <= F_CPU/6. F_CPU after reset is 4 MHz, so use F_JTAG = 0.5MHz
73 #
74 # Since we may be running of an RC oscilator, we crank down the speed a
75 # bit more to be on the safe side. Perhaps superstition, but if are
76 # running off a crystal, we can run closer to the limit. Note
77 # that there can be a pretty wide band where things are more or less stable.
78
79 adapter speed 500
80
81 adapter srst delay 100
82 if {[using_jtag]} {
83    jtag_ntrst_delay 100
84 }
85
86 if {![using_hla]} {
87    # if srst is not fitted use SYSRESETREQ to
88    # perform a soft reset
89    cortex_m reset_config sysresetreq
90 }