Build: Disable NSPE log by default with eRPC
Make the logging from NSPE optional and disable it by default
when eRPC is used to prevent message collision.
Change-Id: I517c334fe0ea6d79572b499947f2c159e4a10707
Signed-off-by: David Vincze <david.vincze@arm.com>
diff --git a/app_broker/CMakeLists.txt b/app_broker/CMakeLists.txt
index fd009d2..9870f8d 100644
--- a/app_broker/CMakeLists.txt
+++ b/app_broker/CMakeLists.txt
@@ -123,7 +123,7 @@
)
endif()
-# TF-M ns logging
+# TF-M NS logging
add_library(tfm_ns_log STATIC EXCLUDE_FROM_ALL)
target_sources(tfm_ns_log
@@ -136,6 +136,11 @@
${APP_LIB_DIR}/log/
)
+target_compile_definitions(tfm_ns_log
+ INTERFACE
+ $<$<NOT:$<BOOL:${TFM_NS_LOG_DISABLE}>>:TFM_NS_LOG>
+)
+
target_link_libraries(tfm_ns_log
PRIVATE
platform_ns
diff --git a/erpc/server/app/CMakeLists.txt b/erpc/server/app/CMakeLists.txt
index 2a5a7cd..ad9cca7 100644
--- a/erpc/server/app/CMakeLists.txt
+++ b/erpc/server/app/CMakeLists.txt
@@ -37,6 +37,12 @@
set(ERPC_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
+# Disable NS log by default to avoid the eRPC messages to be interspersed with
+# log messages and ultimately corrupting them.
+# Log messages can be enabled per platform if the separation of eRPC messages
+# from the rest of the communication can be guaranteed.
+set(TFM_NS_LOG_DISABLE ON CACHE BOOL "Whether to disable log messages from NSPE")
+
add_subdirectory(${ERPC_DIR}/server ${CMAKE_CURRENT_BINARY_DIR}/server)
add_subdirectory(../../../app_broker ${CMAKE_BINARY_DIR}/app_broker)
diff --git a/lib/log/tfm_log.h b/lib/log/tfm_log.h
index 5563434..5d5e649 100644
--- a/lib/log/tfm_log.h
+++ b/lib/log/tfm_log.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2024, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -12,6 +12,10 @@
/* Functions and macros in this file is for 'thread mode' usage. */
+#ifdef TFM_NS_LOG
#define LOG_MSG(...) tfm_log_printf(__VA_ARGS__)
+#else
+#define LOG_MSG(...)
+#endif
#endif /* __TFM_LOG_H__ */