-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Separate flash write API into raw and quirk-handling versions #7644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Isn't it simply a matter of reserving 1 byte, initialize it with "0x55" (or some other pattern) and try to set one of the 0's to 1. This way you know what type of flash it is every time at boot without the need to check it using a write. |
That's an auto detection approach, which I believe has been discussed elsewhere. It may or may not be viable, similar to the flash size detection approach mentioned somewhere, but the goal here is a different one. Let's not hijack the thread. |
@devyte I don't think that SPIFFS has a workaround for PUYA, according to pellepl/spiffs#172 it only fixed relying on 0->1 changes to be ignored by flash, but it still does 1->0 changes on the same offset. |
As for the change in API, I don't think we need "no-quirk" API. It would mean that everyone who wants to use it would need to copy-paste the code of "with-quirks" API to his own code. My proposal with regards to PUYA/non-PUYA mess is to create |
@TD-er I think that the first line of your comment is incorrect
@devyte Currently there is no workaround for 2 in any of ESP core code, since nobody encountered such a flash on ESP |
@drzony Your second point about checking a special register sounds interesting. @devyte How do you imagine to switch between flash write behavior per library? |
@TD-er It cannot be used that way, since it only prevents 0->1 changes, which is ignored on other flashes (0 stays 0, but write succeeds) |
I meant if it marks such an operation as error in a special register, then such a chip could be used to help testing existing libraries without the penalty of needing extra reads. |
Not really, you need to know beforehand that such chip has this register, otherwise you can't tell whether this is exactly this error (and if you know the chip, then you're done with detection). Anyway, let's not hijack API change thread with autodetection which is a whole large topic on it's own. |
It was by no means intended to switch back to "autodetect" but more to address my worries on decisions to make what a "default" flash write strategy should be. Or am I missing the point here? |
Since we are allowing API breaking changes in v3.0 we can rename |
My $0.02, for what it's worth: Flash != EEPROM, and I'm not really sure it's worth the effort in the end. For EEPROMs there is expectation of byte-level (and even bit-level) update and everything should "just work." The current NAND Flash, however, has significant limitations in all incarnations I've run into. You have things like erase blocks, partial page programming, and a host of other ugliness. So, apps writing to flash need to take heed of these. Most basic would be flash word alignment and sizing. Current code requires 32b aligned, 32b sizes writes (due to a combination of the HW engine that does the writes and the blob/ROM which have minimal protections). That seems like a fine requirement because the core itself only writes using the blob (already 4K aligned, 4K sized AFAIK), the EEPROM (aligned properly AFAIK), LittleFS (aligned properly AFAIK), and SPIFFS (AFAIK may be aligned properly but (ab)uses some mode which is fine for NOR flash but isn't a property of the NAND flash people are shipping on the 8266 boards today). SPIFFS is deprecated and not supported upstream, so I really would not sweat that too much. If a user decides to use the raw flash outside of the API the Arduino core provides, they're welcome to but need to follow the restrictions. It might be worthwhile to throw in some |
Basic Infos
Platform
Settings in IDE
Problem Description
CC @drzony @earlephilhower @TD-er
To better understand #7514, I had some (lengthy) discussions with @drzony. Per his explanation (please bear with me here, I'm not an expert here and my understanding may be flawed):
It seems that SPIFFS assumes NOR type flash, while other code like LittleFS assumes NAND type (@earlephilhower), and the PUYA chips don't like the SPIFFS assumption.
The proposal here is:
The above would mean that the current performance penalty for the PUYA case could be reduced or even eliminated for the non-SPIFFS operations.
The text was updated successfully, but these errors were encountered: