Merge changes from topic "early_console" into integration
* changes:
feat(stm32mp2): use early traces
feat(st-bsec): use early traces
refactor(st): replace STM32MP_EARLY_CONSOLE with EARLY_CONSOLE
feat(console): introduce EARLY_CONSOLE
feat(bl32): create an sp_min_setup function
diff --git a/Makefile b/Makefile
index 2902774..57e27ca 100644
--- a/Makefile
+++ b/Makefile
@@ -1206,6 +1206,7 @@
ENABLE_CONSOLE_GETC \
INIT_UNUSED_NS_EL2 \
PLATFORM_REPORT_CTX_MEM_USE \
+ EARLY_CONSOLE \
)))
# Numeric_Flags
@@ -1403,6 +1404,7 @@
ENABLE_CONSOLE_GETC \
INIT_UNUSED_NS_EL2 \
PLATFORM_REPORT_CTX_MEM_USE \
+ EARLY_CONSOLE \
)))
ifeq (${PLATFORM_REPORT_CTX_MEM_USE}, 1)
diff --git a/bl1/bl1_main.c b/bl1/bl1_main.c
index 9f19b4a..2b3a827 100644
--- a/bl1/bl1_main.c
+++ b/bl1/bl1_main.c
@@ -44,6 +44,9 @@
******************************************************************************/
void bl1_setup(void)
{
+ /* Enable early console if EARLY_CONSOLE flag is enabled */
+ plat_setup_early_console();
+
/* Perform early platform-specific setup */
bl1_early_platform_setup();
diff --git a/bl2/bl2_main.c b/bl2/bl2_main.c
index 4c68f07..f12c1a5 100644
--- a/bl2/bl2_main.c
+++ b/bl2/bl2_main.c
@@ -42,6 +42,9 @@
void bl2_el3_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2,
u_register_t arg3)
{
+ /* Enable early console if EARLY_CONSOLE flag is enabled */
+ plat_setup_early_console();
+
/* Perform early platform-specific setup */
bl2_el3_early_platform_setup(arg0, arg1, arg2, arg3);
@@ -64,6 +67,9 @@
void bl2_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2,
u_register_t arg3)
{
+ /* Enable early console if EARLY_CONSOLE flag is enabled */
+ plat_setup_early_console();
+
/* Perform early platform-specific setup */
bl2_early_platform_setup2(arg0, arg1, arg2, arg3);
diff --git a/bl31/bl31_main.c b/bl31/bl31_main.c
index c0e9144..83be0f6 100644
--- a/bl31/bl31_main.c
+++ b/bl31/bl31_main.c
@@ -95,6 +95,9 @@
void bl31_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2,
u_register_t arg3)
{
+ /* Enable early console if EARLY_CONSOLE flag is enabled */
+ plat_setup_early_console();
+
/* Perform early platform-specific setup */
bl31_early_platform_setup2(arg0, arg1, arg2, arg3);
diff --git a/bl32/sp_min/aarch32/entrypoint.S b/bl32/sp_min/aarch32/entrypoint.S
index 693dd4b..ba9d90d 100644
--- a/bl32/sp_min/aarch32/entrypoint.S
+++ b/bl32/sp_min/aarch32/entrypoint.S
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2023, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -118,8 +118,7 @@
mov r1, r10
mov r2, r11
mov r3, r12
- bl sp_min_early_platform_setup2
- bl sp_min_plat_arch_setup
+ bl sp_min_setup
/* Jump to the main function */
bl sp_min_main
diff --git a/bl32/sp_min/sp_min_main.c b/bl32/sp_min/sp_min_main.c
index 61feaec..a26910c 100644
--- a/bl32/sp_min/sp_min_main.c
+++ b/bl32/sp_min/sp_min_main.c
@@ -171,6 +171,20 @@
}
/******************************************************************************
+ * The SP_MIN setup function. Calls platforms init functions
+ *****************************************************************************/
+void sp_min_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2,
+ u_register_t arg3)
+{
+ /* Enable early console if EARLY_CONSOLE flag is enabled */
+ plat_setup_early_console();
+
+ /* Perform early platform-specific setup */
+ sp_min_early_platform_setup2(arg0, arg1, arg2, arg3);
+ sp_min_plat_arch_setup();
+}
+
+/******************************************************************************
* The SP_MIN main function. Do the platform and PSCI Library setup. Also
* initialize the runtime service framework.
*****************************************************************************/
diff --git a/bl32/sp_min/sp_min_private.h b/bl32/sp_min/sp_min_private.h
index 628581a..9c6b5fb 100644
--- a/bl32/sp_min/sp_min_private.h
+++ b/bl32/sp_min/sp_min_private.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -7,6 +7,10 @@
#ifndef SP_MIN_PRIVATE_H
#define SP_MIN_PRIVATE_H
+#include <stdint.h>
+
+void sp_min_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2,
+ u_register_t arg3);
void sp_min_main(void);
void sp_min_warm_boot(void);
void sp_min_fiq(void);
diff --git a/bl32/tsp/tsp_common.c b/bl32/tsp/tsp_common.c
index 908b4ff..3a6c9d9 100644
--- a/bl32/tsp/tsp_common.c
+++ b/bl32/tsp/tsp_common.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2022-2024, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -66,6 +66,9 @@
******************************************************************************/
void tsp_setup(void)
{
+ /* Enable early console if EARLY_CONSOLE flag is enabled */
+ plat_setup_early_console();
+
/* Perform early platform-specific setup. */
tsp_early_platform_setup();
diff --git a/docs/getting_started/build-options.rst b/docs/getting_started/build-options.rst
index c18c155..2892dc6 100644
--- a/docs/getting_started/build-options.rst
+++ b/docs/getting_started/build-options.rst
@@ -230,6 +230,13 @@
contributions are still expected to build with ``W=0`` and ``E=1`` (the
default).
+- ``EARLY_CONSOLE``: This option is used to enable early traces before default
+ console is properly setup. It introduces EARLY_* traces macros, that will
+ use the non-EARLY traces macros if the flag is enabled, or do nothing
+ otherwise. To use this feature, platforms will have to create the function
+ plat_setup_early_console().
+ Default is 0 (disabled)
+
- ``EL3_PAYLOAD_BASE``: This option enables booting an EL3 payload instead of
the normal boot flow. It must specify the entry point address of the EL3
payload. Please refer to the "Booting an EL3 payload" section for more
diff --git a/docs/plat/st/stm32mpus.rst b/docs/plat/st/stm32mpus.rst
index ab6d8fe..7b47112 100644
--- a/docs/plat/st/stm32mpus.rst
+++ b/docs/plat/st/stm32mpus.rst
@@ -54,8 +54,6 @@
| Default: stm32mp157c-ev1.dtb
- | ``DWL_BUFFER_BASE``: the 'serial boot' load address of FIP,
| default location (end of the first 128MB) is used when absent
-- | ``STM32MP_EARLY_CONSOLE``: to enable early traces before clock driver is setup.
- | Default: 0 (disabled)
- | ``STM32MP_RECONFIGURE_CONSOLE``: to re-configure crash console (especially after BL2).
| Default: 0 (disabled)
- | ``STM32MP_UART_BAUDRATE``: to select UART baud rate.
diff --git a/docs/porting-guide.rst b/docs/porting-guide.rst
index c25c8cb..a7600ec 100644
--- a/docs/porting-guide.rst
+++ b/docs/porting-guide.rst
@@ -3286,6 +3286,17 @@
data on the designated crash console. It should only use general purpose
registers x0 through x5 to do its work.
+Function : plat_setup_early_console [optional]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+::
+
+ Argument : void
+ Return : void
+
+This API is used to setup the early console, it is required only if the flag
+``EARLY_CONSOLE`` is enabled.
+
.. _External Abort handling and RAS Support:
External Abort handling and RAS Support
@@ -3572,7 +3583,7 @@
--------------
-*Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved.*
+*Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.*
.. _PSCI: https://developer.arm.com/documentation/den0022/latest/
.. _Arm Generic Interrupt Controller version 2.0 (GICv2): http://infocenter.arm.com/help/topic/com.arm.doc.ihi0048b/index.html
diff --git a/drivers/st/bsec/bsec2.c b/drivers/st/bsec/bsec2.c
index a6e5220..db07d1c 100644
--- a/drivers/st/bsec/bsec2.c
+++ b/drivers/st/bsec/bsec2.c
@@ -166,11 +166,13 @@
struct dt_node_info bsec_info;
if (fdt_get_address(&fdt) == 0) {
+ EARLY_ERROR("%s: DT not found\n", __func__);
panic();
}
node = bsec_get_dt_node(&bsec_info);
if (node < 0) {
+ EARLY_ERROR("%s: BSEC node not found\n", __func__);
panic();
}
@@ -226,13 +228,21 @@
*/
uint32_t bsec_probe(void)
{
+ uint32_t version;
+ uint32_t id;
+
if (is_otp_invalid_mode()) {
+ EARLY_ERROR("%s: otp_invalid_mod\n", __func__);
return BSEC_ERROR;
}
- if (((bsec_get_version() != BSEC_IP_VERSION_1_1) &&
- (bsec_get_version() != BSEC_IP_VERSION_2_0)) ||
- (bsec_get_id() != BSEC_IP_ID_2)) {
+ version = bsec_get_version();
+ id = bsec_get_id();
+
+ if (((version != BSEC_IP_VERSION_1_1) &&
+ (version != BSEC_IP_VERSION_2_0)) ||
+ (id != BSEC_IP_ID_2)) {
+ EARLY_ERROR("%s: version = 0x%x, id = 0x%x\n", __func__, version, id);
panic();
}
diff --git a/drivers/st/bsec/bsec3.c b/drivers/st/bsec/bsec3.c
index a803a3a..3fdaf16 100644
--- a/drivers/st/bsec/bsec3.c
+++ b/drivers/st/bsec/bsec3.c
@@ -188,7 +188,7 @@
uint32_t id = bsec_get_id();
if ((version != BSEC_IP_VERSION_1_0) || (id != BSEC_IP_ID_3)) {
- ERROR("%s: version = 0x%x, id = 0x%x\n", __func__, version, id);
+ EARLY_ERROR("%s: version = 0x%x, id = 0x%x\n", __func__, version, id);
panic();
}
diff --git a/include/common/debug.h b/include/common/debug.h
index 5ea541d..0ddb400 100644
--- a/include/common/debug.h
+++ b/include/common/debug.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -91,6 +91,12 @@
# define VERBOSE(...) no_tf_log(LOG_MARKER_VERBOSE __VA_ARGS__)
#endif
+#if EARLY_CONSOLE
+#define EARLY_ERROR(...) ERROR(__VA_ARGS__)
+#else /* !EARLY_CONSOLE */
+#define EARLY_ERROR(...) no_tf_log(LOG_MARKER_ERROR __VA_ARGS__)
+#endif /* EARLY_CONSOLE */
+
const char *get_el_str(unsigned int el);
#if ENABLE_BACKTRACE
diff --git a/include/plat/common/platform.h b/include/plat/common/platform.h
index 2af49a9..ce5e8e0 100644
--- a/include/plat/common/platform.h
+++ b/include/plat/common/platform.h
@@ -184,6 +184,14 @@
}
#endif /* MEASURED_BOOT */
+#if EARLY_CONSOLE
+void plat_setup_early_console(void);
+#else
+static inline void plat_setup_early_console(void)
+{
+}
+#endif /* EARLY_CONSOLE */
+
/*******************************************************************************
* Mandatory BL1 functions
******************************************************************************/
diff --git a/make_helpers/defaults.mk b/make_helpers/defaults.mk
index 26d2a00..b9ea810 100644
--- a/make_helpers/defaults.mk
+++ b/make_helpers/defaults.mk
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2016-2023, Arm Limited. All rights reserved.
+# Copyright (c) 2016-2024, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -392,3 +392,6 @@
# Enable context memory usage reporting during BL31 setup.
PLATFORM_REPORT_CTX_MEM_USE := 0
+
+# Enable early console
+EARLY_CONSOLE := 0
diff --git a/plat/st/common/common.mk b/plat/st/common/common.mk
index b9b62c0..7ef7665 100644
--- a/plat/st/common/common.mk
+++ b/plat/st/common/common.mk
@@ -6,7 +6,6 @@
RESET_TO_BL2 := 1
-STM32MP_EARLY_CONSOLE ?= 0
STM32MP_RECONFIGURE_CONSOLE ?= 0
STM32MP_UART_BAUDRATE ?= 115200
@@ -82,7 +81,6 @@
$(eval $(call assert_booleans,\
$(sort \
PLAT_XLAT_TABLES_DYNAMIC \
- STM32MP_EARLY_CONSOLE \
STM32MP_EMMC \
STM32MP_EMMC_BOOT \
STM32MP_RAW_NAND \
@@ -104,7 +102,6 @@
$(sort \
PLAT_XLAT_TABLES_DYNAMIC \
STM32_TF_VERSION \
- STM32MP_EARLY_CONSOLE \
STM32MP_EMMC \
STM32MP_EMMC_BOOT \
STM32MP_RAW_NAND \
diff --git a/plat/st/common/include/stm32mp_common.h b/plat/st/common/include/stm32mp_common.h
index a1ed1ad..41b86ae 100644
--- a/plat/st/common/include/stm32mp_common.h
+++ b/plat/st/common/include/stm32mp_common.h
@@ -77,14 +77,6 @@
/* Setup the UART console */
int stm32mp_uart_console_setup(void);
-#if STM32MP_EARLY_CONSOLE
-void stm32mp_setup_early_console(void);
-#else
-static inline void stm32mp_setup_early_console(void)
-{
-}
-#endif
-
/*
* Platform util functions for the GPIO driver
* @bank: Target GPIO bank ID as per DT bindings
diff --git a/plat/st/common/stm32mp_common.c b/plat/st/common/stm32mp_common.c
index a1d1c49..6f36011 100644
--- a/plat/st/common/stm32mp_common.c
+++ b/plat/st/common/stm32mp_common.c
@@ -269,8 +269,8 @@
return 0;
}
-#if STM32MP_EARLY_CONSOLE
-void stm32mp_setup_early_console(void)
+#if EARLY_CONSOLE
+void plat_setup_early_console(void)
{
#if defined(IMAGE_BL2) || STM32MP_RECONFIGURE_CONSOLE
plat_crash_console_init();
@@ -278,7 +278,7 @@
set_console(STM32MP_DEBUG_USART_BASE, STM32MP_DEBUG_USART_CLK_FRQ);
NOTICE("Early console setup\n");
}
-#endif /* STM32MP_EARLY_CONSOLE */
+#endif /* EARLY_CONSOLE */
/*****************************************************************************
* plat_is_smccc_feature_available() - This function checks whether SMCCC
diff --git a/plat/st/stm32mp1/bl2_plat_setup.c b/plat/st/stm32mp1/bl2_plat_setup.c
index 798c033..bd3903d 100644
--- a/plat/st/stm32mp1/bl2_plat_setup.c
+++ b/plat/st/stm32mp1/bl2_plat_setup.c
@@ -142,8 +142,6 @@
u_register_t arg2 __unused,
u_register_t arg3 __unused)
{
- stm32mp_setup_early_console();
-
stm32mp_save_boot_ctx_address(arg0);
}
diff --git a/plat/st/stm32mp1/sp_min/sp_min_setup.c b/plat/st/stm32mp1/sp_min/sp_min_setup.c
index 245b2d3..7bfe6ba 100644
--- a/plat/st/stm32mp1/sp_min/sp_min_setup.c
+++ b/plat/st/stm32mp1/sp_min/sp_min_setup.c
@@ -116,8 +116,6 @@
bl_params_t *params_from_bl2 = (bl_params_t *)arg0;
uintptr_t dt_addr = arg1;
- stm32mp_setup_early_console();
-
/* Imprecise aborts can be masked in NonSecure */
write_scr(read_scr() | SCR_AW_BIT);
diff --git a/plat/st/stm32mp2/bl2_plat_setup.c b/plat/st/stm32mp2/bl2_plat_setup.c
index a7cce62..724209a 100644
--- a/plat/st/stm32mp2/bl2_plat_setup.c
+++ b/plat/st/stm32mp2/bl2_plat_setup.c
@@ -18,7 +18,6 @@
u_register_t arg2 __unused,
u_register_t arg3 __unused)
{
- stm32mp_setup_early_console();
}
void bl2_platform_setup(void)
@@ -28,7 +27,7 @@
void bl2_el3_plat_arch_setup(void)
{
if (stm32_otp_probe() != 0U) {
- ERROR("OTP probe failed\n");
+ EARLY_ERROR("OTP probe failed\n");
panic();
}
}