Skip to content

modules: trusted-fimware-m: Add memory configuration logs#28732

Open
AntonZma wants to merge 1 commit into
nrfconnect:mainfrom
AntonZma:tfm-config-logs
Open

modules: trusted-fimware-m: Add memory configuration logs#28732
AntonZma wants to merge 1 commit into
nrfconnect:mainfrom
AntonZma:tfm-config-logs

Conversation

@AntonZma
Copy link
Copy Markdown
Contributor

@AntonZma AntonZma commented May 12, 2026

The only way to extract the actual information about memory regions configured as non-secure is by debugging the code.

This PR adds debug functions for printing SAU and MPC configuration of nRF54L devices, as well as modifying the existing code printing configuration for MPU and SPU, aligning its implementation with SAU/MPC.
A new KConfig option to activate this functionality has also been added.

@AntonZma AntonZma requested review from Vge0rge and greg-fer May 12, 2026 14:14
@AntonZma AntonZma requested review from a team as code owners May 12, 2026 14:14
@NordicBuilder NordicBuilder added doc-required PR must not be merged without tech writer approval. changelog labels May 12, 2026
@NordicBuilder
Copy link
Copy Markdown
Contributor

NordicBuilder commented May 12, 2026

CI Information

To view the history of this post, click the 'edited' button above
Build number: 4

Inputs:

Sources:

sdk-nrf: PR head: 0e49f28abed5fb4547d62c0dc84cb6ebe10c8b72

more details

sdk-nrf:

PR head: 0e49f28abed5fb4547d62c0dc84cb6ebe10c8b72
merge base: edc1422794d19117e9b7b11cc92e04ad4b1136fb
target head (main): ea86ade4e72ff025485c6b0d132ab7eb3465db35
Diff

Github labels

Enabled Name Description
ci-disabled Disable the ci execution
ci-all-test Run all of ci, no test spec filtering will be done
ci-force-downstream Force execution of downstream even if twister fails
ci-run-twister Force run twister
ci-run-zephyr-twister Force run zephyr twister
List of changed files detected by CI (9)
doc
│  ├── nrf
│  │  ├── releases_and_maturity
│  │  │  ├── releases
│  │  │  │  │ release-notes-changelog.rst
modules
│  ├── trusted-firmware-m
│  │  ├── CMakeLists.txt
│  │  ├── Kconfig
│  │  ├── tfm_boards
│  │  │  ├── CMakeLists.txt
│  │  │  ├── common
│  │  │  │  │ tfm_hal_platform.c
│  │  │  ├── include
│  │  │  │  │ log_memory_protection.h
│  │  │  ├── src
│  │  │  │  ├── log_memory_protection_mpu_spu.c
│  │  │  │  │ log_memory_protection_sau_mpc.c
samples
│  ├── crypto
│  │  ├── hmac
│  │  │  │ prj.conf

Outputs:

Toolchain

Version: b819b2845f
Build docker image: docker-dtr.nordicsemi.no/sw-production/ncs-build:b819b2845f_5ea73affbf

Test Spec & Results: ✅ Success; ❌ Failure; 🟠 Queued; 🟡 Progress; ◻️ Skipped; ⚠️ Quarantine

  • ◻️ Toolchain - Skipped: existing toolchain is used
  • ✅ Build twister
    • sdk-nrf test count: 1052
  • ❌ Integration tests
    • ✅ test-fw-nrfconnect-nrf_crypto
    • ✅ test-fw-nrfconnect-tfm
    • ❌ test-sdk-find-my
    • ✅ test-sdk-mcuboot
    • ✅ test-sdk-dfu
Disabled integration tests
    • test-fw-nrfconnect-nrf_lrcs_mosh
    • test-fw-nrfconnect-nrf_lrcs_positioning
    • desktop52_verification
    • test_ble_nrf_config
    • test-fw-nrfconnect-apps
    • test-fw-nrfconnect-apps_nrfdesktop
    • test-fw-nrfconnect-ble_mesh
    • test-fw-nrfconnect-ble_samples
    • test-fw-nrfconnect-chip
    • test-fw-nrfconnect-fem
    • test-fw-nrfconnect-nfc
    • test-fw-nrfconnect-nrf-iot_libmodem-nrf
    • test-fw-nrfconnect-nrf-iot_lwm2m
    • test-fw-nrfconnect-nrf-iot_samples
    • test-fw-nrfconnect-nrf-iot_zephyr_lwm2m
    • test-fw-nrfconnect-ps-main
    • test-fw-nrfconnect-rpc
    • test-fw-nrfconnect-rs
    • test-fw-nrfconnect-thread-main
    • test-low-level
    • test-sdk-audio
    • test-sdk-wifi
    • test-secdom-samples-public

Note: This message is automatically posted and updated by the CI

Comment thread modules/trusted-firmware-m/Kconfig Outdated
during TF-M initialization. It contains address ranges of the non-secure
memory regions (both volatile and non-volatile). The rest of the memory
is secure by default.
This option is currently available for nRF54L15/10/05.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is blocked on SOC_SERIES_NRF54L, but you state that only 54l15/10/05 is supported. Do you mean all 54L devices or is this restricted to 54L15? And if restricted to 54L15 why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. This option is for all nRF54L devices (which are being configured in target_cfg_54l.c )

@github-actions
Copy link
Copy Markdown

You can find the documentation preview for this PR here.

Preview links for modified nRF Connect SDK documents:

https://ncsbmdoc.z6.web.core.windows.net/ncs/PR-28732/nrf/releases_and_maturity/releases/release-notes-changelog.html

* Added:

* Support for the X25519 key pair storage in the :ref:`Key Management Unit (KMU) <ug_kmu_guides_supported_key_types>`.
* The :kconfig:option:`CONFIG_TFM_LOG_NS_MEMORY_LAYOUT` to print the configuration of SAU and MPC during TF-M initialization of the nRF54L15 devices.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* The :kconfig:option:`CONFIG_TFM_LOG_NS_MEMORY_LAYOUT` to print the configuration of SAU and MPC during TF-M initialization of the nRF54L15 devices.
* The :kconfig:option:`CONFIG_TFM_LOG_NS_MEMORY_LAYOUT` Kconfig option to print the configuration of SAU and MPC during TF-M initialization of the nRF54L15 devices.

@AntonZma AntonZma requested a review from degjorva May 13, 2026 12:01
@AntonZma AntonZma requested a review from umapraseeda May 14, 2026 14:53
* Added:

* Support for the X25519 key pair storage in the :ref:`Key Management Unit (KMU) <ug_kmu_guides_supported_key_types>`.
* The :kconfig:option:`CONFIG_TFM_LOG_NS_MEMORY_LAYOUT` Kconfig option to print the configuration of SAU and MPC during TF-M initialization of the nRF54L15 devices.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nrf54L15 -> nr54L series devices maybe? Since this is not specific to the nrf54L15.


static void log_memory_protection_sau(void)
{
uint32_t sau_regions_count = SAU->TYPE;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it definitely makes sense


static void log_memory_protection_mpc(void)
{
/* On 54l the NRF_MPC00->REGION[]'s are fixed in HW and the
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, in 54L there are only overrides, not regions

for (uint32_t i = 0; i <= max_index; i++) {
config = nrf_mpc_override_config_get(NRF_MPC00, i);
if (config.enable) {
SPMLOG_INFMSG("NS region\r\n");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since MPC could possibly set the override as secure do you think that it makes sense to also call nrf_mpc_override_perm_get here and check the secure bit?
https://docs-be.nordicsemi.com/bundle/ps_nrf54L15/page/mpc.html#register.OVERRIDE.PERM

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is a more universal approach. When implementing this I checked how this is configured in target_cfg_54l.c.
Anyway, now it is updated to check both PERM and PERMMASK.

* Added:

* Support for the X25519 key pair storage in the :ref:`Key Management Unit (KMU) <ug_kmu_guides_supported_key_types>`.
* The :kconfig:option:`CONFIG_TFM_LOG_NS_MEMORY_LAYOUT` Kconfig option to print the configuration of SAU and MPC during TF-M initialization of the nRF54L15 devices.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* The :kconfig:option:`CONFIG_TFM_LOG_NS_MEMORY_LAYOUT` Kconfig option to print the configuration of SAU and MPC during TF-M initialization of the nRF54L15 devices.
* The :kconfig:option:`CONFIG_TFM_LOG_NS_MEMORY_LAYOUT` Kconfig option, which prints the configuration of SAU and MPC during the initialization of TF-M on the nRF54L Series devices.


static void log_memory_protection_mpc(void)
{
/* On 54l the NRF_MPC00->REGION[]'s are fixed in HW and the
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* On 54l the NRF_MPC00->REGION[]'s are fixed in HW and the
/* On 54L, the regions (NRF_MPC00->REGION[]) are fixed in HW and the

Copy link
Copy Markdown
Contributor Author

@AntonZma AntonZma Jun 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rephrased a bit after applying a fix suggested by Georgios

{
/* On 54l the NRF_MPC00->REGION[]'s are fixed in HW and the
* OVERRIDE indexes (that are useful to us) start at 0 and end
* (inclusive) at 4.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* (inclusive) at 4.
* at 4 (inclusive).

Comment thread modules/trusted-firmware-m/Kconfig Outdated
Comment on lines +377 to +381
This option activates logic to print the configuration of SAU and MPC
during TF-M initialization. It contains address ranges of the non-secure
memory regions (both volatile and non-volatile). The rest of the memory
is secure by default.
This option is currently available for all nRF54L devices.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This option activates logic to print the configuration of SAU and MPC
during TF-M initialization. It contains address ranges of the non-secure
memory regions (both volatile and non-volatile). The rest of the memory
is secure by default.
This option is currently available for all nRF54L devices.
This option activates the logic to print the configuration of SAU and MPC
during the initialization of TF-M. The logic targets address ranges of the non-secure
memory regions (both volatile and non-volatile). The rest of the memory
is secure by default.
This option is currently available for all nRF54L Series devices.

The only way to extract the actual information about
memory regions configured as non-secure is by debugging
the code.

This commit adds debug functions for printing SAU and
MPC configuration of nRF54L devices.

It also modifies the existing code printing configuration
for MPU and SPU, aligning its implementation with SAU/MPC.

A new KConfig option to activate this functionality
has also been added.

Ref: NCSDK-38986

Signed-off-by: Anton Zyma <anton.zyma@nordicsemi.no>
@AntonZma AntonZma requested review from Vge0rge and greg-fer June 2, 2026 10:41
uint32_t sau_regions_count = SAU->TYPE & SAU_TYPE_SREGION_Msk;
uint32_t limit_address;

SPMLOG_INFMSG("SAU config:\r\n");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will need updating after #28975 goes in

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this got merged so you will have to update this in order to get a green CI.
This is the relevant commit:
cc80336

CONFIG_PSA_WANT_ALG_SHA_256=y
CONFIG_PSA_WANT_KEY_TYPE_HMAC=y

CONFIG_TFM_LOG_NS_MEMORY_LAYOUT=y
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this was added by accident, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog doc-required PR must not be merged without tech writer approval.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants