LittleFS port to Teensy/SPIFlash

You too and me too that its working. Probably should solder up the M02 chips - still on track for Monday to get mine and then solder and test :)

EDIT: Now I have to sync up with MTP but not sure what version I should use.

Me too! - I need to double check that that branch (send_object_yield) still copies OK, I think I had a file corrupted. Will be trying it again maybe today.

I may also check out @WMXZ version as well, to see how he is trying to do some events generation. I know he said he had some success with the reset device one. But I may try to add in my code again to have my sample sketch to generate a new file and have it send an event (probably 2) to windows to update from.

Probably using the stuff from my USBHost MTPDevice test code.
Example output - cut out some of the initial debug stuff:
Code:
*** Device MTPD 1949: c - connected ***
  manufacturer: Android
  product: Android
  Serial: D0FCA0A0342600M6
    STD Version:64
    Vendor extesion ID:6
    MTP Version:64
    Extensions:microsoft.com: 1.0; android.com: 1.0;
    Mode:0
    Operations: 1001 1002 1003 1004 1005 1006 1007 1008 1009 100A 100B 100C 100D 1014 1015 1016 1017 101B 9801 9802 9803 9804 9805 9810 9811 95C1 95C2 95C3 95C4 95C5
    Events: 4002 4003 4004 4005 C801 400C
    Device Properties: D401 D402 5003
    Capture formats:
    Playback formats: 3000 3001 3004 3005 3008 3009 300B 3801 3802 3804 3807 3808 380B 380D B901 B902 B903 B982 B983 B984 BA05 BA10 BA11 BA14 BA82 B906
    Manufacturer:Amazon
    Model:Fire
    Serial:1.0
Get Storage IDS: 10001

*** MPT connected ***
Connected to:
Count of Storages: 1
0(10001): Internal storage() type:3 2 max:27571462144, free: 22527651840 access:0

========== Internal storage ===========
Music(1) FMT:3001 Size:0
Podcasts(2) FMT:3001 Size:0
Ringtones(3) FMT:3001 Size:0
Alarms(4) FMT:3001 Size:0
Notifications(5) FMT:3001 Size:0
Pictures(6) FMT:3001 Size:0
Movies(7) FMT:3001 Size:0
Download(8) FMT:3001 Size:0
DCIM(9) FMT:3001 Size:0
Android(a) FMT:3001 Size:4096
kindle(3a) FMT:3001 Size:4096
Books(3b) FMT:3001 Size:4096
Documents(3e) FMT:3001 Size:0
.imagecache(40) FMT:3001 Size:0
Audible(44) FMT:3001 Size:0
Contacts(b0) FMT:3001 Size:0
.bugsense(272) FMT:3000 Size:33
mapquest(276) FMT:3001 Size:0
sirius(421) FMT:3001 Size:4096
TuneIn Radio(5e6) FMT:3001 Size:4096
amazonmp3(925) FMT:3001 Size:0
AccuWeather(107c) FMT:3001 Size:0
.backups(115c) FMT:3001 Size:0
.chartboost(1160) FMT:3001 Size:0
zzz(14fe) FMT:3004 Size:0
rx event, len=1, i=0
rx queue i=0

---------- Commands ----------
  s - Show storage list
  e - enum <ID>
  d - dump storage list
  R - Remove <ID> 
rx event, len=5, i=1
rx queue i=1


 ================= Start ENUM(62:Documents) =================

========== Enum completed (62:Documents ===========
Sidecars(3f) FMT:3001 Size:4096
PSNL!DigitalSupportPSNLs!bWFrZVNvZnR3YXJlVXBncmFkZUxldHRlci5odG1sLz9sb2NhbGU9QVRWUERLSUtYMERFUg_PSNL(6b4) FMT:3000 Size:88192
PSNL!DigitalSupportPSNLs!bWFrZVNvZnR3YXJlVXBncmFkZUxldHRlci5odG1sLz9sb2NhbGU9QVRWUERLSUtYMERFUg_PSNL.prc(6e4) FMT:3001 Size:0
PSNL!DigitalSupportPSNLs!bWFrZVdhUG9MZXR0ZXIuaHRtbD9iaW5hcnk9bW9iaTg_PSNL(752) FMT:3000 Size:81760
my data(14fc) FMT:3004 Size:0
Naxos.xls(14fd) FMT:ba85 Size:11776
abcdefg(1501) FMT:3000 Size:0
qwerty(1502) FMT:3000 Size:0
kkk(1504) FMT:3000 Size:0


EVENT C<- len:16 EVENT:  OP:4002(EVT:OBJECT_ADDED) TID:166 P:1505
EVENT C<- len:16 EVENT:  OP:400c(EVT:STORAGE_INFO_CHANGED) TID:169 P:10001
mtpd_event_callback 4002 1505 20206a88 : 0 0 20206320
 CALLBACK: Object added: 20206a88 ID:00001505 P:20206320 C:0000: S:00010001 F:3000 new_file
mtpd_event_callback 400c 10001 - no node
CALLBACK: Storage Changed: 10001
EVENT C<- len:16 EVENT:  OP:4003(EVT:OBJECT_REMOVED) TID:171 P:1504
mtpd_event_callback 4003 1504 202068c8 : 0 0 20206320
 CALLBACK: Object removed: ## FreeStorageListTree: 202068c8 1504 10001: kkk
EVENT C<- len:16 EVENT:  OP:400c(EVT:STORAGE_INFO_CHANGED) TID:171 P:10001
mtpd_event_callback 400c 10001 - no node
CALLBACK: Storage Changed: 10001

20006f70 ID:00010001 P:0000 C:202060e0: S:00010001 F:3001 Internal storage
202060e0   ID:00000001 P:20006f70 C:0000: S:00010001 F:3001 Music
20206110   ID:00000002 P:20006f70 C:0000: S:00010001 F:3001 Podcasts
20206140   ID:00000003 P:20006f70 C:0000: S:00010001 F:3001 Ringtones
20206170   ID:00000004 P:20006f70 C:0000: S:00010001 F:3001 Alarms
202061a0   ID:00000005 P:20006f70 C:0000: S:00010001 F:3001 Notifications
202061d0   ID:00000006 P:20006f70 C:0000: S:00010001 F:3001 Pictures
20206200   ID:00000007 P:20006f70 C:0000: S:00010001 F:3001 Movies
20206230   ID:00000008 P:20006f70 C:0000: S:00010001 F:3001 Download
20206260   ID:00000009 P:20006f70 C:0000: S:00010001 F:3001 DCIM
20206290   ID:0000000a P:20006f70 C:0000: S:00010001 F:3001 Android
202062c0   ID:0000003a P:20006f70 C:0000: S:00010001 F:3001 kindle
202062f0   ID:0000003b P:20006f70 C:0000: S:00010001 F:3001 Books
20206320   ID:0000003e P:20006f70 C:20206748: S:00010001 F:3001 Documents
20206748     ID:0000003f P:20206320 C:0000: S:00010001 F:3001 Sidecars
20206778     ID:000006b4 P:20206320 C:0000: S:00010001 F:3000 PSNL!DigitalSupportPSNLs!bWFrZVNvZnR3YXJlVXBncmFkZUxldHRlci5odG1sLz9sb2NhbGU9QVRWUERLSUtYMERFUg_PSNL
202067a8     ID:000006e4 P:20206320 C:0000: S:00010001 F:3001 PSNL!DigitalSupportPSNLs!bWFrZVNvZnR3YXJlVXBncmFkZUxldHRlci5odG1sLz9sb2NhbGU9QVRWUERLSUtYMERFUg_PSNL.prc
202067d8     ID:00000752 P:20206320 C:0000: S:00010001 F:3000 PSNL!DigitalSupportPSNLs!bWFrZVdhUG9MZXR0ZXIuaHRtbD9iaW5hcnk9bW9iaTg_PSNL
20206808     ID:000014fc P:20206320 C:0000: S:00010001 F:3004 my data
20206838     ID:000014fd P:20206320 C:0000: S:00010001 F:ba85 Naxos.xls
20206868     ID:00001501 P:20206320 C:0000: S:00010001 F:3000 abcdefg
20206898     ID:00001502 P:20206320 C:0000: S:00010001 F:3000 qwerty
20206a88     ID:00001505 P:20206320 C:0000: S:00010001 F:3000 new_file
20206350   ID:00000040 P:20006f70 C:0000: S:00010001 F:3001 .imagecache
20206380   ID:00000044 P:20006f70 C:0000: S:00010001 F:3001 Audible
202063b0   ID:000000b0 P:20006f70 C:0000: S:00010001 F:3001 Contacts
202063e0   ID:00000272 P:20006f70 C:0000: S:00010001 F:3000 .bugsense
20206410   ID:00000276 P:20006f70 C:0000: S:00010001 F:3001 mapquest
20206440   ID:00000421 P:20006f70 C:0000: S:00010001 F:3001 sirius
20206470   ID:000005e6 P:20006f70 C:0000: S:00010001 F:3001 TuneIn Radio
202064a0   ID:00000925 P:20006f70 C:0000: S:00010001 F:3001 amazonmp3
202064d0   ID:0000107c P:20006f70 C:0000: S:00010001 F:3001 AccuWeather
20206500   ID:0000115c P:20006f70 C:0000: S:00010001 F:3001 .backups
20206530   ID:00001160 P:20006f70 C:0000: S:00010001 F:3001 .chartboost
20206560   ID:000014fe P:20006f70 C:0000: S:00010001 F:3004 zzz
Yeah I know spending too much time on something that probably won't go anywhere. But I do have it it enumerating the storage, allow me to enumerate a storage or directory, and then might see I went on kindle and created a new file and received two callbacks, then deleted another one. On the Add one I then had my code ask for all of the properties and then linked it into the right tree... But currently just using malloc for all of these nodes.

The good news is I am getting better understanding...

Also I am going to now split off the Serial emulation code and Serial fixes into new branch and try to PU it. And then rebase this code again on new branch. But current branch has been updated.
 
@KurtE
well everybody is waking up now and making breakfast.

Think I am going to have to catch up on the MTP thread to see whats going on. With that said, I kind of like the idea of expanding USBHost. Even better that you are getting a better understanding of whats going on with events!

Just tested SPINand with a T3.5 and its working but did have to delete this from the .h file:
Code:
#else
class LittleFS_QSPIFlash : public LittleFS
{
public:
	LittleFS_QSPIFlash() { }
	bool begin() { return false; }
};
otherwise it throws an error.
 
@mjs513 hope you have a good Christmas breakfast. A quick FYI - I split my USBHost thing into two new branches.
So that the SEREMU now renamed to USBSerialEmu and the fix to USBSerial are in their own thread and I issued a PR for that.

And then created a new branch based off that new PR branch to have the MTP stuff. New branch is called MTP_Device.

Will now try syncing up to this Project and build an MTP T4.1 with the 4 chips external. Not sure to continue with #37 T4.1 or try to replace with the NAND one..
 
Started an overnight SPI NAND 2Gb run - after restarting from image in use.

Did 220 iterations overnight and then told it to stop after 100 this AM - finally finished - no signs of trouble.
Did lots of I/O :: Bytes read 5,392,233,472, written 5,435,334,656 > that was 'n'o verify on writes so read and write are closer with verify on Delete
Doing a Dir Verify file count takes :: dirV...18,423,529_us >> 18 seconds printing the dir is the same with added printing.
Code:
 32 dirs with 33 files of Size 15831040 Bytes
 Total 839 files of Size 81860608 Bytes
Bytes Used: 154664960, Bytes Total:268435456


	 Loop Count: 320 (#fileCycle=141436), Bytes read 5392233472, written 5435334656, #Files=839
	dirV...18424975_us	[697.62 M](0.66847 M elap) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 >
	 Loop Count: 320 (#fileCycle=141436), Bytes read 5392233472, written 5435334656, #Files=839
	dirV...18423529_us	
 myfs.formatUnused( 1 ) ...


 formatUnused() checkUsed: lfs Used Blocks Map: #used is 1244 ( of 2048 ) : lfs traverse return 0 (neg on err)
FMT 47,
	 formatUnused :: Done Formatting Low Level in 3257769 us (last 48).

This run was 'a'uto formatUnused Off()
Did a Single 'y' above to show the parse works and the used block count.

a Full 'f'ormatUnused() ends with 867 blocks dirty and formatted in 4.68 seconds:
Code:
...
FMT 1935,FMT 1936,FMT 1937,FMT 1944,FMT 1945,FMT 1948,FMT 1949,FMT 1957,	#856
FMT 1958,FMT 1959,FMT 1960,FMT 1973,FMT 1974,FMT 1977,FMT 1979,FMT 2006,	#864
FMT 2007,FMT 2008,FMT 2009,
	 formatUnused :: Done Formatting Low Level in 4687441 us.

Doing '1' iteration after that is all good.

I/O times not fast on SPI with this NAND - but they work:
Code:
:: /27_dir/P_file.txt  SPI_NAND +++ Add [sz 0 add 62464] @KB/sec 730.97 {341.21}  ++ P 
:: /27_dir/Q_file.txt  SPI_NAND +++ Add [sz 0 add 66560] @KB/sec 44.99 {42.15}  ++ Q 
:: /27_dir/R_file.txt  SPI_NAND +++ Add [sz 0 add 70656] @KB/sec 764.56 {608.17}  ++ R 
:: /27_dir/S_file.txt  SPI_NAND +++ Add [sz 0 add 74752] @KB/sec 777.39 {610.87}  ++ S 
:: /27_dir/T_file.txt  SPI_NAND +++ Add [sz 0 add 78848] @KB/sec 789.70 {613.26}  ++ T 
:: /27_dir/U_file.txt  SPI_NAND +++ Add [sz 0 add 82944] @KB/sec 803.52 {616.86}  ++ U 
:: /27_dir/V_file.txt  SPI_NAND +++ Add [sz 0 add 87040] @KB/sec 813.73 {618.59}  ++ V 
:: /27_dir/W_file.txt  SPI_NAND +++ Add [sz 0 add 91136] @KB/sec 825.51 {621.44}  ++ W 
:: /27_dir/X_file.txt  SPI_NAND +++ Add [sz 0 add 95232] @KB/sec 834.71 {623.03}  ++ X 
:: /27_dir/Y_file.txt  SPI_NAND +++ Add [sz 0 add 99328] @KB/sec 844.84 {625.30}  ++ Y 
:: /27_dir/Z_file.txt  SPI_NAND +++ Add [sz 0 add 103424] @KB/sec 852.53 {626.46}  ++ Z 
:: /27_dir/A_file.txt  SPI_NAND +++ Add [sz 0 add 41984] @KB/sec 621.29 {368.68}  ++ A 
:: /28_dir/B_file.txt  SPI_NAND +++ Add [sz 5120 add 5120] @KB/sec 129.05 {104.88}  ++ B 
:: /28_dir/C_file.txt  SPI_NAND +++ Add [sz 9216 add 9216] @KB/sec 193.97 {160.33}  ++ C 
:: /29_dir/D_file.txt  SPI_NAND +++ Add [sz 13312 add 13312] @KB/sec 239.58 {205.74}  ++ D 
:: /29_dir/E_file.txt  SPI_NAND +++ Add [sz 17408 add 17408] @KB/sec 273.88 {236.74}  ++ E 
:: /30_dir/F_file.txt  SPI_NAND +++ Add [sz 21504 add 21504] @KB/sec 300.08 {266.14}  ++ F 
:: /30_dir/G_file.txt  SPI_NAND +++ Add [sz 25600 add 25600] @KB/sec 322.00 {286.11}  ++ G 
:: /31_dir/H_file.txt  SPI_NAND +++ Add [sz 29696 add 29696] @KB/sec 340.61 {212.14}  ++ H 
:: /31_dir/I_file.txt  SPI_NAND +++ Add [sz 33792 add 33792] @KB/sec 19.11 {18.57}  ++ I 
[706.05 M](1.94862 M elap) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 >
[706.27 M](2.16585 M elap) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 >
	 Loop Count: 325 (#fileCycle=141968), Bytes read 5413215232, written 5455413248, #Files=839
	dirV...18834982_us	

...

 32 dirs with 33 files of Size 16025600 Bytes
 Total 839 files of Size 80957440 Bytes
Bytes Used: 153747456, Bytes Total:268435456
 
@defragster
Cool that results are good - looks like its almost ready for primetime. SPI is really slow. 75Mhz was about the fastest I could get too without having issues. The size of the chip vs SPI speed problably has something to do with it as well.
 
If there is a plan/possibility to increase the QSPI/SPI clock speeds having it on the Defragster/LFSintegrity/tree/PlusNAND for testing would allow doing it in a uniform way.

Everything I've done so far is the 'default' speed as provided.

Short answer is especially for QSPI. At least for the W25Q128 and above. Not sure of the specs for the other Flash but I think 104Mhz for QSPI is a safe bet. For SPI 30Mhz seems good for FRAM which is a max of 40Mhz, but if I remember I had to run those lower as well. The NAND chips I am running at 75Mhz on SPI which seems to be a max I found during testing. But at least for the NAND's wanted to run it at the lower speed to make sure for the driver was working.

The clock is set for QSPI in startup.c from this:
Code:
	// turn on clock  (TODO: increase clock speed later, slow & cautious for first release)
	CCM_CBCMR = (CCM_CBCMR & ~(CCM_CBCMR_FLEXSPI2_PODF_MASK | CCM_CBCMR_FLEXSPI2_CLK_SEL_MASK))
		| CCM_CBCMR_FLEXSPI2_PODF(5) | CCM_CBCMR_FLEXSPI2_CLK_SEL(3); // 88 MHz
	CCM_CCGR7 |= CCM_CCGR7_FLEXSPI2(CCM_CCGR_ON);
so pretty close to the max.

In the SPIFFS_t4 code I was running in QUAD mode at 132Mhz:
Code:
	  /* Table of clock settings reference only:
		SEL: 0  DIV: 7 = 49.50000 MHz ok
		SEL: 0  DIV: 6 = 56.57143 MHz ok
		SEL: 0  DIV: 5 = 66.00000 MHz ok
		SEL: 0  DIV: 4 = 79.20000 MHz ok
		SEL: 0  DIV: 3 = 99.00000 MHz ok
		SEL: 0  DIV: 2 = 132.00000 MHz
		SEL: 0  DIV: 1 = 198.00000 MHz
		SEL: 0  DIV: 0 = 396.00000 MHz
		SEL: 1  DIV: 7 = 90.00000 MHz ok
		[COLOR="#FF0000"]SEL: 1  DIV: 6 = 102.85714 MHz ok[/COLOR]  potential first test setting or lower.
		SEL: 1  DIV: 5 = 120.00000 MHz
		SEL: 1  DIV: 4 = 144.00000 MHz
		SEL: 1  DIV: 3 = 180.00000 MHz
		SEL: 1  DIV: 2 = 240.00000 MHz
		SEL: 1  DIV: 1 = 360.00000 MHz
		SEL: 1  DIV: 0 = 720.00000 MHz
		SEL: 2  DIV: 7 = 83.07750 MHz ok
		SEL: 2  DIV: 6 = 94.94572 MHz ok
		SEL: 2  DIV: 5 = 110.77000 MHz ok
		[COLOR="#FF0000"]SEL: 2  DIV: 4 = 132.92400 MHz[/COLOR] SPIFFS for the W25Q128
		SEL: 2  DIV: 3 = 166.15500 MHz
		SEL: 2  DIV: 2 = 221.53999 MHz
		SEL: 2  DIV: 1 = 332.31000 MHz
		SEL: 2  DIV: 0 = 664.62000 MHz
		SEL: 3  DIV: 7 = 66.00000 MHz ok
		SEL: 3  DIV: 6 = 75.42857 MHz ok
[COLOR="#FF0000"]		SEL: 3  DIV: 5 = 88.00000 MHz ok[/COLOR] default
		SEL: 3  DIV: 4 = 105.60000 MHz ok
		SEL: 3  DIV: 3 = 132.00000 MHz
		SEL: 3  DIV: 2 = 176.00000 MHz
		SEL: 3  DIV: 1 = 264.00000 MHz
		SEL: 3  DIV: 0 = 528.00000 MHz
	  */
	  
	  //Reset clock to 132.9 Mhz
	  // turn on clock  (TODO: increase clock speed later, slow & cautious for first release)
	  CCM_CCGR7 |= CCM_CCGR7_FLEXSPI2(CCM_CCGR_OFF);
	  CCM_CBCMR = (CCM_CBCMR & ~(CCM_CBCMR_FLEXSPI2_PODF_MASK | CCM_CBCMR_FLEXSPI2_CLK_SEL_MASK))
		  | CCM_CBCMR_FLEXSPI2_PODF(4) | CCM_CBCMR_FLEXSPI2_CLK_SEL(2); 
	  CCM_CCGR7 |= CCM_CCGR7_FLEXSPI2(CCM_CCGR_ON);

The table is curtesy of @Frank B which he put together during Beta testing. So:
Code:
	  //Reset clock to 102.85714 Mhz
	  CCM_CCGR7 |= CCM_CCGR7_FLEXSPI2(CCM_CCGR_OFF);
	  CCM_CBCMR = (CCM_CBCMR & ~(CCM_CBCMR_FLEXSPI2_PODF_MASK | CCM_CBCMR_FLEXSPI2_CLK_SEL_MASK))
		  | CCM_CBCMR_FLEXSPI2_PODF(6) | CCM_CBCMR_FLEXSPI2_CLK_SEL(1); 
	  CCM_CCGR7 |= CCM_CCGR7_FLEXSPI2(CCM_CCGR_ON);

So if I do a BigFile test of the N01 at 103Mhz:
Code:
Big write /0_bigfile.txt took 25.90 Sec for 66955264 Bytes : file3.size()=66955264
	Big write KBytes per second 2584.84 

Bytes Used: 67239936, Bytes Total:134217728
at default:
Code:
Big write /0_bigfile.txt took 26.44 Sec for 66955264 Bytes : file3.size()=66955264
	Big write KBytes per second 2532.19 

Bytes Used: 67239936, Bytes Total:134217728
you only see a small difference in time about a half a second and a small performance boost in Kbytes/sec. Guess it relative.
 
That with bigFile() looks to be a fair test - Timed after it does space check. Just includes "apples to apples" OPEN/write in 2048 blocks/CLOSE - as long as the block formatting needed is the same for both ( an 'f'ormatUnused() before both )

So it doesn't show a big speed increase - unless it is held up on the static/hardcoded wait() values and not as completed when chips says done?

Still odd that QSPI isn't at least twice as fast as SPI? Given 4 bits per wait and faster clocks it should be 4+ times?

The QSPI 1Gb NANDs here are both unpinned - but similar T_4.1 pinned running the PJRC memory board #3 - will test them each with stock timing.
 
With Two T_4.1's and 1Gb NAND SPI then QSPI: Running NANDs at 'default/stock' build speed.
< updated LFSintegrity.INO on github with QSPI NAND sz fix, also test config as used is in that. >

Results: Both worked
> QSPI is 2.1 times FASTER on write
> QSPI is 1.48 times FASTER on read Verify before delete


Steps:
== Compiled for NAND SPI or QSPI - with "#define ROOTONLY"
> "F"ormat - full low level
> 'f'ormatUnused() - found nothing on either
> "B"igFile create of half media size with timing : both 66,955,264 bytes
> 'd'ir to confirm media type, and it shows the dir check "dirV" is 4X faster
> 'b'igfile DELETE with timing

{Note: had a BUG - both NAND's had SPI in string - updated the QSPI for that case : szDiskMem[] = "QSPI_NAND". }
Code:
Big write /0_bigfile.txt took [B][U]58.67 Sec[/U] for 66955264 Bytes : file3.size()=66955264
	Big write KBytes per second 1141.20 [/B]

Bytes Used: 67239936, Bytes Total:134217728

[  3.10 M](0.97982 M elap) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 > d
[B]printDirectory SPI_NAND[/B]
--------------
FILE	0_bigfile.txt		66955264

 0 dirs with 1 files of Size 66955264 Bytes
 Total 1 files of Size 66955264 Bytes
Bytes Used: 67239936, Bytes Total:134217728


	 Loop Count: 3 (#fileCycle=0), Bytes read 0, written 0, #Files=1
	[B][U]dirV...8218_us	[/U][/B]

Delete with read verify all #bigfile's
	Verify /0_bigfile.txt bytes 66955264 : ..................................................	GOOD! >>  bytes 66955264
	Big [B]read&compare KBytes per second 1637.96 [/B]

Code:
Big write /0_bigfile.txt took [B][U]27.87 Sec[/U] for 66955264 Bytes : file3.size()=66955264
	Big write KBytes per second 2402.73[/B] 

Bytes Used: 67239936, Bytes Total:134217728

[  3.79 M](0.46491 M elap) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 > d
[B]printDirectory QSPI_NAND[/B]
--------------
FILE	0_bigfile.txt		66955264

 0 dirs with 1 files of Size 66955264 Bytes
 Total 1 files of Size 66955264 Bytes
Bytes Used: 67239936, Bytes Total:134217728


	 Loop Count: 3 (#fileCycle=0), Bytes read 0, written 0, #Files=1
	[U][B]dirV...1997_us[/B][/U]

Delete with read verify all #bigfile's
	Verify /0_bigfile.txt bytes 66955264 : ..................................................	GOOD! >>  bytes 66955264
	[B]Big read&compare KBytes per second 2431.43[/B]

After above - both NAND's got 'f'ormatUnused() - had same # used dirty blocks:

SPI:: 15.46 seconds
Code:
...
FMT 1001,FMT 1002,FMT 1003,FMT 1004,FMT 1005,FMT 1006,FMT 1007,FMT 1008,	#496
FMT 1009,FMT 1010,FMT 1011,FMT 1012,FMT 1013,FMT 1014,FMT 1015,FMT 1016,	#504
FMT 1017,FMT 1018,FMT 1019,FMT 1020,FMT 1021,FMT 1022,FMT 1023,
	 formatUnused :: Done Formatting Low Level in 15460288 us.

QSPI:: 4.68 seconds
Code:
...
FMT 1001,FMT 1002,FMT 1003,FMT 1004,FMT 1005,FMT 1006,FMT 1007,FMT 1008,	#496
FMT 1009,FMT 1010,FMT 1011,FMT 1012,FMT 1013,FMT 1014,FMT 1015,FMT 1016,	#504
FMT 1017,FMT 1018,FMT 1019,FMT 1020,FMT 1021,FMT 1022,FMT 1023,
	 formatUnused :: Done Formatting Low Level in 4678134 us.

[ 26.55 M](0.07797 M elap) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 >

Then a 'h'undred SPI NAND iterations: in 8.53 minutes - then 'SSSSS' : create FIVE 2MB files
Code:
 ...
:: /P_file.txt  SPI_NAND +++ Add [sz 62464 add 62464] @KB/sec 482.79 {213.28}  ++ P   Verify /P_file.txt 124928B  @KB/sec 1279.31 
:: /Q_file.txt  SPI_NAND +++ Add [sz 66560 add 66560] @KB/sec 475.24 {215.32}  ++ Q   Verify /Q_file.txt 133120B  @KB/sec 1271.82 
:: /R_file.txt  SPI_NAND +++ Add [sz 70656 add 70656] @KB/sec 476.61 {218.50}  ++ R   Verify /R_file.txt 141312B  @KB/sec 1276.98 
:: /S_file.txt  SPI_NAND +++ Add [sz 74752 add 74752] @KB/sec 477.40 {221.90}  ++ S   Verify /S_file.txt 149504B  @KB/sec 1281.57 
[ 51.95 M](8.53462 M elap) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 >

...
Big write /0_2MBfile.txt took  1.39 Sec for 2048000 Bytes : file3.size()=2048000
	Big write KBytes per second 1477.54 

Big write /1_2MBfile.txt took  1.40 Sec for 2048000 Bytes : file3.size()=2048000
	Big write KBytes per second 1465.21 

Big write /2_2MBfile.txt took  1.41 Sec for 2048000 Bytes : file3.size()=2048000
	Big write KBytes per second 1451.06 

Big write /3_2MBfile.txt took  1.43 Sec for 2048000 Bytes : file3.size()=2048000
	Big write KBytes per second 1435.60 

Big write /4_2MBfile.txt took  1.45 Sec for 2048000 Bytes : file3.size()=2048000
	Big write KBytes per second 1415.86 

[B][U]Bytes Used: 14548992, Bytes Total:134217728[/U][/B]

Then a 'h'undred QSPI NAND iterations: in 3.27 minutes - then 'SSSSS' : create FIVE 2MB files
Code:
:: /P_file.txt  QSPI_NAND +++ Add [sz 62464 add 62464] @KB/sec 773.65 {519.91}  ++ P   Verify /P_file.txt 124928B  @KB/sec 2224.50 
:: /Q_file.txt  QSPI_NAND +++ Add [sz 66560 add 66560] @KB/sec 760.46 {518.91}  ++ Q   Verify /Q_file.txt 133120B  @KB/sec 2221.07 
:: /R_file.txt  QSPI_NAND +++ Add [sz 70656 add 70656] @KB/sec 758.75 {522.18}  ++ R   Verify /R_file.txt 141312B  @KB/sec 2225.25 
:: /S_file.txt  QSPI_NAND +++ Add [sz 74752 add 74752] @KB/sec 760.18 {527.31}  ++ S   Verify /S_file.txt 149504B  @KB/sec 2228.94 
[ 39.16 M](3.26819 M elap) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 >

...
Big write /0_2MBfile.txt took  0.77 Sec for 2048000 Bytes : file3.size()=2048000
	Big write KBytes per second 2670.05 

Big write /1_2MBfile.txt took  0.77 Sec for 2048000 Bytes : file3.size()=2048000
	Big write KBytes per second 2654.33 

Big write /2_2MBfile.txt took  0.77 Sec for 2048000 Bytes : file3.size()=2048000
	Big write KBytes per second 2651.22 

Big write /3_2MBfile.txt took  0.77 Sec for 2048000 Bytes : file3.size()=2048000
	Big write KBytes per second 2647.95 

Big write /4_2MBfile.txt took  0.78 Sec for 2048000 Bytes : file3.size()=2048000
	Big write KBytes per second 2618.19 

[B][U]Bytes Used: 14548992, Bytes Total:134217728[/U][/B]

After the above both disks show the same directory data.
SPI does dir walk counting in dirV...1,368,465_us
QSPI does dir walk counting in dirV...332,930_us

Code:
FILE	0_2MBfile.txt		2048000
FILE	1_2MBfile.txt		2048000
FILE	2_2MBfile.txt		2048000
FILE	3_2MBfile.txt		2048000
FILE	4_2MBfile.txt		2048000
FILE	A_file.txt		41984
FILE	B_file.txt		10240
FILE	C_file.txt		18432
FILE	D_file.txt		26624
FILE	E_file.txt		34816
FILE	F_file.txt		43008
FILE	G_file.txt		51200
FILE	H_file.txt		59392
FILE	I_file.txt		67584
FILE	J_file.txt		75776
FILE	K_file.txt		83968
FILE	L_file.txt		92160
FILE	M_file.txt		100352
FILE	N_file.txt		108544
FILE	O_file.txt		116736
FILE	P_file.txt		124928
FILE	Q_file.txt		133120
FILE	R_file.txt		141312
FILE	S_file.txt		149504
FILE	T_file.txt		78848
FILE	U_file.txt		82944
FILE	V_file.txt		87040
FILE	W_file.txt		91136
FILE	X_file.txt		95232
FILE	Y_file.txt		99328
FILE	Z_file.txt		103424

 0 dirs with 31 files of Size 12357632 Bytes
 Total 31 files of Size 12357632 Bytes
Bytes Used: 14548992, Bytes Total:134217728


	 Loop Count: 108 (#fileCycle=1292), Bytes read 219461632, written 49676288, #Files=31

SPI 'f'ormatUnused after the above:
Code:
...
FMT 1015,FMT 1016,FMT 1017,FMT 1018,FMT 1019,FMT 1020,FMT 1021,FMT 1022,	#912
FMT 1023,
	 formatUnused :: Done Formatting Low Level in [B]1,954,305 us.[/B]

QSPI 'f'ormatUnused after the above:
Code:
...
FMT 1015,FMT 1016,FMT 1017,FMT 1018,FMT 1019,FMT 1020,FMT 1021,FMT 1022,	#912
FMT 1023,
	 formatUnused :: Done Formatting Low Level in [B]1,519,534 us[/B].
 
Last edited:
Question:
Has LittleFS a function that returns the flash-address of a file? For example, to access random data without having to use the API. If I know the Address, the API is not needed and I hope that I can use a simple pointer.

2nd question: I hope it stores the files sequentially? (Continous addresses)


Sorry, I have not used LittleFS so far.
It would be useful for MP3 or Wavetables or any library code that just wants to read without having to use the api overhead.
 
Hi @Frank B - @mjs513 and @defragster and several others can give you a lot more detailed answers. But my guess is it may be a little fun to try to bypass the code to randomly read stuff...

You might take a look at the design file that is in the library: On my install it is at: C:\arduino-1.8.13\hardware\teensy\avr\libraries\LittleFS\src\littlefs\DESIGN.md
 
Hi @Frank B.
As far as I can tell the answer is no - there are no functions really to directly address the memory locations. LittleFS is file based so if you try writing directly to the chip you will probably mess up the file system. Now with that said for at least the NAND chips if you want to do that you can use the stand alone libraries we have for the W25N01/N02 and I think I still have laying around the one we did for the W25Q128. There are some gotchas with the larger NAND chips as well. EDIT = at least for QSPI, I have the SPI versions as well for the N01/N02 chips.

A good read, similar to the design.md file can be found at: https://bioreports.net/armmbed-littlefs/, if you are interested.
 
@KurtE - @defragster
Got something strange happening and I just can't seem to figure out what I am doing wrong. Probably something obvious but .... you know how that goes. First I soldered up a M02 so this is related to that chip. Here is the snippet of code that is giving me the problem:
Code:
	uint8_t cmd1[4], cmd_dieselect[2];

	const uint32_t address = block * config.block_size + offset;
	
	//Program Data Load
	writeEnable();   //sets the WEL in Status Reg to 1 (bit 2)
	uint16_t columnAddress = LINEAR_TO_COLUMN(address);
	uint32_t pageAddress = LINEAR_TO_PAGE(address);

	waitForReady();
	Serial.printf("Write -> targetPage: %d, pages/die: %d\n", pageAddress, pagesPerDie);
[COLOR="#0000CD"]	if(pageAddress > pagesPerDie) {
		//pageAddress -= pagesPerDie;
		cmd1[1] = 1;
		Serial.printf("CMD1: %d\n", cmd1[1]);
	} else {
		cmd1[1] = 0;
	}[/COLOR]

	
	if(deviceID == W25M02) {
		//setup new LUT to issue Select Die command before issuing a page load
[COLOR="#FF0000"]		cmd_dieselect[0] = 0xC2;  //Select Die command
		cmd_dieselect[1] = cmd1[1];[/COLOR]
		waitForReady();
		port->beginTransaction(SPICONFIG_NAND);
		digitalWrite(pin, LOW);
		port->transfer(cmd_dieselect, 2);
		digitalWrite(pin, HIGH);
		port->endTransaction();
		if(pageAddress > pagesPerDie)
			pageAddress -= pagesPerDie;		//W25M02 has 2 separate W25N01 dies addressed individually
		cmd1[1] = 0;						//dummy block for write is 0.
[COLOR="#FF0000"]		Serial.printf("Write M02 -> CMD: 0x%2X, Die: %d, targetPage: %d, pages/die: %d\n", cmd_dieselect[0], cmd_dieselect[1], pageAddress, pagesPerDie);
[/COLOR]
	}

The code in blue is working correctly. cmd[1] switches from 0 to 1 when the pageAddress > pagesPerDie. The problem occurs when I go to set up cmd_dieselect if it sees M02.

The printf is always returning 0 for both cmd_dieselect[0] and cmd_dieselect[1] when cmd_dieselect[0] s/b 0xC2 and cmd_dieselect[1] should be either 0 or 1. So what did I mess up?
 
I did get it working by doing the following but still would like to know what's wrong with the problem code:
Code:
		uint8_t die_select;

    cmd[0] = 0xD8;   //Block erase, 0xD8
	if(pageAddr > pagesPerDie) {
		cmd[1] = 1;
		die_select = 1;
	} else {
		cmd[1] = 0;
		die_select = 0;
	}
    cmd[2] = pageAddr >> 8;
    cmd[3] = pageAddr;
	
	if(deviceID == W25M02) {
		//setup new LUT to issue Select Die command before issuing a page load
		waitForReady();
		port->beginTransaction(SPICONFIG_NAND);
		digitalWrite(pin, LOW);
		port -> transfer(0xC2);   //die select
		port -> transfer(die_select);
		digitalWrite(pin, HIGH);
		port->endTransaction();
		if(pageAddr > pagesPerDie)
			pageAddr -= pagesPerDie;		//W25M02 has 2 separate W25N01 dies addressed individually
		cmd[1] = 0;						//dummy block for write is 0.

	}
 
Timing issue? That is in one case you are doing two calls to transfer which will wait until the first byte is fully sent and response received before sending the next one...

OR I really do hate that transfer syntax: port->transfer(cmd_dieselect, 2)
That is the array will be modified during this transfer to write the contents of the MISO pin into it... So if you expect it to stay those values...
I prefer the other syntax of: port->transfer(cmd_dieselect, nullptr, 2)
where you pass in TX buffer, RX Buffer and count and it does not overwrite.
 
Timing issue? That is in one case you are doing two calls to transfer which will wait until the first byte is fully sent and response received before sending the next one...

OR I really do hate that transfer syntax: port->transfer(cmd_dieselect, 2)
That is the array will be modified during this transfer to write the contents of the MISO pin into it... So if you expect it to stay those values...
I prefer the other syntax of: port->transfer(cmd_dieselect, nullptr, 2)
where you pass in TX buffer, RX Buffer and count and it does not overwrite.

Thanks @KurtE - that's probably it, never really understood that syntax. Thanks for the explanation. Anyway changed to go the other way just because I wanted to get it working - which I did.

Anyway, I just pushed an update to @defragster's library for the M02 chip (SPI and QSPI). Unfortunately I did have to lower the Clock to 55Mhz since the M02 didn't like it at 75Mhz. Maybe if I get ambitious I will play some more. But think I just gave you another distraction :)
 
... re: ...
...

So :: 0x00060401, // lutCustomSeqEnable,serialClkFreq,sflashPadType,deviceType
or :: 0x00080401, // lutCustomSeqEnable,serialClkFreq,sflashPadType,deviceType
...

From the linked post ::
0x00030401, // lutCustomSeqEnable,serialClkFreq,sflashPadType,dev iceType << 60 MHz
0x00080401, // lutCustomSeqEnable,serialClkFreq,sflashPadType,deviceType << 133 MHz

Will do a baseline at 60 MHz then repeat at 133 MHz on LittleFS _Program for 'reference' and see it there is a measurable change worth looking into

Note 1: mj3513 add for NAND >> 'class LittleFS_Program' has no member named 'deviceErase' myfs.deviceErase();

Steps:
== Compiled for _Program at 60 MHz then 133 MHz- with "#define ROOTONLY"
Not needed after UPLOAD :: > "F"ormat - full low level and > 'f'ormatUnused() - found nothing on either
> "B"igFile create of half media size with timing : both 3121152 {3119104} bytes
> 'd'ir to confirm media type, and it shows the dir check "dirV" is 4X faster
> 'b'igfile DELETE with timing
> 'f'ormatUnused for timing
> 'h'undred iterations for timing
> 'SSSSS' : create FIVE 2MB files for timing
> 'd'ir for timing
> 'f'ormatUnused for timing

Summary: Doesn't look like the LittleFS gains/changes much. For 100 iterations - or other ...:
Code:
>> 60 MHz   :: 2.76410 M elap
 - > Big write KBytes per second 530.24 
 - > Big read&compare KBytes per second 2727.69  < on delete
 - > format after B&b :: formatUnused :: Done Formatting Low Level in 824,155 us.
>> 133 MHz :: 2.75704 M elap
 - > Big write KBytes per second 530.14
 - > Big read&compare KBytes per second 2736.78  < on delete 
 - > format after B&b ::  formatUnused :: Done Formatting Low Level in 812,409 us.

for 60 MHz - only two "S" files fit:
Code:
Big write /0_bigfile.txt took  5.88 Sec for 3119104 Bytes : file3.size()=3119104
	Big write KBytes per second 530.24 

printDirectory PRO_DISK
--------------
FILE	0_bigfile.txt		3119104

 0 dirs with 1 files of Size 3119104 Bytes
 Total 1 files of Size 3119104 Bytes
Bytes Used: 3133440, Bytes Total:6291456

	dirV...49_us	[  5.03 M](0.00002 M elap) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 >

Delete with read verify all #bigfile's
	Verify /0_bigfile.txt bytes 3119104 : ..................................................	GOOD! >>  bytes 3119104
	Big read&compare KBytes per second 2727.69 

 myfs.formatUnused( 0 ) ...
 formatUnused() checkUsed: lfs Used Blocks Map: #used is 2 ( of 1536 ) : lfs traverse return 0 (neg on err)
FMT 2,FMT 3,FMT 4,FMT 5,FMT 6,FMT 7,FMT 8,FMT 9,	#8
...
FMT 1525,FMT 1526,FMT 1527,FMT 1528,FMT 1529,FMT 1530,FMT 1531,FMT 1532,	#760
FMT 1533,FMT 1534,FMT 1535,
	 formatUnused :: Done Formatting Low Level in 824155 us.

[  5.22 M](0.01374 M elap) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 >h
:: /B_file.txt  PRO_DISK +++ Add [sz 0 add 5120] @KB/sec 414.94 {410.32}  ++ B   Verify /B_file.txt 5120B  @KB/sec 2699.00 
:: /C_file.txt  PRO_DISK +++ Add [sz 0 add 9216] @KB/sec 435.79 {432.72}  ++ C   Verify /C_file.txt 9216B  @KB/sec 2775.90 

...
 PRO_DISK ----DEL---- -- V
:: /W_file.txt   Verify /W_file.txt 91136B  @KB/sec 2794.47 
 PRO_DISK ----DEL---- -- W
:: /X_file.txt   Verify /X_file.txt 95232B  @KB/sec 2807.80 
 PRO_DISK ----DEL---- -- X
:: /Y_file.txt   Verify /Y_file.txt 99328B  @KB/sec 2798.29 
 PRO_DISK ----DEL---- -- Y
:: /Z_file.txt   Verify /Z_file.txt 103424B  @KB/sec 2794.34 
 PRO_DISK ----DEL---- -- Z
:: /A_file.txt   Verify /A_file.txt 41984B  @KB/sec 2791.12 
 PRO_DISK ----DEL---- -- A
:: /B_file.txt  PRO_DISK +++ Add [sz 0 add 5120] @KB/sec 417.75 {409.40}  ++ B   Verify /B_file.txt 5120B  @KB/sec 2689.08 
:: /C_file.txt  PRO_DISK +++ Add [sz 0 add 9216] @KB/sec 436.96 {431.28}  ++ C   Verify /C_file.txt 9216B  @KB/sec 2686.88 

...
:: /R_file.txt  PRO_DISK +++ Add [sz 70656 add 70656] @KB/sec 454.90 {451.36}  ++ R   Verify /R_file.txt 141312B  @KB/sec 2776.92 
:: /S_file.txt  PRO_DISK +++ Add [sz 74752 add 74752] @KB/sec 460.56 {457.04}  ++ S   Verify /S_file.txt 149504B  @KB/sec 2783.96 
[  8.29 M]([B][U]2.76410 M elap[/U][/B]) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 >
Start Big write of 2048000 Bytes.........................
Big write /0_2MBfile.txt took  3.88 Sec for 2048000 Bytes : file3.size()=2048000
	Big write KBytes per second 528.12 

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

Bytes Used: 6291456, Bytes Total:6291456
Disk too full! DO :: q or FDisk too full! DO :: q or FDisk too full! DO :: q or F
[ 19.62 M](0.00004 M elap) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 > d
printDirectory PRO_DISK
--------------
FILE	0_2MBfile.txt		2048000
FILE	1_2MBfile.txt		2048000
FILE	A_file.txt		41984
FILE	B_file.txt		10240
FILE	C_file.txt		18432
FILE	D_file.txt		26624
FILE	E_file.txt		34816
FILE	F_file.txt		43008
FILE	G_file.txt		51200
FILE	H_file.txt		59392
FILE	I_file.txt		67584
FILE	J_file.txt		75776
FILE	K_file.txt		83968
FILE	L_file.txt		92160
FILE	M_file.txt		100352
FILE	N_file.txt		108544
FILE	O_file.txt		116736
FILE	P_file.txt		124928
FILE	Q_file.txt		133120
FILE	R_file.txt		141312
FILE	S_file.txt		149504
FILE	T_file.txt		78848
FILE	U_file.txt		82944
FILE	V_file.txt		87040
FILE	W_file.txt		91136
FILE	X_file.txt		95232
FILE	Y_file.txt		99328
FILE	Z_file.txt		103424

 0 dirs with 28 files of Size 6213632 Bytes
 Total 28 files of Size 6213632 Bytes
Bytes Used: 6291456, Bytes Total:6291456

	 Loop Count: 109 (#fileCycle=1292), Bytes read 155625472, written 49676288, #Files=28
	dirV...6177_us	[ 20.51 M](0.00025 M elap) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 >

 myfs.formatUnused( 0 ) ...
 formatUnused() checkUsed: lfs Used Blocks Map: #used is 1536 ( of 1536 ) : lfs traverse return 0 (neg on err)

	 formatUnused :: Done Formatting Low Level in 2679 us.

Repeat with 133MHz upload:
Code:
Big write /0_bigfile.txt took  5.88 Sec for 3119104 Bytes : file3.size()=3119104
	Big write KBytes per second 530.14 

printDirectory PRO_DISK
--------------
FILE	0_bigfile.txt		3119104

 0 dirs with 1 files of Size 3119104 Bytes
 Total 1 files of Size 3119104 Bytes
Bytes Used: 3133440, Bytes Total:6291456
[  0.44 M](0.09810 M elap) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 > d
printDirectory PRO_DISK
--------------
FILE	0_bigfile.txt		3119104

 0 dirs with 1 files of Size 3119104 Bytes
 Total 1 files of Size 3119104 Bytes
Bytes Used: 3133440, Bytes Total:6291456

	dirV...49_us	[  1.01 M](0.00002 M elap) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 >

Delete with read verify all #bigfile's
	Verify /0_bigfile.txt bytes 3119104 : ..................................................	GOOD! >>  bytes 3119104
	Big read&compare KBytes per second 2736.78 

 myfs.formatUnused( 0 ) ...

 formatUnused() checkUsed: lfs Used Blocks Map: #used is 2 ( of 1536 ) : lfs traverse return 0 (neg on err)
FMT 2,FMT 3,FMT 4,FMT 5,FMT 6,FMT 7,FMT 8,FMT 9,	#8
...
FMT 1525,FMT 1526,FMT 1527,FMT 1528,FMT 1529,FMT 1530,FMT 1531,FMT 1532,	#760
FMT 1533,FMT 1534,FMT 1535,
	 formatUnused :: Done Formatting Low Level in 812409 us.

[  1.20 M](0.01354 M elap) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 >h
:: /B_file.txt  PRO_DISK +++ Add [sz 0 add 5120] @KB/sec 449.91 {445.14}  ++ B   Verify /B_file.txt 5120B  @KB/sec 2743.84 
:: /C_file.txt  PRO_DISK +++ Add [sz 0 add 9216] @KB/sec 438.88 {435.79}  ++ C   Verify /C_file.txt 9216B  @KB/sec 2738.78 
:: /D_file.txt  PRO_DISK +++ Add [sz 0 add 13312] @KB/sec 448.23 {445.68}  ++ D   Verify /D_file.txt 13312B  @KB/sec 2776.80 
...
:: /Y_file.txt   Verify /Y_file.txt 99328B  @KB/sec 2801.29 
 PRO_DISK ----DEL---- -- Y
:: /Z_file.txt   Verify /Z_file.txt 103424B  @KB/sec 2798.95 
 PRO_DISK ----DEL---- -- Z
:: /A_file.txt   Verify /A_file.txt 41984B  @KB/sec 2795.39 
 PRO_DISK ----DEL---- -- A
:: /B_file.txt  PRO_DISK +++ Add [sz 0 add 5120] @KB/sec 487.76 {476.55}  ++ B   Verify /B_file.txt 5120B  @KB/sec 2511.03 
:: /C_file.txt  PRO_DISK +++ Add [sz 0 add 9216] @KB/sec 433.25 {427.66}  ++ C   Verify /C_file.txt 9216B  @KB/sec 2730.67 

...
:: /Q_file.txt  PRO_DISK +++ Add [sz 66560 add 66560] @KB/sec 450.29 {447.00}  ++ Q   Verify /Q_file.txt 133120B  @KB/sec 2787.15 
:: /R_file.txt  PRO_DISK +++ Add [sz 70656 add 70656] @KB/sec 460.99 {457.66}  ++ R   Verify /R_file.txt 141312B  @KB/sec 2786.06 
:: /S_file.txt  PRO_DISK +++ Add [sz 74752 add 74752] @KB/sec 459.66 {456.45}  ++ S   Verify /S_file.txt 149504B  @KB/sec 2785.25 
[  4.00 M]([B][U]2.75704 M elap[/U][/B]) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 >
Start Big write of 2048000 Bytes.........................
Big write /0_2MBfile.txt took  3.87 Sec for 2048000 Bytes : file3.size()=2048000
	Big write KBytes per second 529.42 

Bytes Used: 4239360, Bytes Total:6291456

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

Bytes Used: 6291456, Bytes Total:6291456
Disk too full! DO :: q or FDisk too full! DO :: q or FDisk too full! DO :: q or F
[  7.73 M](0.00004 M elap) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 > d
printDirectory PRO_DISK
--------------
FILE	0_2MBfile.txt		2048000
FILE	1_2MBfile.txt		2048000
FILE	A_file.txt		41984
FILE	B_file.txt		10240
FILE	C_file.txt		18432
FILE	D_file.txt		26624
FILE	E_file.txt		34816
FILE	F_file.txt		43008
FILE	G_file.txt		51200
FILE	H_file.txt		59392
FILE	I_file.txt		67584
FILE	J_file.txt		75776
FILE	K_file.txt		83968
FILE	L_file.txt		92160
FILE	M_file.txt		100352
FILE	N_file.txt		108544
FILE	O_file.txt		116736
FILE	P_file.txt		124928
FILE	Q_file.txt		133120
FILE	R_file.txt		141312
FILE	S_file.txt		149504
FILE	T_file.txt		78848
FILE	U_file.txt		82944
FILE	V_file.txt		87040
FILE	W_file.txt		91136
FILE	X_file.txt		95232
FILE	Y_file.txt		99328
FILE	Z_file.txt		103424

 0 dirs with 28 files of Size 6213632 Bytes
 Total 28 files of Size 6213632 Bytes
Bytes Used: 6291456, Bytes Total:6291456


	 Loop Count: 106 (#fileCycle=1292), Bytes read 155625472, written 49676288, #Files=28
	dirV...6177_us	[  8.49 M](0.00025 M elap) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 >

[  8.49 M](0.00025 M elap) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 >
 myfs.formatUnused( 0 ) ...


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

	 formatUnused :: Done Formatting Low Level in 2369 us.

[  8.52 M](0.00004 M elap) Awaiting input 0123456789RdchkFEqvplmusSBbyYxfan+-? loops left 0 >
 
Thank you - so Paul does it. Even better. Direct writes are not needed.

Yes, interesting to have it work? When LFS stores data it breaks it into Blocks - each has marker bits/bytes before the data that fits into that block. And the next block may or may not be contiguous depending on free space when created.

Seems like it might be easier to partition the Media to have LFS control it's area and then 'outsource' {if involved at all} SerialFlash to the other partition that is in fact the prior defined 'SerialFlash layout'

Perhaps LFS would get a directory entry 'File' that holds 'needed pointer info' to access the SerialFlash portion of interest? Maybe when the LFS media is created a root directory is created, and the LFS MEDIA is Downsized for the creation of the second partition. SerialFlash would own the 2nd partition then and LFS would not touch it. Any data added to the SerialFlash partition would get a 'file' created in "its" root folder that would give direct link as needed to the SerialFlash data location?
 
defragster said:
Note 1: mj3513 add for NAND >> 'class LittleFS_Program' has no member named 'deviceErase' myfs.deviceErase();
that's correct for NAND I created a device erase function based on the D8h command which is a block erase of 128k at a shot. As you noticed deviceErase is alot faster especially for the larger chips over lowlevel format. Not sure that command will survive into teensyduino.
It just loops through all the blocks available. As a matter of fact deviceErase calls eraseSector which is used directly by LFS to erase the 128k block that we specify in the chipInfo table. Paul actually does the same thing for QSPI and SPI flash. For LittleFS_Program Paul is calling
eepromemu_flash_erase_sector
from eeprom.c which does the equivalent command but for memory - I think, command but implemented slightly differently.

Sounds like NAND and FRAM stuff is about as far as I can go at this point.

EDIT: That is assuming I can figure ECC in conjunction with LFS.
 
@mjs513 - yes - all looks good for functionality!

I need to solder one of the LEGGED double size FeRam's to test - not sure if you got one and did that? 256KB instead of 128 KB? for $4'ish?
 
@mjs513 - yes - all looks good for functionality!

I need to solder one of the LEGGED double size FeRam's to test - not sure if you got one and did that? 256KB instead of 128 KB? for $4'ish?

These are the only FRAM chips that are currently supported:
Code:
	{{0x03, 0x2E, 0xC2}, 24, 64, 128, 1048576, 250, 1200},  //Cypress 8Mb FRAM
	{{0xC2, 0x24, 0x00}, 24, 64, 128, 131072, 250, 1200},  //Cypress 1Mb FRAM
	{{0xC2, 0x24, 0x01}, 24, 64, 128, 131072, 250, 1200},  //Cypress 1Mb FRAM, rev1
	{{0xAE, 0x83, 0x09}, 24, 64, 128, 131072, 250, 1200},  //ROHM MR45V100A 1 Mbit FeRAM Memory
	{{0xC2, 0x26, 0x08}, 24, 64, 128, 131072, 250, 1200},  //Cypress 4Mb FRAM
 
These are the only FRAM chips that are currently supported:
Code:
	{{0x03, 0x2E, 0xC2}, 24, 64, 128, 1048576, 250, 1200},  //Cypress 8Mb FRAM
	{{0xC2, 0x24, 0x00}, 24, 64, 128, 131072, 250, 1200},  //Cypress 1Mb FRAM
	{{0xC2, 0x24, 0x01}, 24, 64, 128, 131072, 250, 1200},  //Cypress 1Mb FRAM, rev1
	{{0xAE, 0x83, 0x09}, 24, 64, 128, 131072, 250, 1200},  //ROHM MR45V100A 1 Mbit FeRAM Memory
	{{0xC2, 0x26, 0x08}, 24, 64, 128, 131072, 250, 1200},  //Cypress 4Mb FRAM


So this one needs edited/added: {{0xAE, 0x83, 0x09}, 24, 64, 128, 262144, 250, 1200}, //ROHM MR45V200A 2 Mbit FeRAM Memory

Assuming it follows the same rules/commands as the 1Mb chip?

I don't see the JEDEC ID in the lapis-tech.com/.../feram/FEDR45V200A-01.pdf - that will show on first failure to use.
 
Back
Top