Hi, Im using ESP8266, then executing flash.begin() and without spi flash connected ... >> getting WDT reset. I cant add delay(0) ... is in your library ...
... with spi flash inserted (connected) - all ok.
ESP.wdtDisable();
ESP.wdtFeed();
if (!flash.begin()) {
Serial.println(flash.error(VERBOSE));
}
ESP.wdtEnable(1000);
same with wdtDisable() after ~10 seconds WDT reset .... your library stack in infinite loop on flash.begin() .... any help ?
OK ... find the bug, in defines.h change ... for esp8266 BUSY_TIMEOUT set ~2 seconds (was 1000 seconds)
// #define BUSY_TIMEOUT 1000000000L
#if defined (ARDUINO_ARCH_ESP8266)
#define BUSY_TIMEOUT 2000000L
#else
#define BUSY_TIMEOUT 1000000000L
#endif
... now work ok
and may be in this code must be done some fixes:
// Polls the status register 1 until busy flag is cleared or timeout
bool SPIFlash::_notBusy(uint32_t timeout) {
_delay_us(WINBOND_WRITE_DELAY);
uint32_t _time = micros();
do {
#if defined (ARDUINO_ARCH_ESP8266)
delay(0);
#endif
_readStat1();
if (!(stat1 & BUSY))
{
return true;
}
} while ((micros() - _time) < timeout);
if (timeout <= (micros() - _time)) {
_troubleshoot(CHIPBUSY);
return false;
}
return true;
}
change code >
do {
** #if defined (ARDUINO_ARCH_ESP8266)**
** delay(0);**
** #endif**
** _readStat1();**
same with cheapErase() fix
//Erases whole chip. Think twice before using.
bool SPIFlash::eraseChip(void) {
#ifdef RUNDIAGNOSTIC
_spifuncruntime = micros();
#endif
if(_isChipPoweredDown() || !_notBusy() || !_writeEnable()) {
return false;
}
_beginSPI(chipErase.opcode);
_endSPI();
while(_readStat1() & BUSY) {
#if defined (ARDUINO_ARCH_ESP8266)
delay(0);
#endif
//_delay_us(30000L);
}
_endSPI();
#ifdef RUNDIAGNOSTIC
_spifuncruntime = micros() - _spifuncruntime;
#endif
return true;
}