What happens when embed flash's write limit is reached?

qheinal
Posts: 24
Joined: Tue Feb 20, 2024 4:38 pm

What happens when embed flash's write limit is reached?

Postby qheinal » Tue Feb 20, 2024 4:48 pm

I have esp32 s2 mini dev board with embed psram and flash. I was wondering if the microcontroller would still be usable in that edge case because i constantly update code with those microcontrollers. On my Esp32 s3 and esp32 the flash memory is external so its easy to just replace the flash chip but on the s2 its all internal. Like for example can it still boot from external flash connected to vspi or hspi even though its internal flash is "Write only dead" since flash has no read limit.

ESP_Sprite
Posts: 9052
Joined: Thu Nov 26, 2015 4:08 am

Re: What happens when embed flash's write limit is reached?

Postby ESP_Sprite » Wed Feb 21, 2024 12:59 am

It would likely not. Worn-out flash, to my knowledge, results in bits not being properly erased anymore, that is, they will always stay 0 even if you need them to be 1. This would result in a corrupted flash image, and the ESP32 will refuse to boot that.

Good thing is that the flash internal to ESP32 chips is generally rated for 100000 writes (actually: erase cycles) or more, so you generally don't reach that limit by simply doing a lot of development work.

qheinal
Posts: 24
Joined: Tue Feb 20, 2024 4:38 pm

Re: What happens when embed flash's write limit is reached?

Postby qheinal » Sun Feb 25, 2024 1:29 am

Yeh but i was writing to the normal Esp32 and it started to give checksum errors after maybe hundreds of writes. Had to erase entire flash to fix it. But then the normal esp32s flash is external so it would be easy to replace. However if the s2 mini will be a brick after embed flash dies then it isn't really worth buying. Might be better to get them with only embed psram but with External flash.

ESP_Sprite
Posts: 9052
Joined: Thu Nov 26, 2015 4:08 am

Re: What happens when embed flash's write limit is reached?

Postby ESP_Sprite » Sun Feb 25, 2024 9:44 am

If a full erase 'fixes' the write errors, it's not a wear issue. I think you may have been doing something wrong. Were you using some API in your program to write to flash? If so, were you aware that a write can only flip bits from 1 to 0 and not the other way around? (You need an erase for that.)

MicroController
Posts: 1219
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: What happens when embed flash's write limit is reached?

Postby MicroController » Mon Feb 26, 2024 10:15 am

Digging a bit into NOR flash failure modes, I found this interesting document.
Apparently, the 'stuck at 0 after erase' failure mode can be somewhat 'self-healing' if cells are allowed a 'rest period' of a few seconds between erase and write. And: Repeated writes to the same 'row' of flash can disturb (i.e. inadvertently program) adjacent cells, to which the fix is to erase and re-program those cells.

That said, before assuming a flash failure you may want to first check if there's an issue in your code which either a) writes to an incorrect location, b) writes to a location which was not previously erased, or c) writes the 'wrong' data.

qheinal
Posts: 24
Joined: Tue Feb 20, 2024 4:38 pm

Re: What happens when embed flash's write limit is reached?

Postby qheinal » Wed Feb 28, 2024 4:26 pm

No i wasn't modifying flash. This only occurred from flashing esp32 a ton of times. I had disabled the option to erase ENTIRE flash every time it uploads. BUT only when i enabled it did the checksum error go away.

ESP_Sprite
Posts: 9052
Joined: Thu Nov 26, 2015 4:08 am

Re: What happens when embed flash's write limit is reached?

Postby ESP_Sprite » Fri Mar 01, 2024 3:42 am

How specifically do you flash your ESP?

qheinal
Posts: 24
Joined: Tue Feb 20, 2024 4:38 pm

Re: What happens when embed flash's write limit is reached?

Postby qheinal » Sun Mar 03, 2024 2:09 am

With arduino ide default settings. Except changed partition style to huge app.

ESP_Sprite
Posts: 9052
Joined: Thu Nov 26, 2015 4:08 am

Re: What happens when embed flash's write limit is reached?

Postby ESP_Sprite » Sun Mar 03, 2024 3:58 am

Do you have anything connected to GPIO45?

qheinal
Posts: 24
Joined: Tue Feb 20, 2024 4:38 pm

Re: What happens when embed flash's write limit is reached?

Postby qheinal » Thu Mar 07, 2024 2:13 am

gpio45 is not broken out on esp32 dev kit

Who is online

Users browsing this forum: No registered users and 170 guests