-
Notifications
You must be signed in to change notification settings - Fork 1.5k
modules: trusted-fimware-m: Add memory configuration logs #28732
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
AntonZma
wants to merge
1
commit into
nrfconnect:main
Choose a base branch
from
AntonZma:tfm-config-logs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
modules/trusted-firmware-m/tfm_boards/include/log_memory_protection.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /* | ||
| * Copyright (c) 2026 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| */ | ||
|
|
||
| #ifndef __LOG_MEMORY_PROTECTION_H | ||
| #define __LOG_MEMORY_PROTECTION_H | ||
|
|
||
| void log_memory_protection_of_mpu(void); | ||
| void log_memory_protection_of_spu_nsc(void); | ||
| void log_memory_protection_of_spu_flash(void); | ||
| void log_memory_protection_of_spu_ram(void); | ||
| void log_memory_protection_of_spu(void); | ||
| void log_memory_protection_mpu_spu(void); | ||
|
|
||
| void log_memory_protection_sau_mpc(void); | ||
|
|
||
| #endif /* __LOG_MEMORY_PROTECTION_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
modules/trusted-firmware-m/tfm_boards/src/log_memory_protection_sau_mpc.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| /* | ||
| * Copyright (c) 2026 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| */ | ||
|
|
||
| #include <log_memory_protection.h> | ||
| #include <cmsis.h> | ||
| #include <hal/nrf_mpc.h> | ||
| #include <tfm_spm_log.h> | ||
|
|
||
| static void log_memory_protection_sau(void) | ||
| { | ||
| uint32_t sau_regions_count = SAU->TYPE & SAU_TYPE_SREGION_Msk; | ||
| uint32_t limit_address; | ||
|
|
||
| SPMLOG_INFMSG("SAU config:\r\n"); | ||
| for (uint32_t i = 0; i < sau_regions_count; i++) { | ||
| SAU->RNR = i & SAU_RNR_REGION_Msk; | ||
|
|
||
| limit_address = SAU->RLAR; | ||
| if (limit_address & SAU_RLAR_ENABLE_Msk) { | ||
| if (limit_address & SAU_RLAR_NSC_Msk) { | ||
| SPMLOG_INFMSG("NCS region\r\n"); | ||
| } else { | ||
| SPMLOG_INFMSG("NS region\r\n"); | ||
| } | ||
| limit_address &= ~(SAU_RLAR_ENABLE_Msk | SAU_RLAR_NSC_Msk); | ||
| limit_address &= SAU_RLAR_LADDR_Msk; | ||
|
|
||
| SPMLOG_INFMSGVAL(" Base addr : ", SAU->RBAR & SAU_RBAR_BADDR_Msk); | ||
| SPMLOG_INFMSGVAL(" Limit addr: ", limit_address); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| static void log_memory_protection_mpc(void) | ||
| { | ||
| /* On 54L, the override regions (NRF_MPC00->OVERRIDE[]) are fixed in HW and the | ||
| * OVERRIDE indexes (that are useful to us) start at 0 and end at 4 (inclusive). | ||
| */ | ||
| const uint32_t max_index = 4; | ||
| uint32_t address; | ||
| uint32_t perm_settings; | ||
| nrf_mpc_override_config_t config; | ||
|
|
||
| SPMLOG_INFMSG("MPC config:\r\n"); | ||
| for (uint32_t i = 0; i <= max_index; i++) { | ||
| config = nrf_mpc_override_config_get(NRF_MPC00, i); | ||
| if (!config.enable) { | ||
| continue; | ||
| } | ||
|
|
||
| perm_settings = nrf_mpc_override_perm_get(NRF_MPC00, i); | ||
| perm_settings &= nrf_mpc_override_permmask_get(NRF_MPC00, i); | ||
|
|
||
| if (perm_settings & MPC_OVERRIDE_PERM_SECATTR_Msk) { | ||
| SPMLOG_INFMSG("S region\r\n"); | ||
| } else { | ||
| SPMLOG_INFMSG("NS region\r\n"); | ||
| } | ||
|
|
||
| address = nrf_mpc_override_startaddr_get(NRF_MPC00, i); | ||
| SPMLOG_INFMSGVAL(" Base addr: ", address); | ||
|
|
||
| address = nrf_mpc_override_endaddr_get(NRF_MPC00, i); | ||
| SPMLOG_INFMSGVAL(" End addr : ", address); | ||
| } | ||
| } | ||
|
|
||
| void log_memory_protection_sau_mpc(void) | ||
| { | ||
| SPMLOG_INFMSG("** NS memory layout config start **\r\n"); | ||
| log_memory_protection_sau(); | ||
| log_memory_protection_mpc(); | ||
| SPMLOG_INFMSG("** NS memory layout config end **\r\n"); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,3 +19,5 @@ CONFIG_PSA_WANT_GENERATE_RANDOM=y | |
| CONFIG_PSA_WANT_ALG_HMAC=y | ||
| CONFIG_PSA_WANT_ALG_SHA_256=y | ||
| CONFIG_PSA_WANT_KEY_TYPE_HMAC=y | ||
|
|
||
| CONFIG_TFM_LOG_NS_MEMORY_LAYOUT=y | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this was added by accident, right? |
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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