SPM: Clean up SPM log output
Couple of things for cleaning up the SPM log:
* As 'MSGVAL' is customized for 'message + value', append '\r\n' at
the end to save extra 'MSG("\r\n")' which looks redundant.
Also adjusted related caller place to provide better adaptation.
* Override the default log level into Debug(3) under debug build.
Change-Id: If4392262fd112494ec86741c1ba5c8f256fd79fe
Signed-off-by: Ken Liu <Ken.Liu@arm.com>
diff --git a/config/build_type/debug.cmake b/config/build_type/debug.cmake
index 1256381..d098afb 100644
--- a/config/build_type/debug.cmake
+++ b/config/build_type/debug.cmake
@@ -6,3 +6,4 @@
#-------------------------------------------------------------------------------
set(MBEDCRYPTO_BUILD_TYPE relwithdebinfo CACHE STRING "Build type of Mbed Crypto library")
+set(TFM_SPM_LOG_LEVEL 3 CACHE STRING "Set debug SPM log level as Debug level" FORCE)
diff --git a/config/config_default.cmake b/config/config_default.cmake
index b795b43..0d1ad32 100644
--- a/config/config_default.cmake
+++ b/config/config_default.cmake
@@ -26,7 +26,7 @@
set(TFM_EXTRA_MANIFEST_LIST_PATH "" CACHE PATH "Path to extra manifest file, used to declare extra partitions. Appended to standard TFM manifest")
set(TFM_EXTRA_GENERATED_FILE_LIST_PATH "" CACHE PATH "Path to extra generated file list. Appended to stardard TFM generated file list.")
-set(TFM_SPM_LOG_LEVEL 2 CACHE STRING "Set SPM log level as INFO level")
+set(TFM_SPM_LOG_LEVEL 2 CACHE STRING "Set default SPM log level as INFO level")
########################## BL2 #################################################
diff --git a/platform/ext/target/cypress/psoc64/target_cfg.c b/platform/ext/target/cypress/psoc64/target_cfg.c
index e0351e4..2474f22 100755
--- a/platform/ext/target/cypress/psoc64/target_cfg.c
+++ b/platform/ext/target/cypress/psoc64/target_cfg.c
@@ -271,11 +271,10 @@
SPMLOG_INFMSG("\r\nSMPU config:\r\n");
SPMLOG_INFMSGVAL("memory_regions.non_secure_code_start = ",
memory_regions.non_secure_code_start);
- SPMLOG_INFMSGVAL("\r\nmemory_regions.non_secure_partition_base = ",
+ SPMLOG_INFMSGVAL("memory_regions.non_secure_partition_base = ",
memory_regions.non_secure_partition_base);
- SPMLOG_INFMSGVAL("\r\nmemory_regions.non_secure_partition_limit = ",
+ SPMLOG_INFMSGVAL("memory_regions.non_secure_partition_limit = ",
memory_regions.non_secure_partition_limit);
- SPMLOG_INFMSG("\r\n");
size_t n = sizeof(smpu_init_table)/sizeof(smpu_init_table[0]);
diff --git a/platform/ext/target/nxp/lpcxpresso55s69/target_cfg.c b/platform/ext/target/nxp/lpcxpresso55s69/target_cfg.c
index 3d63077..6b2b0c8 100755
--- a/platform/ext/target/nxp/lpcxpresso55s69/target_cfg.c
+++ b/platform/ext/target/nxp/lpcxpresso55s69/target_cfg.c
@@ -198,18 +198,14 @@
#endif /* BL2 */
SPMLOG_INFMSG("=== [SAU NS] =======\r\n");
- SPMLOG_INFMSGVAL("NS ROM [", memory_regions.non_secure_partition_base);
- SPMLOG_INFMSGVAL(",", memory_regions.non_secure_partition_limit);
- SPMLOG_INFMSG("]\r\n");
- SPMLOG_INFMSGVAL("NS DATA [", NS_DATA_START);
- SPMLOG_INFMSGVAL(",", NS_DATA_LIMIT);
- SPMLOG_INFMSG("]\r\n");
- SPMLOG_INFMSGVAL("NSC [", memory_regions.veneer_base);
- SPMLOG_INFMSGVAL(",", memory_regions.veneer_limit);
- SPMLOG_INFMSG("]\r\n");
- SPMLOG_INFMSGVAL("PERIPHERALS [", PERIPHERALS_BASE_NS_START);
- SPMLOG_INFMSGVAL(",", PERIPHERALS_BASE_NS_END);
- SPMLOG_INFMSG("]\r\n");
+ SPMLOG_INFMSGVAL("NS ROM Base:", memory_regions.non_secure_partition_base);
+ SPMLOG_INFMSGVAL("NS ROM Limit:", memory_regions.non_secure_partition_limit);
+ SPMLOG_INFMSGVAL("NS DATA Base:", NS_DATA_START);
+ SPMLOG_INFMSGVAL("NS DATA Limit:", NS_DATA_LIMIT);
+ SPMLOG_INFMSGVAL("NSC Base:", memory_regions.veneer_base);
+ SPMLOG_INFMSGVAL("NSC Limit:", memory_regions.veneer_limit);
+ SPMLOG_INFMSGVAL("PERIPHERALS Base:", PERIPHERALS_BASE_NS_START);
+ SPMLOG_INFMSGVAL("PERIPHERALS Limit:", PERIPHERALS_BASE_NS_END);
}
/*------------------- Memory configuration functions -------------------------*/
@@ -367,12 +363,10 @@
}
SPMLOG_INFMSG("=== [AHB MPC NS] =======\r\n");
- SPMLOG_INFMSGVAL("NS ROM [", memory_regions.non_secure_partition_base);
- SPMLOG_INFMSGVAL(",", memory_regions.non_secure_partition_limit);
- SPMLOG_INFMSG("]\r\n");
- SPMLOG_INFMSGVAL("NS DATA [", NS_DATA_START);
- SPMLOG_INFMSGVAL(",", NS_DATA_LIMIT);
- SPMLOG_INFMSG("]\r\n");
+ SPMLOG_INFMSGVAL("NS ROM Base:", memory_regions.non_secure_partition_base);
+ SPMLOG_INFMSGVAL("NS ROM Limit:", memory_regions.non_secure_partition_limit);
+ SPMLOG_INFMSGVAL("NS DATA Base:", NS_DATA_START);
+ SPMLOG_INFMSGVAL("NS DATA Limit:", NS_DATA_LIMIT);
/* Add barriers to assure the MPC configuration is done before continue
* the execution.
diff --git a/secure_fw/spm/cmsis_func/main.c b/secure_fw/spm/cmsis_func/main.c
index 59b91ee..304739d 100644
--- a/secure_fw/spm/cmsis_func/main.c
+++ b/secure_fw/spm/cmsis_func/main.c
@@ -77,10 +77,7 @@
SPMLOG_INFMSG("\033[1;34m[Sec Thread] Secure image initializing!\033[0m\r\n");
-#ifdef TFM_CORE_DEBUG
SPMLOG_DBGMSGVAL("TF-M isolation level is: ", TFM_LVL);
- SPMLOG_DBGMSG("\r\n");
-#endif
tfm_core_validate_boot_data();
diff --git a/secure_fw/spm/cmsis_psa/main.c b/secure_fw/spm/cmsis_psa/main.c
index 5aca4dc..8826a73 100644
--- a/secure_fw/spm/cmsis_psa/main.c
+++ b/secure_fw/spm/cmsis_psa/main.c
@@ -77,10 +77,7 @@
SPMLOG_INFMSG("\033[1;34m[Sec Thread] Secure image initializing!\033[0m\r\n");
-#ifdef TFM_CORE_DEBUG
SPMLOG_DBGMSGVAL("TF-M isolation level is: ", TFM_LVL);
- SPMLOG_DBGMSG("\r\n");
-#endif
tfm_core_validate_boot_data();
diff --git a/secure_fw/spm/common/spm_log.c b/secure_fw/spm/common/spm_log.c
index dc0e995..b15f87d 100644
--- a/secure_fw/spm/common/spm_log.c
+++ b/secure_fw/spm/common/spm_log.c
@@ -7,7 +7,7 @@
#include "tfm_spm_log.h"
-#define MAX_DIGIT_BITS 10 /* Max bits of uint32_t value 0xFFFFFFFF add '0x' */
+#define MAX_DIGIT_BITS 12 /* 8 char for number, 2 for '0x' and 2 for '\r\n' */
const static char HEX_TABLE[] = {'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
@@ -22,13 +22,15 @@
static void to_hex(uint32_t value, char msg[])
{
- int i;
+ int i = MAX_DIGIT_BITS - 1;
- msg[0] = '0';
- msg[1] = 'x';
- for (i = MAX_DIGIT_BITS - 1; i >= 2; i--, value >>= 4) {
+ msg[i--] = '\n';
+ msg[i--] = '\r';
+ for (; i > 1; i--, value >>= 4) {
msg[i] = HEX_TABLE[value & 0xF];
}
+ msg[i--] = 'x';
+ msg[i--] = '0';
}
int32_t spm_log_msgval(const char *msg, size_t len, uint32_t value)