LittleFS port to Teensy/SPIFlash

It is ODD though - never noticed before? It should be writing 2048 bytes One Thousand times and yet the file size is not 2048000? Will have to check that???

In bigFile2MB, should the "while" be changed as marked between "==>" & "<==":

Code:
void bigFile2MB( int doThis ) {
  char myFile[] = "/0_2MBfile.txt";
  char fileID = '0' - 1;

  if ( 0 == doThis ) {  // delete File
    Serial.printf( "\nDelete with read verify all #bigfile's\n");
    do {
      fileID++;
      myFile[1] = fileID;
      if ( myfs.exists(myFile) && bigVerify( myFile, fileID) ) {
        //filecount--;
        myfs.remove(myFile);
      }
      else break; // no more of these
    } while ( 1 );
  }
  else {  // FILL DISK
    lfs_ssize_t resW = 1;
    char someData[2048];
    uint32_t xx, toWrite;
    toWrite = 2048 * 1000;
    if ( toWrite > (65535 + (myfs.totalSize() - myfs.usedSize()) ) ) {
      Serial.print( "Disk too full! DO :: q or F");
      return;
    }
    xx = toWrite;
    Serial.printf( "\nStart Big write of %u Bytes", xx);
    uint32_t timeMe = micros();
    file3 = nullptr;
    do {
      if ( file3 ) file3.close();
      fileID++;
      myFile[1] = fileID;
      file3 = myfs.open(myFile, FILE_WRITE);
    } while ( fileID < '9' && file3.size() > 0);
    if ( fileID == '9' ) {
      Serial.print( "Disk has 9 FILES 0-8! DO :: b or q or F");
      return;
    }
    memset( someData, fileID, 2048 );
    int hh = 0;
==> while ( toWrite >= 2048 && resW > 0 ) {  <==
      resW = file3.write( someData , 2048 );
      hh++;
      if ( !(hh % 40) ) Serial.print('.');
      toWrite -= 2048;
    }
    xx -= toWrite;
    file3.close();
    timeMe = micros() - timeMe;
    file3 = myfs.open(myFile, FILE_WRITE);
    if ( file3.size() > 0 ) {
      //filecount++;
      Serial.printf( "\nBig write %s took %5.2f Sec for %lu Bytes : file3.size()=%llu", myFile , timeMe / 1000000.0, xx, file3.size() );
    }
    if ( file3 != 0 ) file3.close();
    Serial.printf( "\n\tBig write KBytes per second %5.2f \n", xx / (timeMe / 1000.0) );
    Serial.printf("\nBytes Used: %llu, Bytes Total:%llu\n", myfs.usedSize(), myfs.totalSize());
    if ( resW < 0 ) {
      Serial.printf( "\nBig write ERR# %i 0x%X \n", resW, resW );
      //errsLFS++;
      myfs.remove(myFile);
    }
  }
}
 
In bigFile2MB, should the "while" be changed as marked between "==>" & "<==":

Thanks - will give it a look bigfile2MB was repurposed from random size (fill the disk some) to count of blocks - The numbers hadn't ever popped out on other media usage to give it a look.
 
What fun ... and a headache to go with back ache :) :(

You have got that one right. SPI NAND seems to working fine. Not sure what I did to mess up QSPI NAND. To be honest haven't seen much around about people getting LittleFS working with 1GB QSPI NAND.
 
Saw the plusNAND files added to the existing LittleFS files already there, and it has QSPI code - but didn't get as far as moving to build folder and trying anything today :(

Did you have a close to working LFSintegrity.INO?

<edit>
I did move the NAND files to PJRC AVR library and removed the prior sketchbook folder and it is working for SPI.

Will see if I can get to edit to include the QSPI usage.
 
Last edited:
Cute name :: LittleFS_QPINAND::

After fail below I edit .begin to this:
Code:
if (!myfs.begin()) {
  //myfs.begin(chipSelect);
  //if (!myfs.begin(chipSelect)) {
    Serial.println("Error starting spidisk");
    myfs.lowLevelFormat('.');
    if (!myfs.begin())
      while (1) ;
    while (1) ;
  }
It then went through the motions of formatting and this looks wrong? The same Block is read many times? Seems something off in format indexing? Unless blocks are way diff????
Code:
mount after format failed :(
Error starting spidisk
.  flash rd: block=0, offset=0, size=2048
    0A 00 00 00 AF F0 00 01 4B 76 D6 DC FF FF FF FF FF FF FF FF 
  flash er: block=0
Erasing Page: 0
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=2048, size=2048
Read Page Addr Complete: targetPage 65
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=4096, size=2048
Read Page Addr Complete: targetPage 66
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=6144, size=2048
Read Page Addr Complete: targetPage 67
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=8192, size=2048
Read Page Addr Complete: targetPage 68
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=10240, size=2048

...

  flash rd: block=1023, offset=112640, size=2048
Read Page Addr Complete: targetPage 65527
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1023, offset=114688, size=2048
Read Page Addr Complete: targetPage 65528
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1023, offset=116736, size=2048
Read Page Addr Complete: targetPage 65529
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1023, offset=118784, size=2048
Read Page Addr Complete: targetPage 65530
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1023, offset=120832, size=2048
Read Page Addr Complete: targetPage 65531
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1023, offset=122880, size=2048
Read Page Addr Complete: targetPage 65532
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1023, offset=124928, size=2048
Read Page Addr Complete: targetPage 65533
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1023, offset=126976, size=2048
Read Page Addr Complete: targetPage 65534
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1023, offset=129024, size=2048
Read Page Addr Complete: targetPage 65535
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 

  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash er: block=0
Erasing Page: 0
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=2048, size=2048
Read Page Addr Complete: targetPage 1
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash wr: block=0, offset=0, size=2048
Called from PROG: ADDR = 0
RPDL ColumnAddress: 0
PE pageAddress: 0
  waited 2 us
    01 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 00 00 02 00 00 00 02 00 00 04 00 00 27 00 00 00 FF FF FF 7F 
Read Page Addr Complete: targetPage 0
    01 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 00 00 02 00 00 00 02 00 00 04 00 00 27 00 00 00 FF FF FF 7F 
  flash rd: block=0, offset=0, size=2048
    01 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    01 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    01 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash rd: block=0, offset=2048, size=2048
Read Page Addr Complete: targetPage 1
    01 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash er: block=1
Erasing Page: 64
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=2048, size=2048
Read Page Addr Complete: targetPage 65
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash wr: block=1, offset=0, size=2048
Called from PROG: ADDR = 131072
RPDL ColumnAddress: 0
PE pageAddress: 64
  waited 2 us
    02 00 00 00 AF F0 00 01 FE 6D 33 0F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
Read Page Addr Complete: targetPage 64
    02 00 00 00 AF F0 00 01 FE 6D 33 0F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048
    02 00 00 00 AF F0 00 01 FE 6D 33 0F FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    02 00 00 00 AF F0 00 01 FE 6D 33 0F FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    02 00 00 00 AF F0 00 01 FE 6D 33 0F FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    02 00 00 00 AF F0 00 01 FE 6D 33 0F FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=2048, size=2048
Read Page Addr Complete: targetPage 1
    02 00 00 00 AF F0 00 01 FE 6D 33 0F FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    02 00 00 00 AF F0 00 01 FE 6D 33 0F FF FF FF FF FF FF FF FF 
Flash ID: EF AA 21
Flash size is 128.00 Mbyte
attempting to mount existing media
  flash rd: block=0, offset=0, size=2048
    02 00 00 00 AF F0 00 01 FE 6D 33 0F FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048

...

Builds and shows this - tried adding Quick and LLformat - no chage:
Code:
LittleFS Test
Flash ID: EF AA 21
Flash size is 128.00 Mbyte
attempting to mount existing media
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
couldn't mount media, attemping to format
  flash rd: block=1, offset=0, size=2048
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash er: block=0
Erasing Page: 0
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=2048, size=2048
Read Page Addr Complete: targetPage 1
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash wr: block=0, offset=0, size=2048
Called from PROG: ADDR = 0
RPDL ColumnAddress: 0
PE pageAddress: 0
  waited 1 us
    01 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 00 00 02 00 00 00 02 00 00 04 00 00 27 00 00 00 FF FF FF 7F 
Read Page Addr Complete: targetPage 0
    01 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 00 00 02 00 00 00 02 00 00 04 00 00 27 00 00 00 FF FF FF 7F 
  flash rd: block=0, offset=0, size=2048
    01 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    01 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    01 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash rd: block=0, offset=2048, size=2048
Read Page Addr Complete: targetPage 1
    01 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash er: block=1
Erasing Page: 64
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=2048, size=2048
Read Page Addr Complete: targetPage 65
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash wr: block=1, offset=0, size=2048
Called from PROG: ADDR = 131072
RPDL ColumnAddress: 0
PE pageAddress: 64
  waited 2 us
    02 00 00 00 AF F0 00 01 FE 6D 33 0F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
Read Page Addr Complete: targetPage 64
    02 00 00 00 AF F0 00 01 FE 6D 33 0F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048
    02 00 00 00 AF F0 00 01 FE 6D 33 0F FF FF FF FF FF FF FF FF 
attempting to mount freshly formatted media
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    02 00 00 00 AF F0 00 01 FE 6D 33 0F FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    02 00 00 00 AF F0 00 01 FE 6D 33 0F FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    02 00 00 00 AF F0 00 01 FE 6D 33 0F FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=2048, size=2048
Read Page Addr Complete: targetPage 1
    02 00 00 00 AF F0 00 01 FE 6D 33 0F FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    02 00 00 00 AF F0 00 01 FE 6D 33 0F FF FF FF FF FF FF FF FF 
mount after format failed :(
Error starting spidisk

Here is result of QuickFormat replace above LLformat:
Code:
LittleFS Test
Flash ID: EF AA 21
Flash size is 128.00 Mbyte
attempting to mount existing media
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    04 00 00 00 AF F0 00 01 79 64 5C C9 FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    04 00 00 00 AF F0 00 01 79 64 5C C9 FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    04 00 00 00 AF F0 00 01 79 64 5C C9 FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=2048, size=2048
Read Page Addr Complete: targetPage 1
    04 00 00 00 AF F0 00 01 79 64 5C C9 FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    04 00 00 00 AF F0 00 01 79 64 5C C9 FF FF FF FF FF FF FF FF 
couldn't mount media, attemping to format
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    04 00 00 00 AF F0 00 01 79 64 5C C9 FF FF FF FF FF FF FF FF 
  flash er: block=0
Erasing Page: 0
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=2048, size=2048
Read Page Addr Complete: targetPage 1
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash wr: block=0, offset=0, size=2048
Called from PROG: ADDR = 0
RPDL ColumnAddress: 0
PE pageAddress: 0
  waited 2 us
    05 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 00 00 02 00 00 00 02 00 00 04 00 00 27 00 00 00 FF FF FF 7F 
Read Page Addr Complete: targetPage 0
    05 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 00 00 02 00 00 00 02 00 00 04 00 00 27 00 00 00 FF FF FF 7F 
  flash rd: block=0, offset=0, size=2048
    05 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    05 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    05 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash rd: block=0, offset=2048, size=2048
Read Page Addr Complete: targetPage 1
    05 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash er: block=1
Erasing Page: 64
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=2048, size=2048
Read Page Addr Complete: targetPage 65
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash wr: block=1, offset=0, size=2048
Called from PROG: ADDR = 131072
RPDL ColumnAddress: 0
PE pageAddress: 64
  waited 2 us
    06 00 00 00 AF F0 00 01 04 63 79 8B FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
Read Page Addr Complete: targetPage 64
    06 00 00 00 AF F0 00 01 04 63 79 8B FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048
    06 00 00 00 AF F0 00 01 04 63 79 8B FF FF FF FF FF FF FF FF 
attempting to mount freshly formatted media
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    06 00 00 00 AF F0 00 01 04 63 79 8B FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    06 00 00 00 AF F0 00 01 04 63 79 8B FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    06 00 00 00 AF F0 00 01 04 63 79 8B FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=2048, size=2048
Read Page Addr Complete: targetPage 1
    06 00 00 00 AF F0 00 01 04 63 79 8B FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    06 00 00 00 AF F0 00 01 04 63 79 8B FF FF FF FF FF FF FF FF 
mount after format failed :(
Error starting spidisk
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    06 00 00 00 AF F0 00 01 04 63 79 8B FF FF FF FF FF FF FF FF 
  flash er: block=0
Erasing Page: 0
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=2048, size=2048
Read Page Addr Complete: targetPage 1
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash wr: block=0, offset=0, size=2048
Called from PROG: ADDR = 0
RPDL ColumnAddress: 0
PE pageAddress: 0
  waited 1 us
    07 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 00 00 02 00 00 00 02 00 00 04 00 00 27 00 00 00 FF FF FF 7F 
Read Page Addr Complete: targetPage 0
    07 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 00 00 02 00 00 00 02 00 00 04 00 00 27 00 00 00 FF FF FF 7F 
  flash rd: block=0, offset=0, size=2048
    07 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    07 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    07 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash rd: block=0, offset=2048, size=2048
Read Page Addr Complete: targetPage 1
    07 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash er: block=1
Erasing Page: 64
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=2048, size=2048
Read Page Addr Complete: targetPage 65
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash wr: block=1, offset=0, size=2048
Called from PROG: ADDR = 131072
RPDL ColumnAddress: 0
PE pageAddress: 64
  waited 2 us
    08 00 00 00 AF F0 00 01 36 71 F3 9E FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
Read Page Addr Complete: targetPage 64
    08 00 00 00 AF F0 00 01 36 71 F3 9E FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048
    08 00 00 00 AF F0 00 01 36 71 F3 9E FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    08 00 00 00 AF F0 00 01 36 71 F3 9E FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    08 00 00 00 AF F0 00 01 36 71 F3 9E FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    08 00 00 00 AF F0 00 01 36 71 F3 9E FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=2048, size=2048
Read Page Addr Complete: targetPage 1
    08 00 00 00 AF F0 00 01 36 71 F3 9E FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    08 00 00 00 AF F0 00 01 36 71 F3 9E FF FF FF FF FF FF FF FF 
Flash ID: EF AA 21
Flash size is 128.00 Mbyte
attempting to mount existing media
  flash rd: block=0, offset=0, size=2048
    08 00 00 00 AF F0 00 01 36 71 F3 9E FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    08 00 00 00 AF F0 00 01 36 71 F3 9E FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    08 00 00 00 AF F0 00 01 36 71 F3 9E FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=2048, size=2048
Read Page Addr Complete: targetPage 1
    08 00 00 00 AF F0 00 01 36 71 F3 9E FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    08 00 00 00 AF F0 00 01 36 71 F3 9E FF FF FF FF FF FF FF FF 
couldn't mount media, attemping to format
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    08 00 00 00 AF F0 00 01 36 71 F3 9E FF FF FF FF FF FF FF FF 
  flash er: block=0
Erasing Page: 0
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=2048, size=2048
Read Page Addr Complete: targetPage 1
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash wr: block=0, offset=0, size=2048
Called from PROG: ADDR = 0
RPDL ColumnAddress: 0
PE pageAddress: 0
  waited 2 us
    09 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 00 00 02 00 00 00 02 00 00 04 00 00 27 00 00 00 FF FF FF 7F 
Read Page Addr Complete: targetPage 0
    09 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 00 00 02 00 00 00 02 00 00 04 00 00 27 00 00 00 FF FF FF 7F 
  flash rd: block=0, offset=0, size=2048
    09 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    09 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    09 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash rd: block=0, offset=2048, size=2048
Read Page Addr Complete: targetPage 1
    09 00 00 00 F0 0F FF F7 6C 69 74 74 6C 65 66 73 2F E0 00 10 
  flash er: block=1
Erasing Page: 64
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=2048, size=2048
Read Page Addr Complete: targetPage 65
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash wr: block=1, offset=0, size=2048
Called from PROG: ADDR = 131072
RPDL ColumnAddress: 0
PE pageAddress: 64
  waited 2 us
    0A 00 00 00 AF F0 00 01 4B 76 D6 DC FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
Read Page Addr Complete: targetPage 64
    0A 00 00 00 AF F0 00 01 4B 76 D6 DC FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048
    0A 00 00 00 AF F0 00 01 4B 76 D6 DC FF FF FF FF FF FF FF FF 
attempting to mount freshly formatted media
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    0A 00 00 00 AF F0 00 01 4B 76 D6 DC FF FF FF FF FF FF FF FF 
  flash rd: block=1, offset=0, size=2048
Read Page Addr Complete: targetPage 64
    0A 00 00 00 AF F0 00 01 4B 76 D6 DC FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    0A 00 00 00 AF F0 00 01 4B 76 D6 DC FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=2048, size=2048
Read Page Addr Complete: targetPage 1
    0A 00 00 00 AF F0 00 01 4B 76 D6 DC FF FF FF FF FF FF FF FF 
  flash rd: block=0, offset=0, size=2048
Read Page Addr Complete: targetPage 0
    0A 00 00 00 AF F0 00 01 4B 76 D6 DC FF FF FF FF FF FF FF FF 
mount after format failed :(
 
@defragster
Been experimenting a whole bunch and couldn't figure it out - looks like it is writing and erasing correctly and doing the lfs_format correctly. So just now went into lfs_util.h and turned on error, trace, and debug messages plus added a few more LFS_ERRORs so I could trace it better.
Code:
F[COLOR="#FF0000"]:\arduino-1.8.13-beta5\hardware\teensy\avr\libraries\LittleFS\src\littlefs\lfs.c:3790:error: found superblock Error[/COLOR]
F:\arduino-1.8.13-beta5\hardware\teensy\avr\libraries\LittleFS\src\littlefs\lfs.c:3818:trace: lfs_unmount(20002DA0)
F:\arduino-1.8.13-beta5\hardware\teensy\avr\libraries\LittleFS\src\littlefs\lfs.c:3820:trace: lfs_unmount -> 0
[COLOR="#FF0000"]F:\arduino-1.8.13-beta5\hardware\teensy\avr\libraries\LittleFS\src\littlefs\lfs.c:3813:trace: lfs_mount -> -22[/COLOR]
mount after format failed :(

and since I wasn't very descriptive with the error it boils down to that it couldn't find the superblock. Code snippet from lfs.
Code:
    // found superblock?
    if (lfs_pair_isnull(lfs->root)) {
		LFS_ERROR("found superblock Error");
        err = LFS_ERR_INVAL;
        goto cleanup;
    }

Now why this is happening - haven't got a clue.

EDIT: yeah - just got lazy and changed the S in SPINAND to QPINAND - didn't even realize what it was phonetically :)

EDIT2: May be related to this: https://github.com/littlefs-project/littlefs/issues/378, lfs_mount: LFS_ERR_INVAL raised because of unfound superblock
 
Last edited:
Made the change recommended in the LittleFS and also deleted the CAS definition in the begin and now it seems to work:
Code:
LittleFS Test
Flash ID: EF AA 21
Flash size is 128.00 Mbyte
attempting to mount existing media
TotalSize (Bytes): 134217728
started
MAKE files
--------------
printDirectory
--------------
FILE	bigfile.txt  		1849344
DIR	structureData1 / 
	FILE	temp_test.txt		76

 0 dirs with 1 files of Size 76 Bytes
FILE	temp_test1.txt		76
FILE	temp_test2.txt		76
FILE	temp_test3.txt		4096

 1 dirs with 4 files of Size 1853592 Bytes

Disk Usuage:
Bytes Used: 2621440, Bytes Total:134217728
Test for SOME DATA TO TEST

Have to finish incorporating the changes needed for the 2GB chip and will push the changes.
 
Ok - stuck on something. How to convert this to a 24 bit address:
Code:
  //  buf[1] = die_id ;
  //  buf[2] = pageAddr >> 8;
  //  buf[3] = pageAddr;
so i can do this:
Code:
flexspi2_ip_command(12, flashBaseAddr + pageAddr);

I know I did something like this before but my brain is fried :)
 
Seems to be working now ! - Great Work!

Seems to have Read and Write speed improved over SPI using "QPI'/QSPI both at 2,500 Bytes/Sec

Still has NULL print after : Test for SOME DATA TO TEST

Edited the test code to add 2MB file and remove them - didn't look after the wrong file sixe I create yet ...

Code:
LittleFS Test
Flash ID: EF AA 21
Flash size is 128.00 Mbyte
attempting to mount existing media
TotalSize (Bytes): 134217728
started
MAKE files
printDirectory
--------------
FILE	bigfile.txt  		616448
DIR	structureData1 / 
	FILE	temp_test.txt		19

 0 dirs with 1 files of Size 19 Bytes
FILE	temp_test1.txt		19
FILE	temp_test2.txt		19
FILE	temp_test3.txt		1024

 1 dirs with 4 files of Size 617510 Bytes

--------------
printDirectory
--------------
FILE	bigfile.txt  		616448
DIR	structureData1 / 
	FILE	temp_test.txt		38

 0 dirs with 1 files of Size 38 Bytes
FILE	temp_test1.txt		38
FILE	temp_test2.txt		38
FILE	temp_test3.txt		2048

 1 dirs with 4 files of Size 618572 Bytes

Disk Usuage:
Bytes Used: 1310720, Bytes Total:134217728
Test for SOME DATA TO TEST

[B]...  // STILL HAS NULL PRINT VALUE[/B]

printDirectory
--------------
FILE	bigfile.txt  		1232896
DIR	structureData1 / 
	FILE	temp_test.txt		38

 0 dirs with 1 files of Size 38 Bytes
FILE	temp_test1.txt		38
FILE	temp_test2.txt		38
FILE	temp_test3.txt		2048

 1 dirs with 4 files of Size 1235020 Bytes

Mon Dec 21 10:56:18 2020

Start Big write of 2048000 Bytes........................
Big write /0_2MBfile.txt took  0.86 Sec for 2045952 Bytes : file3.size()=2045952
	Big write KBytes per second 2392.54 

Bytes Used: 4063232, Bytes Total:134217728
printDirectory
--------------
FILE	0_2MBfile.txt		2045952
FILE	bigfile.txt  		1232896
DIR	structureData1 / 
	FILE	temp_test.txt		38

 0 dirs with 1 files of Size 38 Bytes
FILE	temp_test1.txt		38
FILE	temp_test2.txt		38
FILE	temp_test3.txt		2048

 1 dirs with 5 files of Size 3280972 Bytes

Mon Dec 21 10:56:32 2020
printDirectory
--------------
FILE	0_2MBfile.txt		2045952
FILE	bigfile.txt  		1232896
DIR	structureData1 / 
	FILE	temp_test.txt		38

 0 dirs with 1 files of Size 38 Bytes
FILE	temp_test1.txt		38
FILE	temp_test2.txt		38
FILE	temp_test3.txt		2048

 1 dirs with 5 files of Size 3280972 Bytes

Mon Dec 21 10:56:32 2020

Start Big write of 2048000 Bytes........................
Big write /1_2MBfile.txt took  0.86 Sec for 2045952 Bytes : file3.size()=2045952
	Big write KBytes per second 2386.17 

Bytes Used: 6160384, Bytes Total:134217728
printDirectory
--------------
FILE	0_2MBfile.txt		2045952
FILE	1_2MBfile.txt		2045952
FILE	bigfile.txt  		1232896
DIR	structureData1 / 
	FILE	temp_test.txt		38

 0 dirs with 1 files of Size 38 Bytes
FILE	temp_test1.txt		38
FILE	temp_test2.txt		38
FILE	temp_test3.txt		2048

 1 dirs with 6 files of Size 5326924 Bytes

Mon Dec 21 10:56:39 2020
printDirectory
--------------
FILE	0_2MBfile.txt		2045952
FILE	1_2MBfile.txt		2045952
FILE	bigfile.txt  		1232896
DIR	structureData1 / 
	FILE	temp_test.txt		38

 0 dirs with 1 files of Size 38 Bytes
FILE	temp_test1.txt		38
FILE	temp_test2.txt		38
FILE	temp_test3.txt		2048

 1 dirs with 6 files of Size 5326924 Bytes

Mon Dec 21 10:56:39 2020

Delete with read verify all #bigfile's
	Verify /0_2MBfile.txt bytes 2045952 : ..................................................	GOOD! >>  bytes 2045952
	Big read&compare KBytes per second 2427.68 
	Verify /1_2MBfile.txt bytes 2045952 : ..................................................	GOOD! >>  bytes 2045952
	Big read&compare KBytes per second 2428.00 
printDirectory
--------------
FILE	bigfile.txt  		1232896
DIR	structureData1 / 
	FILE	temp_test.txt		38

 0 dirs with 1 files of Size 38 Bytes
FILE	temp_test1.txt		38
FILE	temp_test2.txt		38
FILE	temp_test3.txt		2048

 1 dirs with 4 files of Size 1235020 Bytes

Mon Dec 21 10:56:43 2020
printDirectory
--------------
FILE	bigfile.txt  		1232896
DIR	structureData1 / 
	FILE	temp_test.txt		38

 0 dirs with 1 files of Size 38 Bytes
FILE	temp_test1.txt		38
FILE	temp_test2.txt		38
FILE	temp_test3.txt		2048

 1 dirs with 4 files of Size 1235020 Bytes

Mon Dec 21 10:56:43 2020
 
The problem with bigFile2MB was missing >= as the file write was changed - here is OLD and NEW file:

Code:
FILE	0_2MBfile.txt		2045952
FILE	1_2MBfile.txt		2048000

Change to ">=":
Code:
    while ( toWrite >= 2048 && resW > 0 ) {

TESTED these and they seem to work in :: \LittleFS\examples\littlefs_teensy_test1a\littlefs_teensy_test1a.ino
Code:
void loop() {
  if ( Serial.available() ) {
    char rr;
    rr = Serial.read();
  [B]  if (rr == 'B') bigFile2MB(1);
    if (rr == 'b') bigFile2MB(0);
    if (rr == 'q') myfs.quickFormat();
    if (rr == 'F') myfs.lowLevelFormat('.');
    if (rr == 'f') myfs.formatUnused( 0 , 0 );
[/B]
    printDirectory();
  time_t t = rtc_get();
  Serial.print(std::ctime(&t));
  }
}

Will go update LFSintegrity and post on git"plusNAND
 
Ready to upload updated INO's.

@mjs513 : some number of warnings in NAND build
and on SPI_NAND some prolific prints of these I killed ??? (read, write, erase):: flash rd: block=0, offset=40960, size=2048

NAND FORMAT of block seems quick! { search is slow parsing 128MB of course :: 40,696,688 us when ALREADY formatted and only 30 sec when 267 blocks ARE FORMATTED! } :: formatUnused() seems to work.

Output Spew from LFSintegrity - All Good:
Code:
Delete with read verify all #bigfile's
	Verify /0_2MBfile.txt bytes 2048000 : ..................................................	GOOD! >>  bytes 2048000
	Big read&compare KBytes per second 2341.16 
	Verify /1_2MBfile.txt bytes 2048000 : ..................................................	GOOD! >>  bytes 2048000
	Big read&compare KBytes per second 2341.41 
	Verify /2_2MBfile.txt bytes 2048000 : ..................................................	GOOD! >>  bytes 2048000
	Big read&compare KBytes per second 2341.69 
	Verify /3_2MBfile.txt bytes 2048000 : ..................................................	GOOD! >>  bytes 2048000
	Big read&compare KBytes per second 2342.04 
	Verify /4_2MBfile.txt bytes 2048000 : ..................................................	GOOD! >>  bytes 2048000
	Big read&compare KBytes per second 2342.31 

[  0.41 M](0.40985 M elap) Awaiting input 0123456789RdchkFqvplmusSBbyYxfa+-? loops left 0 >
 myfs.formatUnused( 0 ) ...
FMT 336,FMT 337,FMT 338,FMT 339,FMT 340,FMT 341,FMT 342,FMT 343,	#8
FMT 344,FMT 345,FMT 346,FMT 347,FMT 348,FMT 349,FMT 350,FMT 351,	#16
FMT 352,FMT 353,FMT 354,FMT 355,FMT 356,FMT 357,FMT 358,FMT 359,	#24
FMT 360,FMT 361,FMT 362,FMT 363,FMT 364,FMT 365,FMT 366,FMT 367,	#32
FMT 368,FMT 369,FMT 370,FMT 371,FMT 372,FMT 373,FMT 374,FMT 375,	#40
FMT 376,FMT 377,FMT 378,FMT 379,FMT 380,FMT 381,FMT 382,FMT 383,	#48
FMT 384,FMT 385,FMT 386,FMT 387,FMT 388,FMT 389,FMT 390,FMT 391,	#56
FMT 392,FMT 393,FMT 394,FMT 395,FMT 396,FMT 397,FMT 398,FMT 399,	#64
FMT 400,FMT 401,FMT 402,FMT 403,FMT 404,FMT 405,FMT 406,FMT 407,	#72
FMT 408,FMT 409,FMT 410,FMT 411,FMT 412,FMT 413,FMT 414,FMT 415,	#80

	 formatUnused :: Done Formatting Low Level in 7626498 us.

[  0.58 M](0.12711 M elap) Awaiting input 0123456789RdchkFqvplmusSBbyYxfa+-? loops left 0 >1
:: /B_file.txt  SPI_NAND +++ Add [sz 0 add 1024] @KB/sec 31.73 ++ B   Verify /B_file.txt 1024B  @KB/sec 112.17 
:: /C_file.txt  SPI_NAND +++ Add [sz 0 add 1024] @KB/sec 102.95 ++ C   Verify /C_file.txt 1024B  @KB/sec 106.83 
[ 15.48 M](0.00191 M elap) Awaiting input 0123456789RdchkFqvplmusSBbyYxfa+-? loops left 0 >1
:: /D_file.txt  SPI_NAND +++ Add [sz 0 add 1024] @KB/sec 102.95 ++ D   Verify /D_file.txt 1024B  @KB/sec 101.98 
:: /E_file.txt  SPI_NAND +++ Add [sz 0 add 1024] @KB/sec 102.95 ++ E   Verify /E_file.txt 1024B  @KB/sec 97.54 
[ 15.54 M](0.00171 M elap) Awaiting input 0123456789RdchkFqvplmusSBbyYxfa+-? loops left 0 >1
:: /F_file.txt  SPI_NAND +++ Add [sz 0 add 1024] @KB/sec 102.94 ++ F   Verify /F_file.txt 1024B  @KB/sec 93.49 
:: /G_file.txt  SPI_NAND +++ Add [sz 0 add 1024] @KB/sec 102.95 ++ G   Verify /G_file.txt 1024B  @KB/sec 89.75 
[ 15.56 M](0.00191 M elap) Awaiting input 0123456789RdchkFqvplmusSBbyYxfa+-? loops left 0 >1
:: /H_file.txt  SPI_NAND +++ Add [sz 0 add 1024] @KB/sec 102.95 ++ H   Verify /H_file.txt 1024B  @KB/sec 86.30 
:: /I_file.txt  SPI_NAND +++ Add [sz 0 add 1024] @KB/sec 102.95 ++ I   Verify /I_file.txt 1024B  @KB/sec 83.10 
[ 15.67 M](0.00214 M elap) Awaiting input 0123456789RdchkFqvplmusSBbyYxfa+-? loops left 0 >
Start Big write of 65908736 Bytes....................................................................................  // { MANY ...'s deleted }
Big write /0_bigfile.txt took 27.26 Sec for 65906688 Bytes : file3.size()=65906688
	Big write KBytes per second 2417.79 

Bytes Used: 68288512, Bytes Total:134217728

[ 16.20 M](0.45631 M elap) Awaiting input 0123456789RdchkFqvplmusSBbyYxfa+-? loops left 0 >
Delete with read verify all #bigfile's
	Verify /0_bigfile.txt bytes 65906688 : ..................................................	GOOD! >>  bytes 65906688
	Big read&compare KBytes per second 2342.98 

[ 16.75 M](1.01090 M elap) Awaiting input 0123456789RdchkFqvplmusSBbyYxfa+-? loops left 0 > d
printDirectory SPI_NAND
--------------
FILE	B_file.txt		1024
FILE	C_file.txt		1024
FILE	D_file.txt		1024
FILE	E_file.txt		1024
FILE	F_file.txt		1024
FILE	G_file.txt		1024
FILE	H_file.txt		1024
FILE	I_file.txt		1024
FILE	bigfile.txt  		616448
DIR	structureData1 / 
	FILE	temp_test.txt		19

 0 dirs with 1 files of Size 19 Bytes
FILE	temp_test1.txt		19
FILE	temp_test2.txt		19
FILE	temp_test3.txt		1024

 1 dirs with 12 files of Size 625702 Bytes
 Total 13 files of Size 625721 Bytes
Bytes Used: 2359296, Bytes Total:134217728


	 Loop Count: 14 (#fileCycle=8), Bytes read 76154880, written 8192, #Files=13
 
@defragster
Thanks for testing it more thoroughly. Got tired so didn’t give LFSIntegrity a try. Will download your updated test sketch next I am on the PC, on my phone right now.

Not really ready for prime time as they say. Have a bunch of cleaning and simplification of the updates. You saw some warnings I have to clean up. That’s the tip of the ice berg. But at least I have a working interface so when I make further changes will be easier to revert.

But that’s for tonight and tomorrow.
 
@mjs513 / @all :: Updated github.com/Defragster/LFSintegrity/tree/PlusNAND

No Rush indeed - not sure when Next 1.54 Beta set to drop ? And if this is ready to integrate - but looks good in testing so far.

LFSintegrity and the other demo 'littlefs_teensy_test1a' sketch updated.

Local copy made bigger and more files in each iteration to test. Turning on AUTO formatUnused a bit aggressive as coded for this NAND Media - it doesn't leave as much dirtied given the block size and organization ?
The bAutoFormat as implemented not ideal ... but this is better on NAND given the long search time - in TWO PLACES.
Code:
				//if ( bAutoFormat && !(lCnt % 5) ) res = myfs.formatUnused( 20, res );
				if ( bAutoFormat && !(lCnt % 20) ) res = myfs.formatUnused( 3, res );

<edit> iterations are not fast with 26 files and 32 subdirs (as an iteration does bigger batches) - BUT THEY WORK on QSPI NAND:
Code:
 33 dirs with 14 files of Size 824358 Bytes
 Total 227 files of Size 19438649 Bytes
Bytes Used: 45350912, Bytes Total:134217728
 
Sounding great! May have to play soon! Distractions Distractions ...

Which projects do I need to sync up to? Your LFSIntegrety?
 
Running the QSPI NAND LittleFS and some iterations. Added a 60MB file to make it fill with some occasional formatUnused kept it pretty well formatted - only 14 unformatted.

After this another iteration stopped some write from disk looking full. So it runs empty and Full, and no data loss or troubles. New NAND media works as well as all the LittleFS AFAIK.
Testable mixed byte data writes are at about 1.2 MB/sec but BIGfile 2K block writes are about 2.2 MB/sec.
The DIR DATA below shows overhead on 88 MB is 43 MB ????::
Code:
 0 dirs with 10 files of Size 643072 Bytes
FILE	A_file.txt		125952
FILE	B_file.txt		15360
FILE	C_file.txt		27648
FILE	D_file.txt		26624
FILE	E_file.txt		34816
FILE	F_file.txt		64512
FILE	G_file.txt		76800
FILE	H_file.txt		89088
FILE	I_file.txt		101376
FILE	J_file.txt		113664
FILE	K_file.txt		125952
FILE	L_file.txt		138240
FILE	M_file.txt		150528
FILE	N_file.txt		162816
FILE	O_file.txt		175104
FILE	P_file.txt		124928
FILE	Q_file.txt		133120
FILE	R_file.txt		211968
FILE	S_file.txt		224256
FILE	T_file.txt		236544
FILE	U_file.txt		248832
FILE	V_file.txt		261120
FILE	W_file.txt		273408
FILE	X_file.txt		285696
FILE	Y_file.txt		297984
FILE	Z_file.txt		310272
FILE	bigfile.txt  		616448
DIR	structureData1 / 
	FILE	temp_test.txt		19

 0 dirs with 1 files of Size 19 Bytes
FILE	temp_test1.txt		19
FILE	temp_test2.txt		19
FILE	temp_test3.txt		1024

 33 dirs with 37 files of Size 35793958 Bytes
[B] Total 484 files of Size 88534073 Bytes
Bytes Used: 132382720, Bytes Total:134217728[/B]


	 Loop Count: 19 (#fileCycle=972), Bytes read 82278400, written 38002688, #Files=484
[182.26 M](0.26027 M elap) Awaiting input 0123456789RdchkFqvplmusSBbyYxfa+-? loops left 0 >

[182.26 M](0.26027 M elap) Awaiting input 0123456789RdchkFqvplmusSBbyYxfa+-? loops left 0 >
 myfs.formatUnused( 0 ) ...
FMT 153,FMT 154,FMT 690,FMT 692,FMT 693,FMT 694,FMT 695,FMT 721,	#8
FMT 723,FMT 724,FMT 748,FMT 755,FMT 758,FMT 759,
	 formatUnused :: Done Formatting Low Level in 857292 us.
 
@defragster - @KurtE
Just pushed a whole lot of cleanup and consolidation to the plusNAND branch LFSIntegrity repository. Don't know if that will make any difference or not.

Not sure why such a big difference. wonder if BytesUSed is being correctly reported:
Code:
 33 dirs with 37 files of Size 35793958 Bytes
 Total 484 files of Size [COLOR="#FF0000"]88534073 [/COLOR]Bytes
Bytes Used: [COLOR="#FF0000"]132382720[/COLOR], Bytes Total:134217728
 
@mjs513 - that builds more cleanly - seems to work as well.

When the LFS_Traverse is done if the reported BLOCK count is displayed it would show how many are used/Free. That debug SPEW may be in there and disabled?
 
@defragster - @KurtE
Just pushed a whole lot of cleanup and consolidation to the plusNAND branch LFSIntegrity repository. Don't know if that will make any difference or not.

Not sure why such a big difference. wonder if BytesUSed is being correctly reported:
Code:
 33 dirs with 37 files of Size 35793958 Bytes
 Total 484 files of Size [COLOR="#FF0000"]88534073 [/COLOR]Bytes
Bytes Used: [COLOR="#FF0000"]132382720[/COLOR], Bytes Total:134217728

First I thought I would mention that I synced up, deleted my link to LittleFS directory in <sketches>/libraries and created new link to this version.
Then opened your sketch littlefs_teensy_test1a on my T4.1 with the 1GB I soldered onto QSPI pins awhile ago and it never worked...

But now :D
Code:
usb_cdc_line_coding, baud=115200
usb_cdc_line_coding, baud=115200
usb_cdc_line_coding, baud=115200
usb_cdc_line_coding, baud=115200
LittleFS Test
Flash ID: EF AA 21
Flash size is 128.00 Mbyte
attempting to mount existing media
couldn't mount media, attemping to format
attempting to mount freshly formatted media
TotalSize (Bytes): 134217728
started
MAKE files
printDirectory
--------------
DIR	structureData1 / 

 0 dirs with 0 files of Size 0 Bytes

 1 dirs with 0 files of Size 0 Bytes

--------------
printDirectory
--------------
DIR	structureData1 / 
	FILE	temp_test.txt		19

 0 dirs with 1 files of Size 19 Bytes
FILE	temp_test1.txt		19
FILE	temp_test2.txt		19
FILE	temp_test3.txt		1024

 1 dirs with 3 files of Size 1062 Bytes

Disk Usuage:
Bytes Used: 655360, Bytes Total:134217728
Test for SOME DATA TO TEST

As for differences in used space, I wonder if that is all the overhead of littleFS where one size reported is how many bytes you can read, where the FS may have multiple nodes (maybe wrong terminology), with different versions of each block ... Just guessing.
 
@KurtE - @defragster
Glad the new version is working and cleaner - think I got rid of all the warnings now :)

@KurtE you might be right. Was just playing a bit more more and thinking that since the eraseSize of 128K is the block size for the NAND as opposed 4K for the other Winbond FLASH chips you are going to have a heck of alot more overhead probably because (guessing here) of the requirement of Directory pairs and unused space in a block?
 
128KB erase size makes sense with 1024 blocks on disk.

Good thing is files are store in the Dir block when they fit and that means 'small' files under 128 KB inclined to be good without wasting space.

There was a debug in :: cb_usedBlocks() under extreme debug moved like this in LittleFS.cpp !line 290:
Code:
#ifdef DEBUGCF
	uint32_t totBlock = cb_usedBlocks( nullptr, 0 ); // get total blocks used
	Serial.printf( "\n\n formatUnused() checkUsed: lfs Used Blocks Map: #used is %lu ( of %lu ) : lfs traverse return %i (neg on err)\n", totBlock, config.block_count, err );
#endif
#ifdef DEBUGCF_2

That shows this when a 'y' is done after a DIR:
Code:
Bytes Used: 104464384, Bytes Total:134217728
 myfs.formatUnused( 1 ) ...

 formatUnused() checkUsed: lfs Used Blocks Map: #used is 861 ( of 1024 ) : lfs traverse return 0 (neg on err)

So blocks used is 861 / 1024 == 0.715%

And from DIR 104464384 / 134217728 == 0.778%

That sounds like all is about right with free space as there is other overhead beyond used space that LFS may include in some fashion

What is REALLY ODD is doing two BIG files each using HALF of remaining space yields this where 1032 of the 1024 blocks are IN USE ???:
Code:
 Total 674 files of Size 67141632 Bytes
Bytes Used: 126877696, Bytes Total:134217728
 formatUnused() checkUsed: lfs Used Blocks Map: #[B]used is 1032 ( of 1024 )[/B]

Then starting an iteration ( without any DELETES ) show 53 BLOCKS open to FORMAT ???? All the files exisited ( none new made) just extended

Now it shows even more #1052 used of 1024 - and the same 674 files:
Code:
 Total 674 files of Size 69939200 Bytes
Bytes Used: 129499136, Bytes Total:134217728


	 Loop Count: 10 (#fileCycle=52), Bytes read 7755776, written 2797568, #Files=674
 myfs.formatUnused( 1 ) ...


 formatUnused() checkUsed: lfs Used Blocks Map: #used is 1052 ( of 1024 )

So how it calculates Free space and reports blocks used is odd, I never put in debug for saying the same block is used multiple times ( set the bit when bit already set ) as that is an LFS decision I suppose?
 
iterations led to this - Full disk : ERR -28

Code:
:: /29_dir/H_file.txt  SPI_NAND +++ Add [sz 59392 add 29696] @KB/sec 21.74 ++ H   Verify /29_dir/H_file.txt 89088B  @KB/sec 1312.22 
:: /29_dir/I_file.txt  SPI_NAND +++ Add [sz 101376 add 29697] @KB/sec 11.00
	[B]write fail ERR# -28 0xFFFFFFE4 [/B]
0[ 53.32 M](7.10113 M elap) Awaiting input 0123456789RdchkFqvplmusSBbyYxfa+-? loops left 0 >0
	 Loop Count: 15 (#fileCycle=424), Bytes read 46284800, written 16936961, #Files=674
	 ERROR COUNT =1

 ++ I   Verify /29_dir/I_file.txt 101376B  @KB/sec 1316.45 
[200.71 M](11.32455 M elap) Awaiting input 0123456789RdchkFqvplmusSBbyYxfa+-? loops left 0 >

It kept the old file size and verified - then 'd'ir and 'y' shows Bytes usedTotal ... and used BLOCKS.
Showing : 131,072 bytes free - but failed when adding 29,697 bytes to a file of 101,376 bytes. Which could explain the failure if it had to duplicate the data to add to it in some fashion.
>> So other than the "non-standard Error Return" KurtE noted - it failed gracefully and not surprisingly.

Code:
 Total 674 files of Size 75521024 Bytes
Bytes Used: 134086656, Bytes Total:134217728


	 Loop Count: 16 (#fileCycle=424), Bytes read 46386176, written 16936961, #Files=674
	 ERROR COUNT =1

 myfs.formatUnused( 1 ) ...


 formatUnused() checkUsed: lfs Used Blocks Map: #used is 1087 ( of 1024 ) : lfs traverse return 0 (neg on err)

	 formatUnused :: Done Formatting Low Level in 1308364 us (last 0).

Note: Doing a DIR check 'l' takes like 15 seconds ( dir is 30 with 15 for dir and then the 'l' check ) with 674 files in root and 32 subdirs ... testing with 4* on these - no real speed increase:
Code:
	config.cache_size = 4*info->progsize;
	config.lookahead_size = 4*info->progsize;
With only 1024 blocks 256B (progsize) would give bitmap of 2048 so no help there.
 
Just received a message from Christopher Hasterat LittleFS.
Ah! I marked this as "needs fix" so I wouldn't forget about it, and then forgot about it. My bad.

Pushed up the fix here: #508, thanks for the reminder.
I posted that the change worked as part of this issue: https://github.com/littlefs-project/littlefs/issues/378. The fix is exactly the same as I implemented for moving the sanity check if lfs_format after compaction. So looks like littleFS will need to be updated for the next beta update as well.
 
@defragster - @KurtE
Just pushed an update to QPINAND to support a W25N02 flash but really no way to test it at this point.

Now just to figure out what I need to do to finish off ECC at least for the W25N01. The W25N02 adds a bit more info in terms of parity bits :(

Thought of one more thing in terms of memory usage. Some of the chips memory is reserved for ECC. For instance while the page size is 2048 its really 2112 bytes. The other 64bytes per page is reserved for ECC.
 
Back
Top