Skip to content

mkspiffs partition seems to be ReadOnly when mounted into an ESP #733

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

Closed
martinayotte opened this issue Aug 30, 2015 · 6 comments
Closed

Comments

@martinayotte
Copy link
Contributor

After mounting a partition made with mkspiffs, all files are readable, but opening a new file, either in "a" or "w" mode is failing.
Also, trying to open existing one in "a" mode will not fail but the content is never written.

@igrr
Copy link
Member

igrr commented Sep 8, 2015

I tried a few ways, but it seems I can't reproduce this issue. Here's what I do:

  • Prepare FS image:
mkdir -p data
echo "hello" > data/data.txt
./mkspiffs -b 0x1000 -p 0x100 -s 0x10000 -c data fs.bin
  • Create and upload the sketch:
#include "FS.h"

void setup() {
  Serial.begin(115200);
  Serial.setDebugOutput(true);
  for (int i = 0; i < 5; ++i) {delay(1000); Serial.print(".");} // give me some time to open terminal window
  Serial.println("");
  SPIFFS.begin();
  const char* fname = "/data.txt";
  {
    File f = SPIFFS.open(fname, "a");
    if (!f) {
      Serial.printf("%s doesn't exist\r\n", fname);
      return;
    }
    Serial.printf("Opened %s\r\n", fname);
    Serial.printf("Size: %d\r\n", f.size());
    Serial.println("adding more data");
    f.println("more data");
  }
  {
    File f = SPIFFS.open(fname, "r");
    Serial.printf("Size: %d\r\n", f.size());
  }
}

void loop() { }
  • Upload FS image:
esptool-ck -cp /dev/tty.usbserial -cb 921600 -ca 0x6b000 -cf fs.bin

Here is what i get (with debug output enabled just in case):

.........
SPIFFSImpl: allocating 512+180+1400=2092 bytes
SPIFFSImpl: mounting fs @6b000, size=10000, block=1000, page=100
SPIFFSImpl: mount rc=0
Opened /data.txt
Size: 6
adding more data
SPIFFS_close: fd=1
Size: 17
SPIFFS_close: fd=1

So the initial file size was correct and we have added some more data there successfully.

Edit: mkspiffs arguments listed above correspond to "Generic ESP8266 512k/64k" option in the IDE.

@martinayotte
Copy link
Contributor Author

Hi IGRR,

Ok, thanks !
I will try your scenario tomorrow, if I'm able to get success like you did, maybe it is a mkspiffs issue.
Maybe this is depends of the context/content, since we don't even know yet if it is on ArduinoESP side or mkspiffs side. That's why I've also opened the issue igrr/mkspiffs#5 in mkspiffs repo.

So, maybe I should provide here my spiff image which contain more files and bigger ones, which can lead to some confusion. So, in cas it can help to narrow the issue, I'm providing here myspiff.bin image.
"mkspiffs -i myspiffs.bin" for that image showing the following :

0 /ddd/d/d/d/i/dd era_cnt: 0
1 d/d/d/d/d/d/d/d era_cnt: 0
2 /d/d/d/d/d/d/di era_cnt: 0
3 /ddd/d/d/d/i___ era_cnt: 0
4 _______________ era_cnt: 0
5 _______________ era_cnt: 0
6 _______________ era_cnt: 0
7 _______________ era_cnt: 0
8 _______________ era_cnt: 0
9 _______________ era_cnt: 0
10 _______________ era_cnt: 0
11 _______________ era_cnt: 0
12 _______________ era_cnt: 0
13 _______________ era_cnt: 0
14 _______________ era_cnt: 0
15 _______________ era_cnt: 0
era_cnt_max: 1
last_errno: 0
blocks: 16
free_blocks: 12
page_alloc: 32
page_delet: 25
used: 8032 of 52961
total: 52961
used: 8032

Here is the image in attachment, it is a ZIP file, although GIF extension is added simply to bypass attachment github limitation :

myspiffs zip

@igrr
Copy link
Member

igrr commented Sep 9, 2015

Which options did you use to build this image (i.e. something like -b 0x1000 -p 0x100 -s 0x10000)?

@martinayotte
Copy link
Contributor Author

I didn't provide any, so it was using the defaults, so according to main.cpp, it was using -s 0x10000 -p 256 -b 4096.
And if I remember on the first try with debug output, it iwas reportnig Ok.
Also, the files can be access properly, but in ReadOnly.

@igrr
Copy link
Member

igrr commented Sep 9, 2015

Oh, but do these defaults match SPIFFS settings on the ESP side? Which board/flash size setting did you use in the IDE?

@martinayotte
Copy link
Contributor Author

Hi again Ivan,
I'm using 512K(64K).
I've just re-merged all latest changes for GitHub, it seems the problem is gone ... :-)
So, if it is not reproducible any, I'm closing the issue for now !
(I will re-open it if it comes back)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants