Skip to content

[nrf noup] target: add eraseprotect support #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7b830d6
[nrf fromtree] platform: nordic: Add platform memory write service
Vge0rge May 28, 2024
9303e23
[nrf fromtree] platform: nordic: Allow reading UICR registers
SeppoTakalo Aug 15, 2024
d1c8f45
[nrf fromtree] platform: nordic: Guard nvmc header with soc series
SeppoTakalo Aug 21, 2024
ee3362f
[nrf fromtree] Protected Storage: Add capacity in tfm_ps_get_info calls.
MarkusLassila Nov 14, 2024
e343ed5
[nrf fromtree] platform: nordic_nrf: ifdef nrf_rtc.h inclusion
nika-nordic Feb 11, 2025
e36984e
[nrf fromtree] doc: Update READMEs to use nrfutil
greg-fer Mar 14, 2025
0410972
[nrf fromtree] Docs: Fix maintainers file entry
tomi-font Apr 17, 2025
1c5994c
[nrf fromtree] Docs: Fix 2.1.2 release notes build
tomi-font Apr 17, 2025
1daa80b
[nrf fromtree] Crypto: Add psa_can_do_cipher()
adeaarm Apr 23, 2025
89135b5
[nrf fromtree] platform: nordic_nrf: Fix broken path for NS in nRF54L
Vge0rge Apr 23, 2025
2031c49
[nrf fromtree] Docs: Actually fix 2.1.2 release notes build
tomi-font Apr 23, 2025
7bfb357
[nrf noup] Remove check for p256-m
SebastianBoe Mar 1, 2024
6ded8e3
[nrf noup] cmake: tools: Dont add a custom command for running the ma…
SebastianBoe Mar 7, 2024
2015de9
[nrf noup] crypto: Add PAKE support
frkv Aug 15, 2024
31bc349
[nrf noup] Support CMAC KDF and custom builtin solution
frkv Aug 15, 2024
1c36bc1
[nrf noup] crypto: Detect wrong headers being included
SebastianBoe Apr 10, 2024
5a7e309
[nrf noup] Fix version warning
vlilleboe Jun 21, 2024
0d1c9ec
[nrf noup] tf-m: Enable support for external PSA core
frkv Sep 5, 2024
f0d180a
[nrf noup] attestation: Prevent errors of multiple defs of ARRAY_LENGTH
frkv Sep 21, 2024
11f7011
[nrf noup] Add definitions for builtin key support
frkv Sep 26, 2024
70053f8
[nrf noup] tf-m: Reworking a previous version of unitializing uart fo…
frkv Sep 30, 2024
02e1670
[nrf noup] Add KMU ram region at top
Vge0rge Nov 15, 2024
288e906
[nrf noup] secure_fw: Add option to log output on a shared UART insta…
frkv Aug 15, 2024
030c94c
[nrf noup] crypto: Have CRYPTO_HW_ACCELERATOR support nrf_security
SebastianBoe Mar 1, 2024
6d82e72
[nrf noup] Remove version mismatch CMake warning
tomi-font Apr 17, 2025
05b73d2
[nrf noup] ITS: fix aad_size parameter spelling
tomi-font Apr 9, 2025
13e8eaf
[nrf fromtree] platform: nordic_nrf: Add configuration for GPIOTE sec…
Vge0rge May 2, 2025
1352b44
[nrf noup] inteface: Remove headers existing in the Oberon PSA core
Vge0rge May 12, 2025
a26343e
[nrf noup] tf-m: Fixup for the support for external core
Vge0rge May 13, 2025
b23519d
[nrf noup] partitions: crypto: Fix duplicate functions
Vge0rge May 13, 2025
af88d87
[nrf noup] target: add eraseprotect support
maxd-nordic May 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 36 additions & 29 deletions cmake/install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,34 +72,40 @@ if (TFM_PARTITION_INTERNAL_TRUSTED_STORAGE)
endif()

if (TFM_PARTITION_CRYPTO)
install(FILES ${INTERFACE_INC_DIR}/psa/README.rst
${INTERFACE_INC_DIR}/psa/build_info.h
${INTERFACE_INC_DIR}/psa/crypto.h
${INTERFACE_INC_DIR}/psa/crypto_adjust_auto_enabled.h
${INTERFACE_INC_DIR}/psa/crypto_adjust_config_dependencies.h
${INTERFACE_INC_DIR}/psa/crypto_adjust_config_key_pair_types.h
${INTERFACE_INC_DIR}/psa/crypto_adjust_config_synonyms.h
${INTERFACE_INC_DIR}/psa/crypto_builtin_composites.h
${INTERFACE_INC_DIR}/psa/crypto_builtin_key_derivation.h
${INTERFACE_INC_DIR}/psa/crypto_builtin_primitives.h
${INTERFACE_INC_DIR}/psa/crypto_compat.h
${INTERFACE_INC_DIR}/psa/crypto_driver_common.h
${INTERFACE_INC_DIR}/psa/crypto_driver_contexts_composites.h
${INTERFACE_INC_DIR}/psa/crypto_driver_contexts_key_derivation.h
${INTERFACE_INC_DIR}/psa/crypto_driver_contexts_primitives.h
${INTERFACE_INC_DIR}/psa/crypto_extra.h
${INTERFACE_INC_DIR}/psa/crypto_legacy.h
${INTERFACE_INC_DIR}/psa/crypto_platform.h
${INTERFACE_INC_DIR}/psa/crypto_se_driver.h
${INTERFACE_INC_DIR}/psa/crypto_sizes.h
${INTERFACE_INC_DIR}/psa/crypto_struct.h
${INTERFACE_INC_DIR}/psa/crypto_types.h
${INTERFACE_INC_DIR}/psa/crypto_values.h
DESTINATION ${INSTALL_INTERFACE_INC_DIR}/psa)
install(FILES ${INTERFACE_INC_DIR}/tfm_crypto_defs.h
DESTINATION ${INSTALL_INTERFACE_INC_DIR})
install(DIRECTORY ${INTERFACE_INC_DIR}/mbedtls
DESTINATION ${INSTALL_INTERFACE_INC_DIR})
if(PSA_CRYPTO_EXTERNAL_CORE)
include(${TARGET_PLATFORM_PATH}/../external_core_install.cmake)
install(FILES ${INTERFACE_INC_DIR}/tfm_crypto_defs.h
DESTINATION ${INSTALL_INTERFACE_INC_DIR})
else()
install(FILES ${INTERFACE_INC_DIR}/psa/README.rst
${INTERFACE_INC_DIR}/psa/build_info.h
${INTERFACE_INC_DIR}/psa/crypto.h
${INTERFACE_INC_DIR}/psa/crypto_adjust_auto_enabled.h
${INTERFACE_INC_DIR}/psa/crypto_adjust_config_dependencies.h
${INTERFACE_INC_DIR}/psa/crypto_adjust_config_key_pair_types.h
${INTERFACE_INC_DIR}/psa/crypto_adjust_config_synonyms.h
${INTERFACE_INC_DIR}/psa/crypto_builtin_composites.h
${INTERFACE_INC_DIR}/psa/crypto_builtin_key_derivation.h
${INTERFACE_INC_DIR}/psa/crypto_builtin_primitives.h
${INTERFACE_INC_DIR}/psa/crypto_compat.h
${INTERFACE_INC_DIR}/psa/crypto_driver_common.h
${INTERFACE_INC_DIR}/psa/crypto_driver_contexts_composites.h
${INTERFACE_INC_DIR}/psa/crypto_driver_contexts_key_derivation.h
${INTERFACE_INC_DIR}/psa/crypto_driver_contexts_primitives.h
${INTERFACE_INC_DIR}/psa/crypto_extra.h
${INTERFACE_INC_DIR}/psa/crypto_legacy.h
${INTERFACE_INC_DIR}/psa/crypto_platform.h
${INTERFACE_INC_DIR}/psa/crypto_se_driver.h
${INTERFACE_INC_DIR}/psa/crypto_sizes.h
${INTERFACE_INC_DIR}/psa/crypto_struct.h
${INTERFACE_INC_DIR}/psa/crypto_types.h
${INTERFACE_INC_DIR}/psa/crypto_values.h
DESTINATION ${INSTALL_INTERFACE_INC_DIR}/psa)
install(FILES ${INTERFACE_INC_DIR}/tfm_crypto_defs.h
DESTINATION ${INSTALL_INTERFACE_INC_DIR})
install(DIRECTORY ${INTERFACE_INC_DIR}/mbedtls
DESTINATION ${INSTALL_INTERFACE_INC_DIR})
endif()
endif()

if (TFM_PARTITION_INITIAL_ATTESTATION)
Expand Down Expand Up @@ -282,10 +288,11 @@ else()
)
endif()

# PSA_CRYPTO_EXTERNAL_CORE
target_include_directories(psa_interface
INTERFACE
$<INSTALL_INTERFACE:interface/include>
)
)

install(EXPORT tfm-config
FILE spe_export.cmake
Expand Down
9 changes: 9 additions & 0 deletions cmake/spe-CMakeLists.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ target_sources(tfm_api_ns
)

# Include interface headers exported by TF-M
if(PSA_CRYPTO_EXTERNAL_CORE)
include(${TARGET_PLATFORM_PATH}/../external_core.cmake)
else()
target_include_directories(tfm_api_ns
PUBLIC
${INTERFACE_INC_DIR}
)
endif()

target_include_directories(tfm_api_ns
PUBLIC
${INTERFACE_INC_DIR}
Expand Down
7 changes: 1 addition & 6 deletions cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ execute_process(COMMAND git describe --tags --always
# In a repository cloned with --no-tags option TFM_VERSION_FULL will be a hash
# only hence checking it for a tag format to accept as valid version.

string(FIND ${TFM_VERSION_FULL} "TF-M" TFM_TAG)
string(FIND ${TFM_VERSION_FULL} "v" TFM_TAG)
if(TFM_TAG EQUAL -1)
set(TFM_VERSION_FULL v${TFM_VERSION_MANUAL})
endif()
Expand All @@ -25,8 +25,3 @@ string(REGEX REPLACE "TF-M" "" TFM_VERSION_FULL ${TFM_VERSION_FULL})
# remove a commit number
string(REGEX REPLACE "-[0-9]+-g" "+" TFM_VERSION_FULL ${TFM_VERSION_FULL})
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" TFM_VERSION ${TFM_VERSION_FULL})

# Check that manually set version is up to date
if (NOT TFM_VERSION_MANUAL STREQUAL TFM_VERSION)
message(WARNING "TFM_VERSION_MANUAL mismatches to actual TF-M version. Please update TFM_VERSION_MANUAL in cmake/version.cmake")
endif()
2 changes: 2 additions & 0 deletions config/check_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ tfm_invalid_config(TFM_MULTI_CORE_TOPOLOGY AND TFM_NS_MANAGE_NSID)
tfm_invalid_config(TFM_PLAT_SPECIFIC_MULTI_CORE_COMM AND NOT TFM_MULTI_CORE_TOPOLOGY)
tfm_invalid_config(TFM_ISOLATION_LEVEL EQUAL 3 AND CONFIG_TFM_STACK_WATERMARKS)

tfm_invalid_config(CONFIG_TFM_LOG_SHARE_UART AND NOT SECURE_UART1)

########################## BL1 #################################################

tfm_invalid_config(TFM_BL1_2_IN_OTP AND TFM_BL1_2_IN_FLASH)
Expand Down
2 changes: 2 additions & 0 deletions config/config_base.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ set(CONFIG_TFM_HALT_ON_CORE_PANIC OFF CACHE BOOL "On fatal e

set(CONFIG_TFM_STACK_WATERMARKS OFF CACHE BOOL "Whether to pre-fill partition stacks with a set value to help determine stack usage")

set(CONFIG_TFM_LOG_SHARE_UART OFF CACHE BOOL "Allow TF-M and the non-secure application to share the UART instance. TF-M will use it while it is booting, after which the non-secure application will use it until an eventual fatal error is handled and logged by TF-M. Logging from TF-M will therefore otherwise be suppressed")
############################ Platform ##########################################

set(NUM_MAILBOX_QUEUE_SLOT 1 CACHE BOOL "Number of mailbox queue slots")
Expand Down Expand Up @@ -132,6 +133,7 @@ set(BL2_TRAILER_SIZE 0x000 CACHE STRING "BL2 Trailer
set(TFM_PARTITION_PROTECTED_STORAGE OFF CACHE BOOL "Enable Protected Storage partition")
set(PS_ENCRYPTION ON CACHE BOOL "Enable encryption for Protected Storage partition")
set(PS_CRYPTO_AEAD_ALG PSA_ALG_GCM CACHE STRING "The AEAD algorithm to use for authenticated encryption in Protected Storage")
set(PS_CRYPTO_KDF_ALG PSA_ALG_HKDF\(PSA_ALG_SHA_256\) CACHE STRING "KDF Algorithm to use for Protect Storage")

set(TFM_PARTITION_INTERNAL_TRUSTED_STORAGE OFF CACHE BOOL "Enable Internal Trusted Storage partition")
set(ITS_ENCRYPTION OFF CACHE BOOL "Enable authenticated encryption of ITS files using platform specific APIs")
Expand Down
6 changes: 3 additions & 3 deletions docs/contributing/maintainers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ William Vinnicombe
:email: `[email protected] <[email protected]>`__
:github: `Raspberry Pi <https://github.com/raspberrypi>`__

Analog Devices Platform:
~~~~~~~~~~~~~~~~~~~~~~~~
Analog Devices Platform
~~~~~~~~~~~~~~~~~~~~~~~

Sadik Ozer
:email: `[email protected]`__
:email: `[email protected] <[email protected]>`__
:github: `ozersa <https://github.com/ozersa>`__

=============
Expand Down
46 changes: 28 additions & 18 deletions docs/platform/lairdconnectivity/bl5340_dvk_cpuapp/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The following links provide useful information about the BL5340
BL5340 website:
https://www.lairdconnect.com/wireless-modules/bluetooth-modules/bluetooth-5-modules/bl5340-series-multi-core-bluetooth-52-802154-nfc-modules

Nordic Semiconductor Infocenter: https://infocenter.nordicsemi.com
Nordic Semiconductor TechDocs: https://docs.nordicsemi.com

Building TF-M on BL5340 Application MCU
---------------------------------------
Expand Down Expand Up @@ -74,17 +74,25 @@ To install the J-Link Software and documentation pack, follow the steps below:
#. When connecting a J-Link-enabled board such as a BL5340 DVK, a serial port
should come up

nRF Command-Line Tools Installation
***********************************
nRF Util Installation
*********************

The nRF Command-line Tools allow you to control your BL5340 module from the
nRF Util allows you to control your BL5340 module from the
command line, including resetting it, erasing or programming the flash memory
and more.

To install them, visit `nRF Command-Line Tools`_ and select your operating
system.
To install nRF Util:

After installing, make sure that ``nrfjprog`` is somewhere in your executable
1. Visit `nRF Util product page`_.
2. Download the executable.
3. Follow the `nRF Util installation instructions`_.
4. Install ``nrfutil device`` subcommand for programming, flashing, and erasing devices:

.. code-block:: console

nrfutil install device

After installing, make sure that ``nrfutil.exe`` is somewhere in your executable
path to be able to invoke it from anywhere.

BL2, S, and NS application images can be flashed into BL5340 separately or may
Expand All @@ -95,7 +103,7 @@ Flashing the BL5340 DVK

To program the flash with a compiled TF-M image (i.e. S, NS or both) after
having followed the instructions to install the Segger J-Link Software and the
nRF Command-Line Tools, follow the steps below:
nRF Util, follow the steps below:

Generate Intel hex files from the output binary (bin) files as follows:

Expand All @@ -108,27 +116,27 @@ Generate Intel hex files from the output binary (bin) files as follows:

.. code-block:: console

nrfjprog --eraseall -f nrf53
nrfutil device erase --all --x-family nrf53

* Flash the BL2 and the TF-M image binaries from the sample folder of your choice:

.. code-block:: console

nrfjprog --program <sample folder>/install/outputs/LAIRDCONNECTIVITY/BL5340_DVK_CPUAPP/bl2.hex -f nrf53 --sectorerase
nrfjprog --program <sample folder>/install/outputs/LAIRDCONNECTIVITY/BL5340_DVK_CPUAPP/tfm_s_ns_signed.hex -f nrf53 --sectorerase
nrfutil device program --x-family nrf53 --firmware <sample folder>/install/outputs/LAIRDCONNECTIVITY/BL5340_DVK_CPUAPP/bl2.hex --options chip_erase_mode=ERASE_RANGES_TOUCHED_BY_FIRMWARE
nrfutil device program --x-family nrf53 --firmware <sample folder>/install/outputs/LAIRDCONNECTIVITY/BL5340_DVK_CPUAPP/tfm_s_ns_signed.hex --options chip_erase_mode=ERASE_RANGES_TOUCHED_BY_FIRMWARE

* Reset and start TF-M:

.. code-block:: console

nrfjprog --reset -f nrf53
nrfutil device reset --x-family nrf53

Flashing the BL5340 DVK (Secondary slot in QSPI, with BL2)
**********************************************************

To program the flash with a compiled TF-M image (i.e. S, NS or both) after
having followed the instructions to install the Segger J-Link Software and the
nRF Command-Line Tools to the secondary , follow the steps below:
nRF Util to the secondary , follow the steps below:

Generate Intel hex files from the output binary (bin) files as follows:

Expand All @@ -141,20 +149,20 @@ Generate Intel hex files from the output binary (bin) files as follows:

.. code-block:: console

nrfjprog --eraseall -f nrf53
nrfutil device erase --all --x-family nrf53

* Flash the BL2 and the TF-M image binaries from the sample folder of your choice:

.. code-block:: console

nrfjprog --program <sample folder>/install/outputs/LAIRDCONNECTIVITY/BL5340_DVK_CPUAPP/bl2.hex -f nrf53 --sectorerase
nrfjprog --program <sample folder>/install/outputs/LAIRDCONNECTIVITY/BL5340_DVK_CPUAPP/tfm_s_ns_signed.hex -f nrf53 --qspisectorerase
nrfutil device program --x-family nrf53 --firmware <sample folder>/install/outputs/LAIRDCONNECTIVITY/BL5340_DVK_CPUAPP/bl2.hex --options chip_erase_mode=ERASE_RANGES_TOUCHED_BY_FIRMWARE
nrfutil device program --x-family nrf53 --firmware <sample folder>/install/outputs/LAIRDCONNECTIVITY/BL5340_DVK_CPUAPP/tfm_s_ns_signed.hex --options ext_mem_erase_mode=ERASE_RANGES_TOUCHED_BY_FIRMWARE

* Reset and start TF-M:

.. code-block:: console

nrfjprog --reset -f nrf53
nrfutil device reset --x-family nrf53


Secure UART Console on BL5340 DVK
Expand All @@ -169,7 +177,9 @@ Non-Secure console output is available via USART0.

By default USART0 and USART1 outputs are routed to separate serial ports.

.. _nRF Command-Line Tools: https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Command-Line-Tools
.. _nRF Util product page: https://www.nordicsemi.com/Products/Development-tools/nRF-Util/

.. _nRF Util installation instructions: https://docs.nordicsemi.com/bundle/nrfutil/page/guides/installing.html

.. _J-Link Software and documentation pack: https://www.segger.com/jlink-software.html

Expand Down
38 changes: 24 additions & 14 deletions docs/platform/nordic_nrf/nrf5340dk_nrf5340_cpuapp/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The following links provide useful information about the nRF5340
nRF5340 DK website:
https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF5340-DK

Nordic Semiconductor Infocenter: https://infocenter.nordicsemi.com
Nordic Semiconductor TechDocs: https://docs.nordicsemi.com


Building TF-M on nRF5340 Application MCU
Expand Down Expand Up @@ -72,17 +72,25 @@ To install the J-Link Software and documentation pack, follow the steps below:
#. When connecting a J-Link-enabled board such as an nRF5340 DK, a drive
corresponding to a USB Mass Storage device as well as a serial port should come up

nRF Command-Line Tools Installation
*************************************
nRF Util Installation
*********************

The nRF Command-line Tools allow you to control your nRF5340 device from the command line,
nRF Util allows you to control your nRF5340 device from the command line,
including resetting it, erasing or programming the flash memory and more.

To install them, visit `nRF Command-Line Tools`_ and select your operating
system.
To install nRF Util:

After installing, make sure that ``nrfjprog`` is somewhere in your executable path
to be able to invoke it from anywhere.
1. Visit `nRF Util product page`_.
2. Download the executable.
3. Follow the `nRF Util installation instructions`_.
4. Install ``nrfutil device`` subcommand for programming, flashing, and erasing devices:

.. code-block:: console

nrfutil install device

After installing, make sure that ``nrfutil.exe`` is somewhere in your executable
path to be able to invoke it from anywhere.

BL2, S, and NS application images can be flashed into nRF5340 separately or may be merged
together into a single binary.
Expand All @@ -106,27 +114,27 @@ Generate Intel hex files from the output binary (bin) files as follows:

.. code-block:: console

nrfjprog --eraseall -f nrf53
nrfutil device erase --all --x-family nrf53

* (Optionally) Erase the flash memory and reset flash protection and disable
the read back protection mechanism if enabled.

.. code-block:: console

nrfjprog --recover -f nrf53
nrfutil device recover --x-family nrf53

* Flash the BL2 and the TF-M image binaries from the sample folder of your choice:

.. code-block:: console

nrfjprog --program build_spe/bin/bl2.hex -f nrf53 --sectorerase
nrfjprog --program build_app/tfm_s_ns_signed.hex -f nrf53 --sectorerase
nrfutil device program --x-family nrf53 --firmware build_spe/bin/bl2.hex --options chip_erase_mode=ERASE_RANGES_TOUCHED_BY_FIRMWARE
nrfutil device program --x-family nrf53 --firmware build_app/tfm_s_ns_signed.hex --options chip_erase_mode=ERASE_RANGES_TOUCHED_BY_FIRMWARE

* Reset and start TF-M:

.. code-block:: console

nrfjprog --reset -f nrf53
nrfutil device reset --x-family nrf53


Secure UART Console on nRF5340 DK
Expand All @@ -141,7 +149,9 @@ Non-Secure console output is available via USART0.
.. note::
By default USART0 and USART1 outputs are routed to separate serial ports.

.. _nRF Command-Line Tools: https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Command-Line-Tools
.. _nRF Util product page: https://www.nordicsemi.com/Products/Development-tools/nRF-Util/

.. _nRF Util installation instructions: https://docs.nordicsemi.com/bundle/nrfutil/page/guides/installing.html

.. _J-Link Software and documentation pack: https://www.segger.com/jlink-software.html

Expand Down
Loading