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
spiffsgen.py under windows does not generate valid binary images (IDFGH-4615) #6429
Comments
Thanks for the very detailed report and sorry for the inconvenience, we will look into. |
@ctag-fh-kiel Thank you for reporting the issue. Does your application depend on order of files in spiffs? Please, could you provide us with version of Python that you're using:
|
@ctag-fh-kiel Meanwhile I was able to reproduce the behavior. Please, check whether this different order is not causing the problem to your application. It's also important to note that SPIFFS has flat structure and nested structure from filesystem is just mapped to file names. |
If this is the only difference in the file then that is probably what is causing my issues. Is it possible to create the spiffs image consistently on mac, linux and windows? Thanks for looking into the issue! |
@ctag-fh-kiel I made a further investigation of the content of filesystem.
Then I used KDiff3 to compare the content of both directories: http://kdiff3.sourceforge.net/ The only thing that differs is the output from both commands which contains a list of files. After sorting of lines both outputs the results are identical. It seems that the only difference between images is the file order in the image. |
Hi Juraj Michálek, The problems with the bins occur using ESP IDF 4.1 with the following setups:
I also tried the most recent version for ESP IDF (4.2) on Windows with idf.py and mkspiffs. Untested so far:
Working solutions for me with ESP IDF 4.1:
So to sum things up, it seems like for the file-content we are using with ESP IDF 4.1 only on MacOS and with the Docker Image of ESP IDF on Ubuntu there are no errors running the SPIFFS on the ESP32, which seems to be kind of very strange for such a wide-spread architecture? The application itself is not dependant on the ordering of the files in the bins, it simply reads (and afterwards writes) the content of the files. The error occurs upon startup of the application, when it reads JSN-files needed for a webserver. BTW: I also looked for weird (non-ASCII / non UTF 8) characters in our files but did not find anything interesting so far, also as you also as you found out there is not major difference between the working and non-working bins? What you discovered concerning the different sort-order in the bins I find really interesting. All the best, Mathias (Brüssel) |
@Visuelle-Musik Thank you very much for providing these details. The idea was to write small app which reads all files, just to make sure that read operation perform well even on bigger files from the image. |
@georgik Thanks again for looking into this! |
@ctag-fh-kiel @Visuelle-Musik I've noticed that the partition table requires a chip with 16 MB flash. Right now I have only chips with 4 MB of flash. I've tried to build the project on Windows from ESP-IDF examples/storage/spiffsgen with data from reported spiffs_image. The example app booted without a problem and it was possible to read original /spiffs/data/spm-config.jsn. It was just necessary to bump up the size of the read buffer. Here are two ideas to investigate the problem: Please, check whether the read buffer is sufficient when working with .jsn file. Please, try to flash the device and retrieve the data by esptool and compare it:
This test can give a hint whether the bug is caused by the integrity of flash or a problem in esptool when flashing data. |
@ctag-fh-kiel @Visuelle-Musik I made further investigation of the problem.
BTW: I've noticed that
This code will cause failure in case of build on Windows. The part with ENV is redundant and could be removed:
|
Hi georgik, |
@ctag-fh-kiel I'm glad that the image is working for you.
The next build is ok. It might not be related, but it's very strange issue with parallel execution of build steps. How many cores do have your Ubuntu and Windows machines? macOS on common Apple HW has always more than one CPU core. |
@georgik @ctag-fh-kiel Hi Juraj, that's an interesting observation, but like you I don't think it's related with our problem. |
@ctag-fh-kiel @Visuelle-Musik I identified potential source of the problem. spiffs_create_partition_image does not contain declaration of dependency on targets which performs file copy. This can lead to fail of spiffs_create_partition_image or building the spiffs image during copying files to build directory. The pull request is here: ctag-fh-kiel/ctag-tbd#11 You can find description of DEPENDS here: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/storage/spiffs.html Please review and test suggested change |
@georgik @ctag-fh-kiel Hi Juraj, I just tested your fix and can confirm that it works for me (Windows 8.1, idf.py) :-) |
@Visuelle-Musik Thanks for reporting and testing the fix, and glad it works. Will close now, feel free to reopen. |
Environment
git describe --tags
to find it):release/v4.1
Problem Description
spiffsgen.py on windows builds corrupt image from directory, when this is flashed firmware doesn't run as some files in spiffs partition are missing or corrupt
diff storage_ok.bin storage_bad.bin (attached good (Linux + MacOS) and bad images (Windows)) indicates erroneous image as files differ, storage_ok.bin was correctly built on Mac / Linux
Expected Behavior
see attached storage_ok.bin in storage.zip
see attached spiffs_image.zip
file which contains desired file structure (compressed for this issue request)
Actual Behavior
see attached storage_bad.bin in storage.zip
bad image
Steps to reproduce
Image is built through CMake lines 20-38 of the following file
https://github.com/ctag-fh-kiel/ctag-tbd/blob/master/CMakeLists.txt
"idf.py build" executes this command (which seems to be correct):
C:\msys64\home\rma\ctag-tbd\build && C:\msys64\mingw64\bin\python.exe C:/msys64/home/rma/esp-idf/comp
onents/spiffs/spiffsgen.py 0x300000 C:/msys64/home/rma/ctag-tbd/build/spiffs_image C:/msys64/home/rma/ctag-tbd/build/storage.bin --page-size=256 --obj-name-len=32 --meta-len=4 --use-magic --use-magic-len"
which generates a bad spiffs image (storage_bad.bin attached)
Manual execution of $IDF_PATH/components/spiffs/spiffsgen.py 0x300000 build/spiffs_image build/storage.bin
sometimes lead to a good image, and sometimes didn't. It was somehow not reproducible, very strange.
Further information
Original file structure to be put in spiffs image can be found here
https://github.com/ctag-fh-kiel/ctag-tbd/tree/master/spiffs_image
I have tried to set up a working esp idf windows environment, as the esp idf installer was not able to successfully create one for me on windows (CMake Version too old in release/v4.1), I have written down my steps here, but ran into above issue (which persists also with a colleague of mine, who uses standard esp idf windows installer):
https://github.com/ctag-fh-kiel/ctag-tbd/blob/dev/doc/how-to-dev-windows.md
The text was updated successfully, but these errors were encountered: