App: Change printf to tfm_log_printf
Implement stdio output of NS USART and change the 'printf' in
non-secure App to 'tfm_log_printf'. Use 'tfm_log_printf' from
'interface' folder for the substitute.
Change-Id: I871ea999adb525879cc2f1e3183036feb6d1a671
Signed-off-by: Mingyang Sun <mingyang.sun@arm.com>
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index c371ec2..15faf1a 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -68,11 +68,14 @@
message(FATAL_ERROR "Incomplete build configuration: TFM_PSA_API is undefined.")
endif()
+embedded_include_directories(PATH ${TFM_ROOT_DIR}/app ABSOLUTE)
+
set(NS_APP_SRC "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Config/RTX_Config.c"
"${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Source/rtx_lib.c"
"${APP_DIR}/main_ns.c"
"${APP_DIR}/tfm_integ_test.c"
"${APP_DIR}/os_wrapper_cmsis_rtos_v2.c"
+ "${TFM_ROOT_DIR}/interface/src/log/tfm_log_raw.c"
)
if (NOT DEFINED TFM_MULTI_CORE_TOPOLOGY OR NOT TFM_MULTI_CORE_TOPOLOGY)
diff --git a/app/main_ns.c b/app/main_ns.c
index 5168ef2..89c0be5 100644
--- a/app/main_ns.c
+++ b/app/main_ns.c
@@ -32,6 +32,20 @@
/* For UART the CMSIS driver is used */
extern ARM_DRIVER_USART NS_DRIVER_STDIO;
+int stdio_output_string(const unsigned char *str, uint32_t len)
+{
+ int32_t ret;
+
+ ret = NS_DRIVER_STDIO.Send(str, len);
+ if (ret != ARM_DRIVER_OK) {
+ return 0;
+ }
+ /* Add a busy wait after sending. */
+ while (NS_DRIVER_STDIO.GetStatus().tx_busy);
+
+ return NS_DRIVER_STDIO.GetTxCount();
+}
+
/**
* \brief Modified table template for user defined SVC functions
*
diff --git a/app/tfm_integ_test.h b/app/tfm_integ_test.h
index 8b52ba0..236e9ef 100644
--- a/app/tfm_integ_test.h
+++ b/app/tfm_integ_test.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <cmsis_compiler.h>
+#include "log/tfm_log_raw.h"
#ifndef __TFM_INTEG_TEST_H__
#define __TFM_INTEG_TEST_H__
@@ -49,7 +50,7 @@
{
/* if IPSR is non-zero, exception is active. NOT banked S/NS */
if (!__get_IPSR()) {
- printf("\t\033[1;32m[Non-Sec] %s\033[0m\r\n", MSG);
+ tfm_log_printf("\t\033[1;32m[Non-Sec] %s\033[0m\r\n", MSG);
}
}
diff --git a/app/uart_stdout.h b/app/uart_stdout.h
new file mode 100644
index 0000000..7c69c71
--- /dev/null
+++ b/app/uart_stdout.h
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __UART_STDOUT_H__
+#define __UART_STDOUT_H__
+
+#include <stdint.h>
+
+/**
+ * \brief Output buffer by STDIO.
+ */
+int stdio_output_string(const unsigned char *str, uint32_t len);
+
+#endif /* __UART_STDOUT_H__ */