tcl/target: add SPDX tag
[fw/openocd] / tcl / target / nrf51.cfg
1 # SPDX-License-Identifier: GPL-2.0-or-later
2
3 #
4 # script for Nordic nRF51 series, a Cortex-M0 chip
5 #
6
7 source [find target/swj-dp.tcl]
8
9 if { [info exists CHIPNAME] } {
10    set _CHIPNAME $CHIPNAME
11 } else {
12    set _CHIPNAME nrf51
13 }
14
15 if { [info exists ENDIAN] } {
16    set _ENDIAN $ENDIAN
17 } else {
18    set _ENDIAN little
19 }
20
21 # Work-area is a space in RAM used for flash programming
22 # By default use 16kB
23 if { [info exists WORKAREASIZE] } {
24    set _WORKAREASIZE $WORKAREASIZE
25 } else {
26    set _WORKAREASIZE 0x4000
27 }
28
29 if { [info exists CPUTAPID] } {
30    set _CPUTAPID $CPUTAPID
31 } else {
32    set _CPUTAPID 0x0bb11477
33 }
34
35 swj_newdap $_CHIPNAME cpu -expected-id $_CPUTAPID
36 dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
37
38 set _TARGETNAME $_CHIPNAME.cpu
39 target create $_TARGETNAME cortex_m -dap $_CHIPNAME.dap
40
41 $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
42
43 if {![using_hla]} {
44    # The chip supports standard ARM/Cortex-M0 SYSRESETREQ signal
45    cortex_m reset_config sysresetreq
46 }
47
48 flash bank $_CHIPNAME.flash nrf51 0x00000000 0 1 1 $_TARGETNAME
49 flash bank $_CHIPNAME.uicr nrf51 0x10001000 0 1 1 $_TARGETNAME
50
51 #
52 #  The chip should start up from internal 16Mhz RC, so setting adapter
53 #  clock to 1Mhz should be OK
54 #
55 adapter speed 1000
56
57 proc enable_all_ram {} {
58         # nRF51822 Product Anomaly Notice (PAN) #16 explains that not all RAM banks
59         # are reliably enabled after reset on some revisions (contrary to spec.) So after
60         # resetting we enable all banks via the RAMON register
61         mww 0x40000524 0xF
62 }
63 $_TARGETNAME configure -event reset-end {  enable_all_ram }