-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Different behaviour on ESP32 vs ESP8266 #144
Comments
Looking at the underlying glue code, the arduino 8266 implementation and my implementation are quite similar when it comes to flush: See: 8266:
This has also been discussed a bit here: #48. Some of the comments have actually been cross-posted to the other issues you linked. In summary, it seems like there's a workaround, but it also seems like it's an upstream issue. From a quick skim, I'm not seeing a functional difference when it comes to the writing and flushing code between the arduino-8266 and this esp32 implementation. I agree that the current behavior is unintuitive and less than ideal. A possible cause is that the configured 8266 cache sizes are smaller, so a flush/sync might be more likely to always flush to disk. I haven't had a chance to mess around with this. |
Yeah, I've been chasing this issue across the internet for a while without coming to a full understanding or solution (yet), as is evident from the array of open issues here and there... How do i call Here's the ESP32 code you can use to repro/test
Thanks |
So I can't say I've used arduino-esp32, but it doesn't look like the sync functionality is exposed. As an alternative, if you set the configuration parameter |
Doesn't Arduino just sit on top of esp-idf and the associated components, which means all this library's/component's functions are available? Can I call I'm happy to switch to just calling the littlefs lib directly, I'm only using the Arduino entry point from a convenience perspective from previous familiarity. I will try the config option but it means I need to rebuild the project I'm using to be in esp-idf which is slightly more involved, ill try that in the next few days |
Up to my experience, even ESP8266 loses file content when a power failure happens while writing. |
@HamzaHajeir thanks I've seen that thread. Not only can I not reproduce that 8266 behaviour (all bytes are always written) but on the 32 no bytes are written/synced, even when exceeding the ram buffer size |
Haven't tested for ESP32, but I can confirm the issue, the provided log was
the interesting part, as it's a very short window and it can be missed
easily by the reset button push.
Might it be a multi threading related issue for ESP32 or not?
…On Fri, Sep 22, 2023, 13:35 Andrew Bullock ***@***.***> wrote:
@HamzaHajeir <https://github.com/HamzaHajeir> thanks I've seen that
thread. Not only can I not reproduce that 8266 behaviour (all bytes are
always written) but on the 32 no bytes are written/synced, even when
exceeding the ram buffer size
—
Reply to this email directly, view it on GitHub
<#144 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AH3O7J7QJTEN4UUOIG53NXLX3VSYNANCNFSM6AAAAAA47WL6U4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
You seem to write only little amounts of data (smaller than CONFIG_LITTLEFS_WRITE_SIZE). Did you have a look at my workaround here: littlefs-project/littlefs#344 (comment) ? If you can try it out and write it this helps. I am not sure if this is still necessary. Of course it is inefficient to do this all the time - so it works best if you have some kind of brown out detection triggering immediately before power loss. |
Can that workaround be invoked from LittleFS via Arduino ESP? I don't think it can, but I will try later. I know I'm writing small data per loop, but even if you let it run for ages (to have written lots), a reset still leaves a 0B file, surely it should have written some of it... |
@trullock Have you tried @justintconroy #48 (comment) solution? I just ran a test, and for me calling
properly writes the files to disk when reseting prior to closing the file. The |
@BrianPugh how do I invoke these with an Arduino FS::File? Is the File |
It seems that CONFIG_LITTLEFS_WRITE_SIZE is an ESP-IDF configuration. Arduino core doesn't build on the IDF. But anyway, this was just an MCVE. The lost files were actually larger, holding WiFi and MQTT credentials, MQTT server url, and some other global values. |
I'm going to build Arduino from sources so I can play with that config setting when I get a moment. However, no amount of writing gets persisted to "disc". Surely this is a bug. Ram buffers and wear considerations are one thing, but LFS can't be touted as highly resilient when it never writes and bytes for me... I'm going to write some test code that proves the WRITE_SIZE has no effect, although there's threads elsewhere that already identify this |
I understand this may not technically be an "issue" but its a problem I've encountered and would greatly appreciate any help or pointer you can give me.
I'll reproduce my issue I posted here: https://esp32.com/viewtopic.php?f=19&t=35869&sid=86902cd8c4a9aa8cb4547f524096db9b
I'm porting some code from ESP8266 to ESP32 and I've found a behavioural difference between the two which I need to solve.
I'm writing log data to a LittleFS file on the ESP8266, calling flush after each write. On the ESP8266 if there is a power failure before
file.close()
is called, the data is synced to flash and can be read back. On the ESP32 it is not, the file has 0 Bytes.I loosely understand why, its to do with how LFS stages the content and when
sync()
gets called. This thread is relevant littlefs-project/littlefs#344My question is, whats (or rather where) is different between the ESP32 and ESP8266? What code or configuration settings are different between the two?
What is the ESP32 doing, why is the behaviour different and how to I get it to behave like the ESP8266?
Example code for esp8266, esp32 version has some slight syntax differences
Thanks
The text was updated successfully, but these errors were encountered: