CTRL-AP - Control access port

The control access port (CTRL-AP) is a custom access port that enables control of the device when other debug access ports (DAP) have been disabled by the access port protection.

For an overview of the other debug access ports, see DAP - Debug access port.
Figure 1. Control access port details
Control access port details

Access port protection (APPROTECT) blocks the debugger access to the AHB-AP, and prevents read and write access to all CPU registers and memory-mapped addresses. To enable port protection access for both secure and non-secure modes, use the registers SECUREAPPROTECT and APPROTECT respectively. The debugger can use the register APPROTECT.STATUS to read the status of secure and non-secure access port protection.

CTRL-AP has the following features:
  • Soft reset
  • Erase all
  • Mailbox interface
  • Debug of protected devices

Reset request

The debugger can request the device to perform a soft reset.

Use the register RESET to request a soft reset. Once the soft reset is performed, the reset reason is accessible on the on-chip firmware through the RESETREAS register. For more information about the soft reset, see Reset.

Erase all

The erase all function lets the debugger trigger an erase of flash, user information configuration registers (UICR), RAM, all peripheral settings, and also removes the access port protection.

To trigger an erase all function, the debugger writes to the register ERASEALL. The register ERASEALLSTATUS will read as busy for the duration of the operation. After the next reset, the access port protection is removed.

When erase all is executed, any further writes to RESET are blocked until the device is reset either pin-reset or power-cycle.

If the debugger performs an erase all function on a slave MCU, the erase sequence will always erase the application MCU first, independently of how the application is protected, before erasing the slave MCU.

Erase all protection

It is possible to prevent the debugger from performing an erase all operation by writing to the UICR.ERASEPROTECT register. Once the register is configured and the device is reset, the CTRL-AP ERASEALL operation is disabled, and all flash write and erase operations are restricted to the firmware. In addition, it is still possible to write/erase from the debugger as long as the UICR.APPROTECT register is not set.

Note: Setting the UICR.ERASEPROTECT register only affects the erase all operation and not the debugger access.

The register ERASEPROTECT.STATUS holds the status for erase protection.

Mailbox interface

CTRL-AP implements a mailbox interface which enables the CPU to communicate with a debugger over the SWD interface.

The mailbox interface consists of a transmit register MAILBOX.TXDATA with its corresponding status register MAILBOX.TXSTATUS, and a receive register MAILBOX.RXDATA with its corresponding status register MAILBOX.RXSTATUS. Status bits in the TXSTATUS/RXSTATUS registers are set and cleared automatically when the TXDATA/RXDATA registers are written to and read from, independently of the direction.
Figure 2. Mailbox register interface
Mailbox register interface, illustrating the data flow between debugger and CPU

Mailbox transfer sequence

  1. Sender writes TXDATA.
  2. Hardware sets sender's TXSTATUS to DataPending.
  3. Hardware sets receiver's RXSTATUS to DataPending.
  4. Receiver reads RXDATA.
  5. Hardware sets receiver's RXSTATUS to NoDataPending.
  6. Hardware sets sender's TXSTATUS to NoDataPending.

Disabling erase protection

The erase protection mechanism can be disabled to return a device to factory default settings on next reset.

The debugger can read the erase protection status in the register ERASEPROTECT.STATUS.

If ERASEPROTECT has been enabled, both the debugger and on-chip firmware must write the same non-zero 32-bit KEY value into their respective ERASEPROTECT.DISABLE registers to disable the erase protection. When both registers have been written with the same non-zero 32-bit KEY value, the device is automatically erased as described in Erase all. The access ports will be re-enabled on the next reset once the secure erase sequence has completed.

The write-once register ERASEPROTECT.LOCK should be set to Locked as early as possible in the start-up sequence, preferably as soon as the on-chip firmware has determined it does not need to communicate with a debugger over the CTRL-AP mailbox interface. Once written, it will not be possible to remove the erase protection until the next reset.

Debugger registers

CTRL-AP has a set of registers that can only be accessed from the debugger over the SWD interface. These are not accessible from the CPU.

Debugger registers

Register overview

RegisterOffsetDescription
RESET0x000System reset request
ERASEALL0x004Perform a secure erase of the device, where flash, SRAM and UICR will be erased in sequence. The device will be returned to factory default settings upon next reset.
ERASEALLSTATUS0x008This is the status register for the ERASEALL operation.
APPROTECT.STATUS0x00CThis is the status register for the UICR access port protection.
ERASEPROTECT.STATUS0x018This is the status register for the UICR ERASEPROTECT configuration.
ERASEPROTECT.DISABLE0x01CThis register disables ERASEPROTECT and performs ERASEALL.
MAILBOX.TXDATA0x020Data sent from the debugger to the CPU.
MAILBOX.TXSTATUS0x024This register shows a status that indicates if data sent from the debugger to the CPU has been read.
MAILBOX.RXDATA0x028Data sent from the CPU to the debugger.
MAILBOX.RXSTATUS0x02CThis register shows a status that indicates if data sent from the CPU to the debugger has been read.
IDR0x0FCCTRL-AP Identification Register, IDR

RESET

Address offset: 0x000

System reset request

This register is automatically deactivated by writing Erase to ERASEALL, it is then kept inactive until a reset source affecting the debug system is asserted. See Reset behavior.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWRESETSystem reset request and status
NoReset0

Write to release reset

Reading '0' means reset is not active

Reset1

Write to hold reset

Reading '1' means reset is active

ERASEALL

Address offset: 0x004

Perform a secure erase of the device, where flash, SRAM and UICR will be erased in sequence. The device will be returned to factory default settings upon next reset.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
AWERASEALLReturn device to factory default settings
NoOperation0No operation
Erase1Erase flash, SRAM, and UICR in sequence

ERASEALLSTATUS

Address offset: 0x008

This is the status register for the ERASEALL operation.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARERASEALLSTATUSStatus bit for the ERASEALL operation
Ready0ERASEALL is ready
Busy1ERASEALL is busy (on-going)

APPROTECT.STATUS

Address offset: 0x00C

This is the status register for the UICR access port protection.

Bit number313029282726252423222120191817161514131211109876543210
IDBA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARAPPROTECT

Status bit for access port protection

Note: The reset value is auto read from the APPROTECT register in UICR.
Enabled0APPROTECT is enabled
Disabled1APPROTECT is disabled
BRSECUREAPPROTECT

Status bit for secure access port protection

Note: The reset value is auto read from the SECUREAPPROTECT register in UICR.
Enabled0SECUREAPPROTECT is enabled
Disabled1SECUREAPPROTECT is disabled

ERASEPROTECT.STATUS

Address offset: 0x018

This is the status register for the UICR ERASEPROTECT configuration.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARPALL

Status bit for erase protection

Note: The reset value is auto read from the ERASEPROTECT register in UICR.
Enabled0ERASEPROTECT is enabled
Disabled1ERASEPROTECT is not enabled and ERASEALL can be performed

ERASEPROTECT.DISABLE

Address offset: 0x01C

This register disables ERASEPROTECT and performs ERASEALL.

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARW1KEYThe ERASEALL sequence will be initiated if value of the KEY fields are non-zero and the KEY fields match on both the CPU and debugger sides.

MAILBOX.TXDATA

Address offset: 0x020

Data sent from the debugger to the CPU.

Writing to this register will automatically set a DataPending value in the TXSTATUS register.

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWDataData sent from debugger

MAILBOX.TXSTATUS

Address offset: 0x024

This register shows a status that indicates if data sent from the debugger to the CPU has been read.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARStatusStatus of register DATA
NoDataPending0No data pending in register TXDATA
DataPending1Data pending in register TXDATA

MAILBOX.RXDATA

Address offset: 0x028

Data sent from the CPU to the debugger.

Reading from this register will automatically set a NoDataPending value in the RXSTATUS register.

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARDataData sent from CPU

MAILBOX.RXSTATUS

Address offset: 0x02C

This register shows a status that indicates if data sent from the CPU to the debugger has been read.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARStatusStatus of register DATA
NoDataPending0No data pending in register RXDATA
DataPending1Data pending in register RXDATA

IDR

Address offset: 0x0FC

CTRL-AP Identification Register, IDR

Bit number313029282726252423222120191817161514131211109876543210
IDEEEEDDDDCCCCCCCBBBBAAAAAAAA
Reset 0x1288000000010010100010000000000000000000
IDR/WFieldValue IDValueDescription
ARAPIDAP Identification
BRCLASSAccess Port (AP) class
NotDefined0x0No defined class
MEMAP0x8Memory Access Port
CRJEP106IDJEDEC JEP106 identity code
DRJEP106CONTJEDEC JEP106 continuation code
ERREVISIONRevision

Registers

Instances

InstanceBase addressTrustZoneSplit accessDescription
MapAttDMA
CTRL_AP_PERI0x50006000HFSNANoCTRL-AP-PERI

Register overview

RegisterOffsetTZDescription
MAILBOX.RXDATA0x400Data sent from the debugger to the CPU.
MAILBOX.RXSTATUS0x404This register shows a status that indicates if data sent from the debugger to the CPU has been read.
MAILBOX.TXDATA0x480Data sent from the CPU to the debugger.
MAILBOX.TXSTATUS0x484This register shows a status that indicates if the data sent from the CPU to the debugger has been read.
ERASEPROTECT.LOCK0x500This register locks the ERASEPROTECT.DISABLE register from being written until next reset.
ERASEPROTECT.DISABLE0x504This register disables the ERASEPROTECT register and performs an ERASEALL operation.

MAILBOX.RXDATA

Address offset: 0x400

Data sent from the debugger to the CPU.

Reading from this register will automatically set a NoDataPending value in the RXSTATUS register.

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARRXDATAData received from debugger

MAILBOX.RXSTATUS

Address offset: 0x404

This register shows a status that indicates if data sent from the debugger to the CPU has been read.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARRXSTATUSStatus of data in register RXDATA
NoDataPending0No data pending in register RXDATA
DataPending1Data pending in register RXDATA

MAILBOX.TXDATA

Address offset: 0x480

Data sent from the CPU to the debugger.

Writing to this register will automatically set a DataPending value in the TXSTATUS register.

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWTXDATAData sent to debugger

MAILBOX.TXSTATUS

Address offset: 0x484

This register shows a status that indicates if the data sent from the CPU to the debugger has been read.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARTXSTATUSStatus of data in register TXDATA
NoDataPending0No data pending in register TXDATA
DataPending1Data pending in register TXDATA

ERASEPROTECT.LOCK

Address offset: 0x500

This register locks the ERASEPROTECT.DISABLE register from being written until next reset.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARW1LOCKLock ERASEPROTECT.DISABLE register from being written until next reset
Unlocked0Register ERASEPROTECT.DISABLE is writeable
Locked1Register ERASEPROTECT.DISABLE is read-only

ERASEPROTECT.DISABLE

Address offset: 0x504

This register disables the ERASEPROTECT register and performs an ERASEALL operation.

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARW1KEYThe ERASEALL sequence is initiated if the value of the KEY fields are non-zero and the KEY fields match on both the CPU and debugger sides.