cpu/esp8266: fix stdio problems#12133
Conversation
benpicco
left a comment
There was a problem hiding this comment.
Works nicely on esp8266-esp-12x.The UART output looks more in line with other RIOT boards too (no double newlines)
This also saves a good chunk of ROM.
before:
text data bss dec hex
83275 4324 7304 94903 172b
with this patch:
text data bss dec hex
73323 4324 7096 84743 14b07
|
Uh, but Murdock is unhappy I guess |
|
@benpicco Thanks for testing. Unfortunatly, Murdock is not happy yet. There are two apps that aren't compilable anymore:
|
It is not clear for me why the test complains that addresses are equal. I'm a bit unsure if it would be the right way to blacklist ESP8266 for this test. Maybe @cladmi can say more about this test and whether it is really a problem if it fails. |
|
|
The goal of this test was to detect if I had no real idea how to do the detection so used the fact described in the RIOT/tests/libc_newlib/Makefile Lines 23 to 31 in d991883 However, it appears that it is not a reliable condition :'( Could it be that I will try debugging a bit. |
|
TL;DR: Test is right, you just need to add ExplanationAccording to this test the For some toolchain it must be explicitly enabled and handled in the build system but it looks like it is by default for To verify this, I faked enabling newlib_nano in my test, and it detects Configure the test to expect `newlib_nano`diff --git a/tests/libc_newlib/Makefile b/tests/libc_newlib/Makefile
index f21f0761d..f3a4e781c 100644
--- a/tests/libc_newlib/Makefile
+++ b/tests/libc_newlib/Makefile
@@ -2,6 +2,8 @@ include ../Makefile.tests_common
USEMODULE += embunit
+CFLAGS += -DMODULE_NEWLIB_NANO=1
+
include $(RIOTBASE)/Makefile.include
# Compile time tests
@@ -20,6 +22,9 @@ ifneq (,$(filter newlib,$(USEMODULE)))
endif
endif
+# Force trying 'NEWLIB_NANO'
+CMP_OP = =
+
# Newlib-nano removed the integer only 'iprintf' functions which are now mapped
# to printf.
#BUILD_IN_DOCKER=1 DOCKER="sudo docker" BOARD=esp8266-esp-12x make flash termSo this correctly compiles and detects the Lines 39 to 43 in 3901740 Adding `newlib_nano` to `cpu/esp8266` correctly makes this test pass too without modificationsdiff --git a/cpu/esp8266/Makefile.include b/cpu/esp8266/Makefile.include
index 6f2a999c6..3104bd587 100644
--- a/cpu/esp8266/Makefile.include
+++ b/cpu/esp8266/Makefile.include
@@ -62,6 +62,7 @@ PSEUDOMODULES += esp_spiffs
USEMODULE += esp
USEMODULE += mtd
USEMODULE += newlib
+USEMODULE += newlib_nano
USEMODULE += newlib_syscalls_default
USEMODULE += periph
USEMODULE += psI love when tests can do reviews automatically :) |
|
@cladmi Thanks for clarifying that. Indeed, the newlib-xtensa was compiled with |
The overridden stdio functions `puts`, `putchar` and `printf` were removed. Instead, the corresponding newlib functions are always used. Using the newlib functions fixes output conflicts when using `f *` functions like `fprintf`,` fputs`, ... with `stdout` as the file parameter.
The modules `newlib, `newlib_syscalls_default` and `stdio_uart` are now used by default for output to the UART interface. This also reduces the dependency rules.
To avoid unresolved symbols for unused functions during linking, compiler option `-ffunction-sections` is used now. Linker option `--warn-unresolved-symbols` is removed to get errors if required symbols cannot be resolved.
39984ce to
0de34b6
Compare
UART FIFO must contain only 1 byte when newlib's `printf` function is used. Otherwise, outputs that are still not sent over UART are lost when `printf` is called asynchronousely.
0de34b6 to
37ecb4f
Compare
|
@benpicco Murdock is happy now. |
|
And my esp8266 is happy now too! |
|
@benpicco Thanks again for reviewing and testing. |
Contribution description
This PR fixes a problem with the standard output that arose in conjunction with the
i2c_scanproblem described in issue #12125.The problem occurs when stdio functions
puts,putcharandprintfare used together withfputsorfprintfandstdoutas file parameter. While outputs withputsare printed out immediately,outputs with
fputsare not printed out on linefeed but when the internal buffer of 128 bytes is full. As a result, mixing these functions scrambles the output completely.The problem is fixed by removing the overridden stdio functions
puts,putcharandprintf. Instead, the corresponding newlib functions are used always. For this purpose, modulesnewlib,newlib_syscalls_defaultandstdio_uartare now enabled by default which also reduces the number of module dependency rules inMakefile.dep.Testing procedure
Flash and test
examples/defaultwith enabled modulei2c_scanwith commandWithout this PR the output should look like:
With this PR the output should look like:
Issues/PRs references
Related to issue #12125.