SPIFFS access fa

r2d2abc
Posts: 6
Joined: Mon Jun 25, 2018 8:01 am

SPIFFS access fa

Postby r2d2abc » Fri Aug 17, 2018 5:01 pm

Hi all I try to save some files for a web site (css, html,...) on SPIFFS but it' s a true fight for this target.
All my files are under '/web' directory (here I try with some examples files)

Context:
Eclipse oxygen / arduino-esp32 / compiler xtensa updated.
xtensa-esp32-elf-win32-1.22.0-80-g6c4433a-5.2.0.zip
ESP32 Arducam

1° step , i do a mkspiffs (version 022 and not 023 dixit forum) (see below 1). An error appears 10025 for 022, but at least the options -l or -i runs fine.

Code: Select all

MINGW32 /r/temp
$ ./mkspiffs022.exe -c ./web/ -b 4096 -p 256 -s 1048576 ./spiffs022.bin
[color=#FF0040]SPIFFS mount failed with error: -10025[/color]
/spiffs.info
/test1.jpg
/test2.jpg
/test4.jpg

MINGW32 /r/temp
$ ./mkspiffs023.exe -c ./web/ -b 4096 -p 256 -s 1048576 ./spiffs023.bin
/spiffs.info
/test1.jpg
/test2.jpg
/test4.jpg

MINGW32 /r/temp
$ ./mkspiffs022.exe -l ./spiffs022.bin
405     /spiffs.info
39310   /test1.jpg
50538   /test2.jpg
47438   /test4.jpg

MINGW32 /r/temp
$ ./mkspiffs023.exe -l ./spiffs023.bin
405     /spiffs.info
39310   /test1.jpg
50538   /test2.jpg
47438   /test4.jpg

2° stage, file ares strictly the same (a FC confirm this) .... despite error above.

Code: Select all

MINGW32 /r/temp
$ ./mkspiffs022.exe -i ./spiffs022.bin
0000 /ddi/ddd/d/d/d/    era_cnt: 0
0001 d/d/d/d/d/d/d/d    era_cnt: 0
0002 /d/d/d/d/d/d/d/    era_cnt: 0
...
0047 d/d/d/d/d/d/d/d    era_cnt: 0
0048 /d/d/d/d/d/d/d/    era_cnt: 0
0049 i______________    era_cnt: 0
004a _______________    era_cnt: 0
004b _______________    era_cnt: 0
...
00fd _______________    era_cnt: 0
00fe _______________    era_cnt: 0
00ff _______________    era_cnt: 0
era_cnt_max: 1
last_errno:  0
blocks:      256
free_blocks: 182
page_alloc:  557
page_delet:  539
used:        139807 of 956561
total: 956561
used: 139807


MINGW32 /r/temp
$ ./mkspiffs023.exe -i ./spiffs023.bin
0000 /ddi/ddd/d/d/d/    era_cnt: 0
0001 d/d/d/d/d/d/d/d    era_cnt: 0
....
0047 d/d/d/d/d/d/d/d    era_cnt: 0
0048 /d/d/d/d/d/d/d/    era_cnt: 0
0049 i______________    era_cnt: 0
004a _______________    era_cnt: 0
004b _______________    era_cnt: 0
....
00fc _______________    era_cnt: 0
00fe _______________    era_cnt: 0
00ff _______________    era_cnt: 0
era_cnt_max: 1
last_errno:  0
blocks:      256
free_blocks: 182
page_alloc:  557
page_delet:  539
used:        139807 of 956561
total: 956561
used: 139807
Flash stage :
---------------

Code: Select all

MINGW32 /r/temp
$ python $IDF_PATH/components/esptool_py/esptool/esptool.py --chip esp32 --port COM6 --baud 921600 write_flash -z 0x291000 ./spiffs022.bin
esptool.py v2.3.1
Connecting......
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 1048576 bytes to 147831...
Wrote 1048576 bytes (147831 compressed) at 0x00291000 in 7.0 seconds (effective 1206.2 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...

Make menuconfig :
----------------------

Code: Select all

  (3) Maximum Number of Partitions
  SPIFFS Cache Configuration  --->
  [*] Enable SPIFFS Page Check
  (10) Set Maximum GC Runs
  [ ] Enable SPIFFS GC Statistics
  (256) SPIFFS logical page size
  (32) Set SPIFFS Maximum Name Length
  [*] Enable SPIFFS Filesystem Magic
  [*]   Enable SPIFFS Filesystem Length Magic
  (0) Size of per-file metadata field
  Debug Configuration  --->
Flash_id:
-----------

Code: Select all

MINGW32 /r/ESP32Projects/workspace/03-EspIdfTemplate
esptool.py v2.3.1H/components/esptool_py/esptool/esptool.py --port COM6 flash_id
Connecting.....
Detecting chip type... ESP32
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core
Uploading stub...
Running stub...
Stub running...
Manufacturer: c8
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...
Partition_tables:
--------------------

Code: Select all

MINGW32 /r/ESP32Projects/workspace/04-Sensor-A1
$ make partition_table
Partition table binary generated. Contents:
*******************************************************************************
# Espressif ESP32 Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,		data,		nvs,		0x9000,20K,
otadata,	data,		ota,		0xe000,8K,
app0,	app,		ota_0,	0x10000,1280K,
app1,	app,		ota_1,	0x150000,1280K,
eeprom,	data,		153,		0x290000,4K,
spiffs,	data,		spiffs,	0x291000,1468K,
*******************************************************************************

Code tried:
--------------
[code]
void listDir2(fs::FS &fs, const char * dirname, uint8_t levels)
{
  printf("\nListing directory: %s\n", dirname);

  File root = fs.open(dirname);
  if (!root)
  {
    printf("\n\tFailed to open directory");
    return;
  }
  if (!root.isDirectory())
  {
    printf("\n\tNot a directory");
    return;
  }

  File file = root.openNextFile();
  while (file)
  {
    if (file.isDirectory())
    {
      printf("\n\t  DIR : ");
      printf(file.name());
      if (levels)
      {
        listDir(fs, file.name(), levels - 1);
      }
    } else
    {
      printf("\n\t  FILE: ");
      printf(file.name());
      printf("  SIZE: ");
      printf("%u",file.size());
    }
    file = root.openNextFile();
  }
}

void handleFileList2 (char *spath)
{
	printf ("\nSPIFFS/Listing [%s] :", spath);
	String path=spath;

	if(!SPIFFS.exists((char *)path.c_str()))
	 {
	    printf ("\n\tError: bad path [%s]", spath);
	    return;
	  }

	File dir = SPIFFS.open((char *)path.c_str());

	printf ("\n\tDir=%s]",dir.name());
	dir.rewindDirectory();
	String output = "[";

	for (int cnt = 0; true; ++cnt)
	  {
	    File entry = dir.openNextFile();
	    if (!entry)
	    {
	    	printf ("\n\tNo Entry");
	    	break;
	    }

	    if (cnt > 0)
	      output += ',';

	    output += (entry.isDirectory()) ? "dir" : "file";
	    output += "\tname :";
	    output += entry.name()+1;
	    output += "\tsize "+entry.size();
	    entry.close();
	    printf ("\n\t%s",output.c_str());
	  }

	  dir.close();
}

void TestSpiffs()
{
	printf("\n3.1: Init SPIFFS");

	//if(!SPIFFS.begin(true))
	if(!SPIFFS.begin()) //true))
	{
		printf ("\n\tSPIFFS: Mounted FAIL");
	    return;
	}
	printf ("\n\tSPIFFS: Mounted OK");

	int res=mkdir ("/A",ACCESSPERMS);
	printf("\n\tcreation dir [A] =%i ",res);

	printf ("\n\tSPIFFS: Test write file /A/testA.txt");
	File file= SPIFFS.open("/A/testA.txt", FILE_WRITE);
	if (!file)
	  {
		printf("\n\tThere was an error opening the file for writing");
		return;
	  }

	if (file.print("TEST-A"))
			printf("\n\tFile was written");
	 else	printf("\n\tFile write failed");

	file.close();

	// File creation
	printf ("\n\tSPIFFS: Test write file  /test.txt");
	file= SPIFFS.open("/test.txt", FILE_WRITE);
	if (!file)
	  {
		printf("\n\tThere was an error opening the file for writing");
		return;
	  }
	if (file.print("TEST"))
				printf("\n\tFile was written");
	   else	    printf("\n\tFile write failed");

	file.close();
	

	printf ("\n\tSPIFFS: Test read file");
	File  file2 = SPIFFS.open("/test.txt");
	if(!file2)
	  {
		printf("\n\tFailed to open file for reading");
	  }
	else
	  {
		printf ("\n\tFile Size   : [%u] bytes",file2.size());
		printf ("\n\tFile Dir    : [%s] ",(file2.isDirectory()?"Y":"N"));
		printf ("\n\tFile Content:");

		while(file2.available()) printf (" [%c]",file2.read());

		file2.close();
	  }

	printf ("\n\tSPIFFS: Test dir check");
	handleFileList2("/");
	handleFileList2("/spiffs");
	listDir2(SPIFFS,"/",3);
	listDir2(SPIFFS,"/spiffs",3);
}

Any help would be very appreciated.
Thank's
Frederic

r2d2abc
Posts: 6
Joined: Mon Jun 25, 2018 8:01 am

Re: SPIFFS access fails

Postby r2d2abc » Mon Aug 20, 2018 3:04 pm

Hi , up for this request ;)
F.

Who is online

Users browsing this forum: No registered users and 74 guests