-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
SPIFFS println weird behavior with long strings #8372
Comments
also see #8070 with the examples above... for failing cases, 0xff is actually 0xff and can be seen on the flash, so I'd guess this is something broken on writes and not something wrong with the reading
(looking at binary dump via esptool read_flash 0x300000 0x100000 for something resembling file chunks) There were no changes to spiffs source itself 2.7.4 and 3.0.0 though, and it is deprecated for a variety of reasons (#7095 plus #7263), so it is a pretty low chance this is going to get fixed. There are some avenues to explore
|
I missed your issue, thanks for linking! I will look at #79ea883 for further insights. |
I seem to be having the same problem. I have saved data into a SPIFFS file, but after reading ~1kbyte back there are spurious FF's in the data read. Read back:
Correct data:
|
Rolling back from 3.0.x to 2.7.4 fixes the problem so it does appear to be a bug in the latest versions. |
I can confirm that the issue is on "write" and not in "read" process. In particular, it seems that the bug is in Line 883 in b080c50
If I understood the idea of the algorithm, to write in flash the proper 4-bytes alignment must be guaranteed for both RAM and flash addresses. The issue is that if you try to align one, you will break the other alignment. In that branch you may have a wrong RAM alignment (there is no check about it), so in this case it may fail the writing. In other words, when you enter that branch, if the flash address is not aligned, you should write a partial 4-bytes block and then re-check the alignment of the start address of remaining data. This may lead to a reallocation of the data on the stack, (it already occurs in flashWriteUnalignedMemory function). If the maintainer would consider the idea, I can create a pull request. |
Can you provide an example with specific numbers and the call chain that breaks? |
The minimal sketch to reproduce is the following one with core v3.0.2.
When you print the file content on serial port, you will see some prints showing "??" instead of "\r\n".
Is this core based on RTOS SDK? I remember, arduino core is based on NONOS SDK... However I have read that implementation, basically the solution is the reallocation of the memory on the stack. EDIT: I had fixed the previous post by adding the line number, sorry |
I have pushed a temptative fix that fix the current issue, but it may break other behaviors which I'm not aware of... |
Basic Infos
Platform
Settings in IDE
Problem Description
Sporadically, File::println("message") fails, and instead of recording "\r\n" it prints 0xFFFF. In this sketch, this happens only with long messages (i.e. >350 chars). However, in more complicated sketches (where multiple write per lines occurs), it happens even with short strings. It happens with Arduino Core 3.x.x, as well as the latest commit, but it works fine in previous releases (2.7.4 and lower).
I know that SPIFFS is deprecated, but this seems a regression and it should be mentioned.
Sketch
Debug Messages
Sometimes 2 messages are printed on the same line. It seems that println prints 0xFFFF instead of "\r\n". An example (there are 2 '⸮' in the middle of the string):
If I use
f.print("mymessage\r\n")
the sketch works as expectedThe text was updated successfully, but these errors were encountered: