Esp32 rebboting while upload through PlatformIO

Hi,

I have the working sketch when it uploaded through the Arduino IDE. But when I upload it with PlatformIO - esp32 board always rebooting. is it due to the different libs, or due to PlatformIO is only for hi skils person?..

I tried to copy libs from the Arduino libs folder and put them into my project lib folder (see picture). To use them I added the string: lib_deps = ${common_env_data.lib_deps_builtin} in platformio.ini - is it the right step?

Capture

also - I have a Backtrace of reboot reason - but as I understand PlatformIO cant decode it yet…

The libraries in the project’s lib folder will always be included, so ${common_env_data.lib_deps_builtin} is not needed.

However, I recommend not to use the libs folder unless you need to modify a library. Instead, just list them in platformio.ini and PlatformIO will take care of the rest.

For your case, it could look like so:

lib_deps =
    ArduinoJson
    ESP32WebServer
    UniversalTelegramBot
    OneWire
    ...

I’m not sure what the libraries LOG_Output and Preferences are, so you’ll need to add them to the above snippet.

If it still doesn’t work, shows us your full platformio.ini file and the build output.

1 Like

Dear Manuel, thanks for your reply!
my platformio.ini file

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino

; Скорость загрузки в baud
upload_speed = 921600

; COM-порт для загрузки
; upload_port = COM6

lib_deps =
    ;${common_env_data.lib_deps_builtin}
    ;${common_env_data.lib_deps_external}
    RTClib
    LOG_output
    Preferences1
    ArduinoJson-master
    ESP32WebServer-master
    Universal-Arduino-Telegram-Bot-master

** and the build output:**

rocessing esp32doit-devkit-v1 (platform: espressif32; board: esp32doit-devkit-v1; framework: arduino)

Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: Espressif 32 1.11.1 > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)

PACKAGES: toolchain-xtensa32 2.50200.80 (5.2.0), framework-arduinoespressif32 2.10004.191002 (1.0.4), tool-esptoolpy 1.20600.0 (2.6.0), tool-mkspiffs 2.230.0 (2.30)
LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies…
Dependency Graph
|-- LOG_output>
|-- ArduinoJson> 5.13.3
|-- ESP32WebServer> 1.0
| |-- WiFi> 1.0
| |-- FS> 1.0
|-- HTTPClient> 1.2
| |–WiFi> 1.0
| |-- WiFiClientSecure> 1.0
| | |-- WiFi> 1.0
|-- Preferences> 1.0
|-- RTClib> 1.3.3
| |-- Wire> 1.0.1
|-- UniversalTelegramBot> 1.1.0
| |-- ArduinoJson> 5.13.3
|-- WiFi> 1.0
|-- WiFiClientSecure> 1.0
| |-- WiFi> 1.0
|-- Wire> 1.0.1
Building in release mode
Compiling .pio\build\esp32doit-devkit-v1\src\main.cpp.o
Generating partitions .pio\build\esp32doit-devkit-v1\partitions.bin
Compiling .pio\build\esp32doit-devkit-v1\lib766\LOG_output\LOG_output.cpp.o
Archiving .pio\build\esp32doit-devkit-v1\libb85\libArduinoJson-master.a
Compiling .pio\build\esp32doit-devkit-v1\lib522\WiFi\ETH.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib522\WiFi\WiFi.cpp.o
Archiving .pio\build\esp32doit-devkit-v1\lib766\libLOG_output.a
src\main.cpp: In function ‘void get_cal_value()’:
src\main.cpp:189:58: warning: passing NULL to non-pointer argument 3 of ‘size_t Preferences::getBytes(const char*, void*, size_t)’ [-Wconversion-null]
size_t schLen = eeprom.getBytes(“dosTimers”, NULL, NULL);

                                                      ^

src\main.cpp: In function ‘void Task_WiFi(void*)’:
src\main.cpp:306:13: warning: unused variable ‘cnter’ [-Wunused-variable]
int cnter = 0;
^
src\main.cpp:415:13: warning: unused variable ‘cnter’ [-Wunused-variable]
int cnter = 0;
^
src\main.cpp:278:11: warning: unused variable ‘SD_pH_val’ [-Wunused-variable]
float SD_pH_val;
^
src\main.cpp:279:19: warning: unused variable ‘autodoliv_state’ [-Wunused-variable]
unsigned long autodoliv_state;
^
src\main.cpp:280:10: warning: unused variable ‘protechka_v’ [-Wunused-variable]
byte protechka_v;
^
src\main.cpp:281:10: warning: unused variable ‘emptyFreshW_v’ [-Wunused-variable]
byte emptyFreshW_v;
^
src\main.cpp:282:9: warning: unused variable ‘waterAdd_v’ [-Wunused-variable]
int waterAdd_v;
^
src\main.cpp:266:16: warning: unused variable ‘vtime’ [-Wunused-variable]
unsigned int vtime = 0;
^
src\main.cpp:267:17: warning: unused variable ‘xStatus’ [-Wunused-variable]
portBASE_TYPE xStatus;
^
src\main.cpp:271:17: warning: unused variable ‘vtimewifi’ [-Wunused-variable]
unsigned long vtimewifi = 0;
^
Compiling .pio\build\esp32doit-devkit-v1\lib522\WiFi\WiFiAP.cpp.o
src\main.cpp: In function ‘void Task_dosingPomp(void*)’:
src\main.cpp:716:138: warning: ‘utime’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (dosers_Timers_[pomp].is_off == false && dosers_Timers_[pomp].is_run == false && utime >= dosers_Timers_[pomp].timeStart[i] && utime < dosers_Timers_[pomp].timeStop[i] ) {
^
Compiling .pio\build\esp32doit-devkit-v1\lib522\WiFi\WiFiClient.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib522\WiFi\WiFiGeneric.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib522\WiFi\WiFiMulti.cpp.o

Compiling .pio\build\esp32doit-devkit-v1\lib522\WiFi\WiFiSTA.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib522\WiFi\WiFiScan.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib522\WiFi\WiFiServer.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib522\WiFi\WiFiUdp.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib8bb\FS\FS.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib8bb\FS\vfs_api.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libb5d\ESP32WebServer-master\ESP32WebServer.cpp.o
Archiving .pio\build\esp32doit-devkit-v1\lib522\libWiFi.a
Compiling .pio\build\esp32doit-devkit-v1\libb5d\ESP32WebServer-master\Parsing.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib51f\WiFiClientSecure\WiFiClientSecure.cpp.o
Archiving .pio\build\esp32doit-devkit-v1\lib8bb\libFS.a
Compiling .pio\build\esp32doit-devkit-v1\lib51f\WiFiClientSecure\ssl_client.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\lib37a\HTTPClient\HTTPClient.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\libbfa\Preferences\Preferences1.cpp.o
Archiving .pio\build\esp32doit-devkit-v1\libb5d\libESP32WebServer-master.a
Compiling .pio\build\esp32doit-devkit-v1\libe10\Wire\Wire.cpp.o
Archiving .pio\build\esp32doit-devkit-v1\lib51f\libWiFiClientSecure.a
Compiling .pio\build\esp32doit-devkit-v1\libfc7\RTClib_ID83\RTClib.cpp.o
Archiving .pio\build\esp32doit-devkit-v1\lib37a\libHTTPClient.a
Archiving .pio\build\esp32doit-devkit-v1\libbfa\libPreferences.a
Compiling .pio\build\esp32doit-devkit-v1\lib12a\Universal-Arduino-Telegram-Bot-master\UniversalTelegramBot.cpp.o
Archiving .pio\build\esp32doit-devkit-v1\libFrameworkArduinoVariant.a
Archiving .pio\build\esp32doit-devkit-v1\libe10\libWire.a
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Esp.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\FunctionalInterrupt.cpp.o
Archiving .pio\build\esp32doit-devkit-v1\libfc7\libRTClib_ID83.a
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\HardwareSerial.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\IPAddress.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\IPv6Address.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\MD5Builder.cpp.o
Archiving .pio\build\esp32doit-devkit-v1\lib12a\libUniversal-Arduino-Telegram-Bot-master.a
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Print.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Stream.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\StreamString.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\WMath.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\WString.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\base64.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\cbuf.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-adc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-bt.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-cpu.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-dac.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-gpio.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-i2c.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-ledc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-matrix.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-misc.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-psram.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-rmt.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-sigmadelta.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-spi.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-time.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-timer.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-touch.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\esp32-hal-uart.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\libb64\cdecode.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\libb64\cencode.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\main.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\stdlib_noniso.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\wiring_pulse.c.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\wiring_shift.c.o
Archiving .pio\build\esp32doit-devkit-v1\libFrameworkArduino.a
Linking .pio\build\esp32doit-devkit-v1\firmware.elf
Building .pio\build\esp32doit-devkit-v1\firmware.bin
Retrieving maximum program size .pio\build\esp32doit-devkit-v1\firmware.elf
Checking size .pio\build\esp32doit-devkit-v1\firmware.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
DATA: [= ] 13.7% (used 44768 bytes from 327680 bytes)
PROGRAM: [======= ] 73.5% (used 962774 bytes from 1310720 bytes)
esptool.py v2.6
Configuring upload protocol…
AVAILABLE: esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port…
Auto-detected: COM6
Uploading .pio\build\esp32doit-devkit-v1\firmware.bin
esptool.py v2.6
Serial port COM6
Connecting……__
Chip is ESP32D0WDQ6 (revision 1)

Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
MAC: a4:cf:12:72:a9:9c
Uploading stub…
Running stub…
Stub running…
Changing baud rate to 921600
Changed.
Configuring flash size…
Auto-detected Flash size: 4MB
Compressed 15872 bytes to 10319…

Writing at 0x00001000… (100 %)
Wrote 15872 bytes (10319 compressed) at 0x00001000 in 0.1 seconds (effective 996.9 kbit/s)…
Hash of data verified.
Compressed 3072 bytes to 128…

Writing at 0x00008000… (100 %)
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.0 seconds (effective 1891.8 kbit/s)…
Hash of data verified.
Compressed 8192 bytes to 47…

Writing at 0x0000e000… (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 5456.0 kbit/s)…
Hash of data verified.
Compressed 962896 bytes to 547526…

Writing at 0x00010000… (2 %)


Writing at 0x00094000… (100 %)
Wrote 962896 bytes (547526 compressed) at 0x00010000 in 7.7 seconds (effective 1000.7 kbit/s)…
Hash of data verified.

Leaving…
Hard resetting via RTS pin…
========================= [SUCCESS] Took 65.08 seconds =========================

I forgot to mentioned that you should delete the unmodified publicly available libraries from the lib directory. It looks as if it still takes the libraries from there. But don’t do it right now. I’ve tried to reproduce your setup and it looks as if the latest versions of the libraries you are using don’t work well together. The fact that you could get it to compile indicates that your are using a very specific mix of version.

Since it works in the Arduino IDE, there must be a difference. And the difference is likely in the libraries. It would be good if the Arduino IDE could tell you which of the installed libraries it has effectively used. But it can’t. So you will have to investigate it some more.

I propose the following steps:

  • Turn on verbose output in the Arduino IDE and compare the build output with the output from PlatformIO. There are serious warnings in your output like passing NULL to non-pointer argument 3. If they are not present in the Arduino IDE output, it could point to a difference regarding the libraries.
  • I assume you have copied the libraries from the Arduino libraries directory to the PlatformIO project lib directory. If not, delete the libraries in lib and copy them from the Arduino directory.
  • If it doesn’t help, add Serial.print statement to the code to figure out how far it gets and where it crashes.
  • If still don’t succeed, publish your project so we can reproduce it.
1 Like

Actually, it can… just it’s not as simple/straightforward as PlatformIO is in actually giving it to you there in the compile log. It’s a matter of going Sketch -> Include Library -> Manage Libraries, filtering by those libraries actuallty Installed, and then searching for the library and checking what version it is… simple, right? :confounded:
image

1 Like

I agree you can figure out the version. But:

  • You might have 50 libraries installed. But which ones has the Arduino IDE now used for your project?

  • You might have included file “abc.h”. Which library was now used?

  • You might be using library ABC. Does it depend on other libraries that need to be included as well?

2 Likes

The ones you told it to :stuck_out_tongue:

Same applies to PlatformIO


Anyway, this doesn’t help the OP… as tongue-in-cheek as it may be… We really need to see some actual output from the ESP32 to see if it is indicating why it’s rebooting - any crash / error messages? Plus some answers to the questions you asked.

1 Like

Dear All,

Luckily, Arduino shows the LOG with used libs. So, I copied them into the project lib folder.

Using library Wire at version 1.0.1 in folder: C:\Users\igorlab\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.2\libraries\Wire
Using library RTClib-master at version 1.2.0 in folder: D:\WORK\Dropbox\Ardunio!Programs\libraries\RTClib-master
Using library ESP32WebServer-master at version 1.0 in folder: D:\WORK\Dropbox\Ardunio!Programs\libraries\ESP32WebServer-master
Using library WiFi at version 1.0 in folder: C:\Users\igorlab\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.2\libraries\WiFi
Using library ArduinoJson-master at version 5.13.3 in folder: D:\WORK\Dropbox\Ardunio!Programs\libraries\ArduinoJson-master
Using library Preferences at version 1.0 in folder: C:\Users\igorlab\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.2\libraries\Preferences
Using library WiFiClientSecure at version 1.0 in folder: C:\Users\igorlab\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.2\libraries\WiFiClientSecure
Using library HTTPClient at version 1.2 in folder: C:\Users\igorlab\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.2\libraries\HTTPClient
Using library Universal-Arduino-Telegram-Bot-master at version 1.1.0 in folder: D:\WORK\Dropbox\Ardunio!Programs\libraries\Universal-Arduino-Telegram-Bot-master
Using library FS at version 1.0 in folder: C:\Users\igorlab\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.2\libraries\FS
“C:\Users\igorlab\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-80-g6c4433a-5.2.0/bin/xtensa-esp32-elf-size” -A “C:\Users\igorlab\AppData\Local\Temp\arduino_build_477088/DoserLab_v_1.3.ino.elf”
Sketch uses 953202 bytes (72%) of program storage space. Maximum is 1310720 bytes.
Global variables use 43952 bytes (13%) of dynamic memory, leaving 283728 bytes for local variables. Maximum is 327680 bytes.

Now I haven’t cyclic reboot… Mostly all works fine except the posting data by a POST request, I have the error on output, suppose I have to keep poking around with libs:

11:10:08.880 -> [E][ssl_client.cpp:35] handle_error(): MbedTLS message code: -28928
11:10:08.880 -> [E][ssl_client.cpp:33] handle_error(): SSL - Bad input parameters to function
11:10:08.880 -> [E][ssl_client.cpp:35] handle_error(): MbedTLS message code: -28928
11:10:08.914 -> LabDoser -> ---------> Error on sending POST:
11:10:08.914 -> LabDoser -> httpResponseCode = -2
11:10:08.914 -> [E][ssl_client.cpp:33] handle_error(): SSL - Bad input parameters to function
11:10:08.914 -> [E][ssl_client.cpp:35] handle_error(): MbedTLS message code: -28928
11:10:08.914 -> [E][ssl_client.cpp:33] handle_error(): SSL - Bad input parameters to function
11:10:08.914 -> [E][ssl_client.cpp:35] handle_error(): MbedTLS message code: -28928
11:10:08.914 -> [E][ssl_client.cpp:33] handle_error(): SSL - Bad input parameters to function
11:10:08.948 -> [E][ssl_client.cpp:35] handle_error(): MbedTLS message code: -28928

Thanks, for your answers, it helps me getting into the Plarformio approach to get a good result. This was a hard decision to move from Arduino ide where all works fine but ide is absolutely not adapted for useability. Opposite the Platformio has the best usability but does not use the Arduino approach and due to this, for example, it has a lot of problems with converting the Arduino project with multiple .ino files into thePlatformio project (with .cpp) - but this community allows quickly solve all arising problems - thanks for that.

1 Like

Sorry, but I have one more problem :frowning: after just reloading Atom, Platformio doesn’t see the WiFi lib, but it included into a config file and into the lib folder… what could happen? :sob:

Capture

WiFi is a built-in library for the Arduino-ESP32 framwork. You should remove it from the lib/ folder and remove the WiFi line in lib_deps

Also how do you include WiFi.h? In code it should be #include <WiFi.h>.

Also note that the LDF might have done a mistake there when auto-detecting the needed libraries, so adding lib_ldf_mode = chain+ might help.

After removing a library from lib/ you should reload the the Atom project files by executing pio init --ide=atom (or via a GUI in the extension, don’t know it right now)

2 Likes