MCXN9xx Code Read Protection (CRP)#
This notebook shows how to read the Code Read Protection (CRP) level of an MCXN9xx device (e.g. mcxn946/mcxn947) using the SPSDK nxpdebugmbox application.
Code Read Protection restricts read/write access to the on-chip flash and debug resources. The current CRP level is exposed through the debug mailbox and can be queried with the nxpdebugmbox cmd get-crp command. This is useful to verify the security state of a device during development and provisioning. The same nxpdebugmbox tool is used for debug authentication on this device.
1. Prerequisites#
SPSDK is needed with examples extension.
pip install spsdk[examples](Please refer to the installation documentation.)This example uses an MCXN9xx board (e.g. FRDM-MCXN947) connected via a debug probe (pyOCD / MCU-Link / J-Link).
# This env variable sets colored logger output to STDOUT
%env JUPYTER_SPSDK=1
# Set a magic for command execution and echo
%alias execute echo %l && %l
%alias_magic ! execute
env: JUPYTER_SPSDK=1
Created `%!` as an alias for `%execute`.
FAMILY = "mcxn946" # change this to your MCXN9xx family (e.g. mcxn947)
INTERFACE = "jlink" # debug probe interface: pyocd, mcu-link or jlink
VERBOSITY = (
"" # verbosity of commands, might be -v or -vv for debug or blank for no additional info
)
2. Read the CRP level#
The CRP level is read through the debug mailbox in three steps:
startopens a debug mailbox session,get-crpreads the current CRP level (it must be called afterstartand with the-n/--no-resetoption so the session is preserved),exitcloses the debug mailbox session.
# Open the debug mailbox session
%! nxpdebugmbox $VERBOSITY -i $INTERFACE cmd -f $FAMILY start
nxpdebugmbox -i jlink cmd -f mcxn946 start
# Interface Id Description Architecture Protocols
-------------------------------------------------------------------------------------
0 Jlink 851006367 Segger J-Link Compact PLUS arm-cortex swd, jtag
Start Debug Mailbox succeeded
# Read the current CRP level (no-reset keeps the mailbox session open)
%! nxpdebugmbox $VERBOSITY -n -i $INTERFACE cmd -f $FAMILY get-crp
nxpdebugmbox -n -i jlink cmd -f mcxn946 get-crp
# Interface Id Description Architecture Protocols
-------------------------------------------------------------------------------------
0 Jlink 851006367 Segger J-Link Compact PLUS arm-cortex swd, jtag
CRP level is: 0x00.
Get CRP Level succeeded
# Close the debug mailbox session
%! nxpdebugmbox $VERBOSITY -i $INTERFACE cmd -f $FAMILY exit
nxpdebugmbox -i jlink cmd -f mcxn946 exit
# Interface Id Description Architecture Protocols
-------------------------------------------------------------------------------------
0 Jlink 851006367 Segger J-Link Compact PLUS arm-cortex swd, jtag
Exit Debug Mailbox succeeded