[riot-notifications] [RIOT-OS/RIOT] cpu/esp8266: fix stdio problems (#12133)

Gaëtan Harter notifications at github.com
Mon Sep 2 12:24:40 CEST 2019


TL;DR: Test is right, you just need to add `USEMODULE += newlib_nano` after the `USEMODULE += newlib` to declare it in the build system, and verify everything else keeps working :D 

#### Explanation

According to this test the `esp8266` newlib is using the `newlib-nano` specs.
So the test is correct and showing an error in the configuration.

For some toolchain it must be explicitly enabled and handled in the build system but it looks like it is by default for `esp8266`. However, we rely on having the `newlib_nano` to be in `USEMODULE`.


To verify this, I faked enabling newlib_nano in my test, and it detects `newlib_nano`:

<details><summary>Configure the test to expect `newlib_nano`</summary>

```diff
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.
 #
```
</details>

<details><summary>BUILD_IN_DOCKER=1 DOCKER="sudo docker" BOARD=esp8266-esp-12x make flash term</summary>

```
...
Test: comparing addresses of 'printf' and 'iprintf' symbols
[SUCCESS] '40101cf8' = '40101cf8' is True
...
2019-09-02 12:15:11,712 - INFO # sysmem: 5116 (used 612, free 4504)
2019-09-02 12:15:11,712 - INFO # 
2019-09-02 12:15:11,713 - INFO # Board configuration:
2019-09-02 12:15:11,715 - INFO # 	PWM_DEV(0): channelmain(): This is RIOT! (Version: 2019.10-devel-559-g39984c-pr/riot/12133/fix_stdio_problems)
2019-09-02 12:15:11,715 - INFO # Newlib/nano test
2019-09-02 12:15:11,715 - INFO # .
2019-09-02 12:15:11,715 - INFO # OK (1 tests)
2019-09-02 12:15:57,686 - INFO # Exiting Pyterm
```
</details>

So this correctly compiles and detects the `_NANO_FORMATTED_IO` macro.

https://github.com/RIOT-OS/RIOT/blob/3901740ef219389d63ff859213f3c3b22c0ec45f/tests/libc_newlib/main.c#L39-L43


<details><summary>Adding `newlib_nano` to `cpu/esp8266` correctly makes this test pass too without modifications</summary>

``` diff
diff --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 += ps
```
</details>

I love when tests can do reviews automatically :)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/12133#issuecomment-527094777
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190902/c964f094/attachment.htm>


More information about the notifications mailing list