Coder Social home page Coder Social logo

Comments (2)

weswitt avatar weswitt commented on July 26, 2024

I did a test that demonstrates the problem and attached some files to show the issue. The zip file has 2 files: fs-bad.bin and fs-good.bin. fs-bad.bin was created by mkspiffs. fs-good.bin was created by the spiffs code in the sketch below.

#include "FS.h"

void read_file()
{
File configFile = SPIFFS.open("/test.txt", "r");
if (!configFile)
{
Serial.println("cannot open file");
}
else
{
size_t configSize = configFile.size();
char buf[512];
memset(buf, 0, 512);
size_t bytes_read = configFile.readBytes(buf, configSize);
configFile.close();
Serial.print("BYTES_READ: ["); Serial.print(bytes_read); Serial.println("]");
Serial.print("DATA: ["); Serial.print(buf); Serial.println("]");
}
}

void write_file()
{
char buf[512];
SPIFFS.format();
strcpy(buf, "*** ==> test data <== ****");
File f = SPIFFS.open("/test.txt", "w");
f.write((const uint8_t
)buf, strlen(buf));
f.close();
Serial.println("filesystem created");
}

void setup()
{
Serial.begin(115200);
//Serial.setDebugOutput(true);
delay(5000);
SPIFFS.begin();
String str = "";
Serial.println("FILES:");
Dir dir = SPIFFS.openDir("/");
while (dir.next())
{
str += dir.fileName();
str += " : ";
str += dir.fileSize();
str += "\r\n";
}
Serial.print(str);
write_file();
read_file();
}

void loop()
{
}

fs.zip

from mkspiffs.

weswitt avatar weswitt commented on July 26, 2024

I resolved this. I built with SPIFFS_USE_MAGIC_LENGTH=0 and SPIFFS_ALIGNED_OBJECT_INDEX_TABLES=1 and it now works.

from mkspiffs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.