Boot loop after building with platformio
Closed this issue · 10 comments
I attempted to follow your various directions, but using platformio rather than the Arduino IDE.
I made this platformio.ini
:
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
sqfmi/Watchy ; @ 1.4.1
https://github.com/tzapu/WiFiManager.git ; #2.0.3-alpha
https://github.com/GuruSR/SmallRTC.git
https://github.com/GuruSR/SmallNTP.git
https://github.com/GuruSR/StableBMA.git
https://github.com/GuruSR/Olson2POSIX.git
lib_ldf_mode = deep+
board_build.partitions = min_spiffs.csv
I did NOT do any of the dark border modifications. (That should be okay, right?) This ended up giving me these package versions (from pio pkg list
):
Resolving esp32dev environment packages...
Platform espressif32 @ 4.4.0 (required: espressif32)
├── framework-arduinoespressif32 @ 3.20003.220626 (required: platformio/framework-arduinoespressif32 @ ~3.20003.0)
├── tool-esptoolpy @ 1.30300.0 (required: platformio/tool-esptoolpy @ ~1.30300.0)
├── tool-mkfatfs @ 2.0.1 (required: platformio/tool-mkfatfs @ ~2.0.0)
├── tool-mklittlefs @ 1.203.210628 (required: platformio/tool-mklittlefs @ ~1.203.0)
├── tool-mkspiffs @ 2.230.0 (required: platformio/tool-mkspiffs @ ~2.230.0)
└── toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3 (required: espressif/toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3)
Libraries
├── Olson2POSIX @ 0.0.0+20220629192147.sha.3e9c4b8 (required: git+https://github.com/GuruSR/Olson2POSIX.git)
├── SmallNTP @ 0.0.0+20220629192146.sha.f1c21fc (required: git+https://github.com/GuruSR/SmallNTP.git)
├── SmallRTC @ 0.0.0+20220629192119.sha.a1c8a33 (required: git+https://github.com/GuruSR/SmallRTC.git)
├── StableBMA @ 0.0.0+20220629192147.sha.e276cf0 (required: git+https://github.com/GuruSR/StableBMA.git)
├── Watchy @ 1.4.1 (required: sqfmi/Watchy)
│ ├── Adafruit GFX Library @ 1.11.3 (required: Adafruit GFX Library)
│ │ └── Adafruit BusIO @ 1.12.0 (required: Adafruit BusIO)
│ ├── Arduino_JSON @ 0.1.0 (required: Arduino_JSON)
│ ├── DS3232RTC @ 2.0.1 (required: DS3232RTC)
│ │ └── Time @ 1.6.1 (required: Time)
│ ├── GxEPD2 @ 1.4.6 (required: GxEPD2)
│ │ └── Adafruit GFX Library @ 1.11.3 (required: Adafruit GFX Library)
│ │ │ └── Adafruit BusIO @ 1.12.0 (required: Adafruit BusIO)
│ ├── NTPClient @ 3.2.1 (required: NTPClient)
│ ├── Rtc_Pcf8563 @ 0.0.0-alpha+sha.6b5adc2ced (required: Rtc_Pcf8563)
│ └── WiFiManager @ 2.0.11-beta+sha.01bd8a3 (required: WiFiManager)
└── WiFiManager @ 2.0.11-beta+sha.01bd8a3 (required: git+https://github.com/tzapu/WiFiManager.git)
After that, I was able to pio run --target upload
and it successfully programmed the watch and it even came up with your pretty text and the time BUT then got itself into a boot loop:
[ 36][E][Wire.cpp:159] begin(): Bus already started in Master Mode.
Guru Meditation Error: Core 1 panic'ed (InstrFetchProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x00000000 PS : 0x00060a30 A0 : 0x801525d0 A1 : 0x3ffb2660
A2 : 0x00000053 A3 : 0x3ffb26cd A4 : 0x00000001 A5 : 0x50000234
A6 : 0x3ffb8a88 A7 : 0x00000000 A8 : 0x8016f976 A9 : 0x3ffb25f0
A10 : 0x00000000 A11 : 0x00000053 A12 : 0x3ffb26cd A13 : 0x00000001
A14 : 0x000000be A15 : 0x00000004 SAR : 0x0000000a EXCCAUSE: 0x00000014
EXCVADDR: 0x00000000 LBEG : 0x4008b031 LEND : 0x4008b045 LCOUNT : 0xffffffff
Backtrace:0xfffffffd:0x3ffb26600x401525cd:0x3ffb2680 0x40152a15:0x3ffb26c0 0x400eb238:0x3ffb26f0 0x400d559e:0x3ffb2720 0x400dee35:0x3ffb2740 0x400d2e9e:0x3ffb27e0 0x400f0d6e:0x3ffb2820
ELF file SHA256: 0000000000000000
Rebooting...
Did I miss an important step somewhere?
Give me a few to validate those libraries that you added, to see if I run into any issues with any of them.
If the issue isn't obvious or known (I was wondering if it was one of the known bad versions) then I can embark on the process of sticking log entries in, and/or trying to figure out how to interpret the crash dump. (Someone somewhere is an Amiga fan lol.) If we get it working maybe we can add a platformio.ini with working versions of things? Happy to send a PR once we get issues sorted out.
Try here with the information on how to get the backtrace output: platformio/platform-espressif32#105
See if that helps, I'm looking at the versions you compiled against the ones I have, maybe more than one library is causing grief.
(Also if you tell me what you've got I can try pinning the version. Whatever's easiest for you.)
For some reason the crash dump had a missing space between the first two backspace entries which caused the filter to fail but I found its implementation and did it by hand, so here's the decoded backtrace:
(python_venv) % /home/egnor/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-addr2line -fipC -e .pio/build/watchy/firmware.elf
0xfffffffd:0x3ffb2630
?? ??:0
0x4015a7ef:0x3ffb2650
bma4_write_regs at /home/egnor/source/Watchy_GSR/.pio/libdeps/watchy/Watchy/src/bma4.c:876
0x4015adc7:0x3ffb2690
bma4_set_int_pin_config at /home/egnor/source/Watchy_GSR/.pio/libdeps/watchy/Watchy/src/bma4.c:2921
0x400f16a4:0x3ffb26c0
StableBMA::defaultConfig() at /home/egnor/source/Watchy_GSR/.pio/libdeps/watchy/StableBMA/src/StableBMA.cpp:364
0x400d56db:0x3ffb26f0
WatchyGSR::_bmaConfig() at /home/egnor/source/Watchy_GSR/src/Watchy_GSR.cpp:2367
0x400e2aa7:0x3ffb2710
WatchyGSR::init(String) at /home/egnor/source/Watchy_GSR/src/Watchy_GSR.cpp:290
0x400d2a45:0x3ffb27e0
setup() at /home/egnor/source/Watchy_GSR/src/GSR.ino:151
0x400f8453:0x3ffb2820
loopTask(void*) at /home/egnor/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:42
I added some log statements:
[ 36][E][GSR.ino:151] setup(): ENTERING setup
[ 37][E][Watchy_GSR.cpp:214] init(): ENTERING WatchyGSR.init
[ 37][E][Wire.cpp:159] begin(): Bus already started in Master Mode.
[ 47][E][Watchy_GSR.cpp:2363] _bmaConfig(): BEFORE SBMA.begin (RTC type=2)
[ 1505][E][Watchy_GSR.cpp:2369] _bmaConfig(): BEFORE SBMA.defaultConfig (RTC type=2),
[ 1565][E][Watchy_GSR.cpp:2372] _bmaConfig(): BEFORE SBMA.enableFeature
[ 1679][E][Watchy_GSR.cpp:2374] _bmaConfig(): AFTER SBMA.enableFeature
[ 36][E][GSR.ino:151] setup(): ENTERING setup
[ 37][E][Watchy_GSR.cpp:214] init(): ENTERING WatchyGSR.init
[ 37][E][Wire.cpp:159] begin(): Bus already started in Master Mode.
[ 71][E][Watchy_GSR.cpp:2363] _bmaConfig(): BEFORE SBMA.begin (RTC type=0)
[ 72][E][Watchy_GSR.cpp:2369] _bmaConfig(): BEFORE SBMA.defaultConfig (RTC type=0)
Guru Meditation Error: Core 1 panic'ed (InstrFetchProhibited). Exception was unhandled.
... the usual crash report follows ...
For some reason it's restarting the firmware, even before we get to the crash; I see multiple entries into the top level setup()
. I have no idea why. I assume this is not expected?
Then, SmallRTC.getType()
is returning 0 (though it returned 2 the first time around!), which causes StableBMA.begin()
to exit early (but without an error!), which means the callback functions aren't initialized, and the subsequent call to StableBMA.enableFeature()
ends up jumping to a null function pointer, which causes the crash we see.
This only raises more questions obviously...
It doesn't seem to be a reliable failure. I see the periodic re-setups, but it doesn't go into the crash reporting all the time. (Once it does, it goes into a rapid crash loop, however.) Something awry with the state of the I2C bus, related to whatever mysterious thing is causing it to reset/restart/re-setup?
I ran into that a while ago, but I rolled back and solved the issue, but I'm not sure what library may be causing that. Oddly, your backtrace has odd line numbers.
This is what I have currently:
Adafruit GFX 1.10.14
Adafruit BusIO 1.9.1
DS3232RTC 2.0.0
GxEPD2 1.4.5
NTPClient 3.2.0
PCF_PCF8563 1.0.3 - Yours has no version, using I'm using: https://github.com/orbitalair/Rtc_Pcf8563
WiFiManager - 2.0.11-beta - SAME, but it is no longer being used, shouldn't be included.
Not sure if you can roll back down for those to see if that makes any difference.
Aha -- turns out platformio's framework-arduinoespressif32 ver 3.20003.220626 is arduino-ESP32 2.0.3, aka the one you already knew was crashy!
To get 2.0.2, I selected framework-arduinoespressif32 ver 3.20002.220503.
Now I still see the periodic restarts
[ 33][E][GSR.ino:151] setup(): ENTERING setup
[ 34][E][Watchy_GSR.cpp:214] init(): ENTERING WatchyGSR.init
[ 34][E][Wire.cpp:159] begin(): Bus already started in Master Mode.
[ 39][E][Watchy_GSR.cpp:279] init(): BEFORE SRTC.init
[ 47][E][Watchy_GSR.cpp:281] init(): AFTER SRTC.init (type=2)
[ 51][E][Watchy_GSR.cpp:2365] _bmaConfig(): BEFORE SBMA.begin (RTC type=2)
[ 1511][E][Watchy_GSR.cpp:2371] _bmaConfig(): BEFORE SBMA.defaultConfig (RTC type=2)
[ 1573][E][Watchy_GSR.cpp:2374] _bmaConfig(): BEFORE SBMA.enableFeature
[ 1689][E][Watchy_GSR.cpp:2376] _bmaConfig(): AFTER SBMA.enableFeature
[ 33][E][GSR.ino:151] setup(): ENTERING setup
[ 34][E][Watchy_GSR.cpp:214] init(): ENTERING WatchyGSR.init
[ 34][E][Wire.cpp:159] begin(): Bus already started in Master Mode.
[ 33][E][GSR.ino:151] setup(): ENTERING setup
[ 34][E][Watchy_GSR.cpp:214] init(): ENTERING WatchyGSR.init
[ 34][E][Wire.cpp:159] begin(): Bus already started in Master Mode.
[ 33][E][GSR.ino:151] setup(): ENTERING setup
[ 34][E][Watchy_GSR.cpp:214] init(): ENTERING WatchyGSR.init
[ 34][E][Wire.cpp:159] begin(): Bus already started in Master Mode.
However, it doesn't try to re-init SRTC, and doesn't run into detection failures.
Reading more about the ESP32's sleep handling, it looks like going back through setup()
is expected after deep sleep. What's not expected are all the attempts to re-initialize things like the RTC. It looks like on 2.0.3, for some reason, the return from esp_sleep_get_wakeup_cause()
isn't always as expected, causing WatchyGSR to go back through the "hard reset" path, which runs into problems sometimes. (Why? And why only sometimes? Unclear.)
(Closing, since the problem is solved! I'll send you a PR with a good platformio.ini to help others.)