platform-espressif8266: Arduino IDE compiling differently that PlatformIO, causing bugs in ESP8266
Configuration
Operating system: Windows 10 64 Bit
PlatformIO Version (platformio --version): PlatformIO, version 3.5.3a8
Description of problem
I’ve got a pretty big (around 4k lines) software written for the ESP8266 (WiFi LED dimmer) which seems to compile differently between Arduino IDE and PIO. The firmware has two TCP servers. One is a webserver and based on the ESP8266WebServer.h and the second one is a simple tcp server which listens to incoming bytes and is based on the ESP8266WiFi.h (class WiFiServer and WiFiClient).
When compiling the software using the Arduino IDE, everything works as expected. When compiling the same software with PIO, the tcp server which is based on ESP8266WiFi.h stops working after serving one request. The webserver and the rest of the devices continues working. However, also Wifi connection issues occur, like SoftAP not working (SSID doesn’t show up).
I have reproduced this many times, it occurs using any ESP8266 core version beginning with 2.2.0 when I use PIO and does NOT occur on any Arduino compiled ESP8266 core, also beginning with 2.2.0 including 2.4.0-rc2.
I can’t isolate the issue so I guess it will be hard to track this one down using the code. Rather, maybe it would be possible to somehow match the compile options of the Arduino IDE and PIO? Something stuff-breaking must be different here?!
I “converted” the Arduino .ino project this way:
- copy .ino content to main.cpp
- change order of functions so that no functions are called which aren’t declared yet - arduino ide doesn’t seem to care about the order
- put setup and loop to the end of the file
The content of platformio.ini:
[env:nodemcuv2]
platform = espressif8266@1.6.0
board = nodemcuv2
framework = arduino
monitor_baud = 115200
There is an addin for Visual Studio, called “VisualMicro” which had a very(!) similar or even exact the same issue. I contacted the developer and after sending him the build logs and a few months he said that there was something wrong with the linking order or something and now it seems to be fixed. So I don’t think that this is an error on my side, although I wouldn’t be opposed to that if it were so.
Please help, i think PIO is REALLY cool stuff, but this is really stuff breaking and I can’t even use it as an IDE and all the cool lib manager/dependency features because the Arduino IDE can’t compile PIO stuff.
Thanks!
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 45 (13 by maintainers)
@d-a-v Thanks! I’ve just updated our package in CDN for 2.4.2, it will use
PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORYprofile automatically if another is not specified.Also, see PR for “stage” version https://github.com/esp8266/Arduino/pull/5305
There is something very funky going on with the PlatformIO build process. I am not sure when it started, but I know I lost really a lot of hours (way over a month times my sparse free time to work on ESPeasy) trying to find lots of reported issues/crashes/etc that I could not reproduce.
You have to make sure to close and re-open Atom with PlatformIO plugin when changing anything in the platformio.ini file or any file outside the editor (e.g. rebase from git) before building again and when you change Arduino core libraries (e.g. 2.3.0 => 2.4.x) you have to build it at least twice to make sure it is working. And still then it is possible the built binaries are not working as intended. Often I see issues with WiFi, especially since working with 2.4.x (Platformio 1.6.0 or higher).
It is really bothering me too, since there is no guarantee the nightly builds we make are working and even worse, among builds in the same run things can get messy. And we’re building it twice already.