Flash fail after long-usage of the development board

Hi,

I want to share some insights with you regarding my experience with an ESP8266-based board, Wemos D1 R1. Bought one few months ago, and used it for a heating-station relay with a temperature sensor, kind'a like a thermostat but with WiFi info across the web.

The only things I had in the loop() were Wifi.status() to retreive the connection status and reconnect if WiFi connections fails and WebServer.handleClient() to handle the HTTP requests.

Worked like a charm for about 4-5 months, 'til the point when the Web requests started to be very laggy or unresponsive at all.
No restart or reflash worked, so I started to debug it. The WiFi connection was unstable and dropping all the time.

I enabled Debugging Options over Serial in the Arduino IDE, and amazingly - it was working normally again, no connection drops.

Disabled the debugging again, connection dropping.

I played a bit with the code and found out that if I add a very small delay (even 5 milisecs | delay(5) ), the board is working normally.

Started to think what could be the reason for a sudden loss of stability which is fixed by a delay... (I guess that's the reason it worked with debugging as well, 'cause it added delay to the loop).

I knew that solid state memories usually have a limited lifetime, so I thought the flash must be worn-up.

Went to Arduino IDE and selected "VTables" to "IRAM" instead of "Flash" and guess what: Board works again like a charm. Storing it to "HEAP" also worked. But flash... doesn't.

Surprisingly, I uploaded the same Sketch to two (apparently) new boards "Wemos Micro" and had the same problem, even though these boards were never used; delay(5) or storing vTables to IRAM solved the problem for these boards too.

I suspect there's an issue with the flash chip (which is Winbond W25Q32JV) and these China-made products don't have any kind of QA... so they come with such issues.

Hope my experience helps anyone in similar future situations.
And if someone has experienced something similar, please share your thoughts.

Regards,
A.

I remember seeing some reports of ESP8266 modules that used flash chips which would only survive a few write cycles. An unfortunate aspect of the use of an external flash chip is that it introduces an extra variable into the equation: two modules with the same model number and same microcontroller might use completely different flash chips. At the time I was working with the ESP8266 more, they were usually hidden under cans, so you couldn't easily get a visual of what chip was on there. When I could get a model number of the flash chip, I often found that they were some undocumented Chinese chips.