-
Notifications
You must be signed in to change notification settings - Fork 2.1k
native: fputs and fprintf not printed correctly #21910
Copy link
Copy link
Closed
Description
Description
Strings printed to stdout on native using fputs/fprintf instead of puts/printf do not show up until pyterm is exited. All output is shown immediately when using make cleanterm, i.e., just calling the native binary. I suspect this points to an issue in RIOT native where stdout would somehow not result to the stdout used by puts/printf that is consumed by pyterm.
Steps to reproduce the issue
Apply the following diff:
diff --git a/examples/basic/hello-world/Makefile b/examples/basic/hello-world/Makefile
index ad1fa6fdcb..14dbbb2fdd 100644
--- a/examples/basic/hello-world/Makefile
+++ b/examples/basic/hello-world/Makefile
@@ -12,6 +12,8 @@ RIOTBASE ?= $(CURDIR)/../../..
# development process:
DEVELHELP ?= 1
+USEMODULE += ztimer_msec
+
# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1
diff --git a/examples/basic/hello-world/main.c b/examples/basic/hello-world/main.c
index c1fe9bae12..5f25b23b7d 100644
--- a/examples/basic/hello-world/main.c
+++ b/examples/basic/hello-world/main.c
@@ -18,6 +18,8 @@
#include <stdio.h>
+#include "ztimer.h"
+
int main(void)
{
puts("Hello World!");
@@ -25,5 +27,13 @@ int main(void)
printf("You are running RIOT on a(n) %s board.\n", RIOT_BOARD);
printf("This board features a(n) %s CPU.\n", RIOT_CPU);
+ while (1) {
+ fputs("fputs\n", stdout);
+ puts("puts");
+ fprintf(stdout, "fprintf\n");
+ printf("printf\n");
+ ztimer_sleep(ZTIMER_MSEC, 1000);
+ }
+
return 0;
}and run make -C examples/basic/hello-world flash term on native (it works on actual hardware, tested with nrf52840dk).
Expected results
repeatedly printing
2025-11-24 13:20:50,083 # fputs
2025-11-24 13:20:50,084 # puts
2025-11-24 13:20:50,084 # fprintf
2025-11-24 13:20:50,084 # printf
Actual results
only printing
2025-11-24 13:21:30,780 # puts
2025-11-24 13:21:30,780 # printf
until exiting pyterm, which prints out the rest:
2025-11-24 13:21:42,532 # Exiting Pyterm
2025-11-24 13:21:42,533 # native: exiting
2025-11-24 13:21:42,535 # fputs
2025-11-24 13:21:42,535 # fprintf
...
It works as expected with make cleanterm (without pyterm) on native. It also worked with pyterm before #20172
Versions
Current master
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels