I am experiencing intermittent crashes or WDT resets and I am having trouble pinpointing the issue. This only happens with ESP8266. ESP32 and Nano33 IoT are also supported and working fine with no issues.
I suspect it could be memory corruption related. I've tried debugging available RAM at various points and the device always has RAM available
In order to reproduce, please clone the repository to the Arduino sketch directory (I stil haven't published the library) and compile the Xrc20TokenTransferMultiple example using Arduino IDE. You would need to edit secrets.h to input your Wifi credentials
The expected output is that the program just loops and tries to send an action every couple of seconds. If everything works as expected, it should print the following every time the action is sent (Note the result is always error because the account for this private key doesn't have enough balance. This is fine):
Calling contract with data: 0xa9059cbb0000000000000000000000005840bf8e5d3f5b66ee52b9b933bdac9682e386d00000000000000000000000000000000000000000000000000de0b6b3a7640000
Result : ERROR_GRPC
Progrm finished
However, most of the times the ESP8266 crashes, with one of these two errors (I can't figure out why it's sometimes a crash and other times a WDT reboot):
1. WDT reset:
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x4010f000, len 3460, room 16
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4
tail 4
chksum 0xc9
csum 0xc9
v0007b8a0
~ld
2. A Crash with the following stack dump
Decoding stack results
0x4020be3e: iotex::Encoder::protobuf_encodeExecution(iotex::responsetypes::ActionCore_Execution&, unsigned char*, unsigned int) at /Users/Santos/Documents/Arduino/libraries/iotex-client/src/encoder/encoder.cpp line 204
0x4020beab: std::vector >::emplace_back (unsigned char&&) at /Users/Santos/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/xtensa-lx106-elf/include/c++/10.3.0/bits/stl_uninitialized.h line 1022
0x4020b915: Cat > >(std::vector >, std::vector > const&) at /Users/Santos/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/xtensa-lx106-elf/include/c++/10.3.0/bits/stl_uninitialized.h line 1022
0x40209b68: iotex::api::Wallets::sendExecution(unsigned char const*, unsigned char const*, iotex::responsetypes::ActionCore_Execution const&, unsigned char*) at /Users/Santos/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/WString.h line 79
0x40209b2e: iotex::api::Wallets::sendExecution(unsigned char const*, unsigned char const*, iotex::responsetypes::ActionCore_Execution const&, unsigned char*) at /Users/Santos/Documents/Arduino/libraries/iotex-client/src/api/wallet/wallets.cpp line 128
0x40203dfc: generate_k_rfc6979 at /Users/Santos/Documents/Arduino/libraries/iotex-client/src/extern/crypto/rfc6979.c line 44
0x40202bdb: generate_k_random at /Users/Santos/Documents/Arduino/libraries/iotex-client/src/extern/crypto/ecdsa.c line 177
0x4020388a: ecdsa_sign_digest at /Users/Santos/Documents/Arduino/libraries/iotex-client/src/extern/crypto/ecdsa.c line 708
0x40209bc9: iotex::api::Wallets::sendTokenTransfer(unsigned char const*, unsigned char const*, iotex::responsetypes::ActionCore_Transfer const&, unsigned char*) at /Users/Santos/Documents/Arduino/libraries/iotex-client/src/protobuf/pb_api.h line 61
0x40206eac: GetExecutionByHash() at /var/folders/0r/j6fmfyts4r52fxm3czh4_tmc0000gn/T/arduino_modified_sketch_3867/commands.h line 108
0x40205d09: std::_Rb_tree >, std::_Select1st > >, std::less , std::allocator > > >::_M_get_insert_unique_pos(int const&) at /Users/Santos/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/xtensa-lx106-elf/include/c++/10.3.0/bits/move.h line 76
0x4020c814: iotex::Host::set(char const*, int, char const*) at /Users/Santos/Documents/Arduino/libraries/iotex-client/src/host/host.cpp line 28
0x402063c9: AddData() at /var/folders/0r/j6fmfyts4r52fxm3czh4_tmc0000gn/T/arduino_modified_sketch_3867/commands.h line 294
0x402063a6: AddData() at /Users/Santos/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/WString.h line 277
0x40209e24: iotex::api::Wallets::getAccount(char const*, iotex::responsetypes::AccountMeta&) at /Users/Santos/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/WString.h line 298
0x40209e30: iotex::api::Wallets::getAccount(char const*, iotex::responsetypes::AccountMeta&) at /Users/Santos/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/WString.h line 298
0x40209e24: iotex::api::Wallets::getAccount(char const*, iotex::responsetypes::AccountMeta&) at /Users/Santos/Library/Arduino15/packages/esp8266/hardware/esp8266/3.0.2/cores/esp8266/WString.h line 298
0x4020b984: std::vector >::vector(unsigned int, std::allocator const&) at /Users/Santos/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/xtensa-lx106-elf/include/c++/10.3.0/bits/stl_vector.h line 512
Please note this works for ESP32, so I doubt the code in my library is the cause (except for the high RAM usage which could corrupt the heap)
Could you let me know what steps I could take to troubleshoot this?
Many thanks