This is an automated email from Gerrit. Luca BRUNO ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/5384
-- gerrit commit 565febbb27b92a87f3f1ab525d23bbd0850e11da Author: Luca BRUNO <[email protected]> Date: Thu Dec 26 10:47:20 2019 +0000 target/nrf52: add AP-protection helpers This commit adds helpers for inspecting and manipulating debug access port protection status on nrf52 chips. Change-Id: Id2b00253ce5bf3c05403da6f0af4605f4914ff05 Signed-off-by: Luca BRUNO <[email protected]> diff --git a/tcl/target/nrf52.cfg b/tcl/target/nrf52.cfg index c29adbd..61e3885 100644 --- a/tcl/target/nrf52.cfg +++ b/tcl/target/nrf52.cfg @@ -40,3 +40,49 @@ if { ![using_hla] } { flash bank $_CHIPNAME.flash nrf5 0x00000000 0 1 1 $_TARGETNAME flash bank $_CHIPNAME.uicr nrf5 0x10001000 0 1 1 $_TARGETNAME + +# Return whether CTRL-AP access is locked (see manual §16.2) +proc nrf52_is_ap_protected {} { + if { [using_hla] } { + return -code error "command not working with hla interfaces" + } + + set val [[[target current] cget -dap] apreg 1 0x0c] + return [expr {$val == 0 ? true : false}] +} +add_help_text nrf52_is_ap_protected "return whether nrf52 CTRL-AP access is locked" + +# Erase all content and unlock CTRL-AP access (see manual §16.2) +proc nrf52_erase_unlock {} { + if { [using_hla] } { + return -code error "command not working with hla interfaces" + } + + poll off + set target [target current] + set dap [$target cget -dap] + + # Erase all content + $dap apreg 1 0x04 1 + # Wait for completion + while {[$dap apreg 1 0x08] == 1} { + echo "erase in progress..." + sleep 150 + } + echo "erased and unlocked" + + reset halt + poll on +} +add_help_text nrf52_erase_unlock "erase all nrf52 content and unlock CTRL-AP access" + +# Enable CTRL-AP access protection (see manual §14.1.62) +proc nrf52_protect_ap {} { + poll off + + flash fillw 0x10001208 0x00 1 + + reset run + poll on +} +add_help_text nrf52_protect_ap "enable nrf52 CTRL-AP access protection" -- _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
