calling begin() on Wiznet5500lwIP driver without hardware being connected crashes
- Dominant language
- C++
- Stars
- 16.7k
- Forks
- 13.1k
- PR merge metrics
- No merged PRs in 30d
Description
### Basic Infos
- [ X] This issue complies with the [issue POLICY doc](https://github.com/esp8266/Arduino/blob/master/POLICY.md).
- [ X] I have read the documentation at [readthedocs](https://arduino-esp8266.readthedocs.io/en/latest) and the issue is not addressed there.
- [ ] I have tested that the issue is present in current master branch (aka latest git).
- [X ] I have searched the issue tracker for a similar issue.
- [X ] If there is a stack dump, I have decoded it.
- [X ] I have filled out all fields below.
#### Platform
- Hardware: ESP12E
- Core Version: Espressif 8266 (3.2.0)
- Development Env: PLatform IO framework-arduinoespressif8266 3.30002.0 (3.0.2)
- Operating System: Windows
### Settings in IDE
- Module: WeMos D1 R2 and mini
- Flash Mode: ?
- Flash Size: 4MB
- lwip Variant: default
- Reset Method: ?
- Flash Frequency: [40Mhz]
- CPU Frequency: 80Mhz
- Upload Using: OTA & SERIAL
- Upload Speed: 115200
### Problem Description
I use the Wiznet5500lwIP driver to drive a W5500 chip. The host ESP can use either wifi or ethernet.
Therefore the chip is only powered if a physical switch is set on the board to allow saving energy if user choose wifi
The problem is that when callig begin() of the driver, it crashes (see dump) if the W5500 is not powered up.
### [MCVE](https://stackoverflow.com/help/mcve) Sketch
```cpp
#include
Wiznet5500lwIP ethDriver(D2);
cableLink = ethDriver.begin(mac);
if (cableLink) {
ESP.wdtDisable();
loopElapsedTime = millis();
while (!ethDriver.connected() && (millis() - loopElapsedTime < ETHCONNECTTIMEOUT)) ;
ESP.wdtEnable(1000);
}
if (!ethDriver.connected()) {
cableLink = false;
ethDriver.end();
WiFi.mode(WIFI_STA);
if (!connectWiFi()){
stopWifi();
WiFi.mode(WIFI_AP_STA);
WiFi.softAP(conf.getValue(MODCONFAPNAME), "", random(12) + 1, false, 1);
}
}
```
### Debug Messages
Soft WDT reset
>>>stack>>>
0x4023678e in Wiznet5500::wizchip_spi_write_byte(unsigned char) at lib\lwIP_w5500\src\utility/w5500.h:203
(inlined by) Wiznet5500::wizchip_read(unsigned char, unsigned short) at lib\lwIP_w5500\src\utility/w5500.cpp:47
0x402369cc in Wiznet5500::setSn_CR(unsigned char) at lib\lwIP_w5500\src\utility/w5500.cpp:126
0x40236cef in Wiznet5500::getSn_SR() at lib\lwIP_w5500\src\utility/w5500.h:687
(inlined by) Wiznet5500::begin(unsigned char const*) at lib\lwIP_w5500\src\utility/w5500.cpp:366
0x4020ef8f in LwipIntfDev::begin(unsigned char const*, unsigned short) at C:\Users\progman\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/LwipIntfDev.h:169
0x4023a8e8 in String::changeBuffer(unsigned int) at C:\Users\progman\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/WString.cpp:202
0x4023c53c in esp_yield at C:\Users\progman\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/core_esp8266_main.cpp:123
0x4023cee1 in __delay at C:\Users\progman\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/core_esp8266_wiring.cpp:57
0x4022fab8 in std::enable_if >, std::is_move_constructible, std::is_move_assignable >::value, void>::type std::swap(std::_Any_data&, std::_Any_data&) at c:\users\progman\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\10.3.0\bits/move.h:197
(inlined by) std::function::swap(std::function&) at c:\users\progman\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\10.3.0\bits/std_function.h:483
(inlined by) std::function::operator=(std::function const&) at c:\users\progman\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\10.3.0\bits/std_function.h:398
(inlined by) Pinger::OnReceive(std::function) at .pio\libdeps\debug_version\ESP8266-ping\src/Pinger.cpp:71
0x402212d7 in setup at src/main.cpp:4982
0x40250524 in std::_Function_handler::_M_manager(std::_Any_data&, std::_Function_handler const&, std::_Manager_operation)
at c:\users\progman\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\10.3.0\bits/std_function.h:271
0x402080e0 in std::_Function_handler::_M_invoke(std::_Any_data const&, PingerResponse const&) at src/main.cpp:4964
(inlined by) __invoke_impl&, const PingerResponse&> at c:\users\progman\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\10.3.0\bits/invoke.h:60
(inlined by) __invoke_r&, const PingerResponse&> at c:\users\progman\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\10.3.0\bits/invoke.h:113
(inlined by) _M_invoke at c:\users\progman\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include\c++\10.3.0\bits/std_function.h:291
0x4023c61b in loop_wrapper() at C:\Users\progman\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/core_esp8266_main.cpp:198
0x4010059d in cont_wrapper at C:\Users\progman\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/cont.S:81
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.