From cb4c22da37b2a31aa0ed3bc005df03bd729979d7 Mon Sep 17 00:00:00 2001 From: Indan Zupancic Date: Tue, 19 Nov 2024 11:51:20 +0000 Subject: [PATCH] Avoid garbage on stdout for first print Caused by recursive stdio function calling. Just use seL4_DebugPutString() directly to avoid any problems. Signed-off-by: Indan Zupancic --- libsel4platsupport/src/common.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libsel4platsupport/src/common.c b/libsel4platsupport/src/common.c index a1f130e55..e867f86d4 100644 --- a/libsel4platsupport/src/common.c +++ b/libsel4platsupport/src/common.c @@ -268,8 +268,12 @@ static void __serial_setup() case NOT_INITIALIZED: #ifdef CONFIG_LIB_SEL4_PLAT_SUPPORT_USE_SEL4_DEBUG_PUTCHAR setup_status = SETUP_COMPLETE; - printf("\nWarning: using printf before serial is set up. This only works as your\n"); - printf("printf is backed by seL4_Debug_PutChar()\n"); + /* + * Don't call any stdio functions here, it will cause unexpected recursion + * that will mess up the internal file buffer! + */ + seL4_DebugPutString("\nWarning: using printf before serial is set up. This only works as your\n" + "printf is backed by seL4_Debug_PutChar()\n"); started_regular = 1; #else /* attempt failsafe initialization and print something out */