-
Notifications
You must be signed in to change notification settings - Fork 808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Writing 64 Bytes is taking 2.5 seconds @ 40 MHz #1019
Comments
For what it's worth, here are my helper functions for the configurations as well.
|
LittleFS uses a copy-on-write mechanism to ensure that the file system remains consistent even in the event of a power failure. This means that instead of directly overwriting data, it writes new data to a new location and then updates pointers to the new data. This extra step can introduce some latency. |
Xiao, thanks for your response. That makes sense that it would add some time to copy-on-write. |
Changed the structure of my file system so I would create a new 64 byte file instead of write to the 32kB file, now the full create/write/close cycle is only ~100ms. I'm finding each successive file created adds ~5-10 ms each time which I am trying to now minimize. |
Hi @cnitroy, it looks like you're using a 64KiB block size, but the MX25R can actually erase in 4KiB blocks with the sector-erase command. Large block sizes are one of the main sources of performance issues for littlefs right now, so this may help things. There is also I realize it's confusing with littlefs calling these blocks and MX25R calling these sectors, but other storage technology sometimes calls these blocks so you can't really win naming-wise... |
Hi @geky, thanks so much for taking the time to comment on this thread. |
Hmm, my first thought would be the wrong erase command, but you mentioned switching to sector erases. Is it possible the address is getting the lower bits masked out somewhere? Unfortunately the low-level SPI drivers/libraries vary quite a lot so it's hard to know more. It may be easier to debug outside of littlefs, by manually writing/reading back blocks on the flash and checking that nothing clobbers block 0. |
for your read, write, erase function, you can try use these configuration for lfs: struct lfs_config cfg = {
// Block device operations
.read = File_System_Flash_Read,
.prog = File_System_Flash_Prog,
.erase = File_System_Flash_Erase,
.sync = File_System_Flash_Sync,
// Block device configuration
.read_size = sizeof(FS_read_buffer), // Min. size of block read
.prog_size = sizeof(FS_prog_buffer), // Min. size of block program
.block_size = 4096, // Size of erasable block in bytes
.block_count = 64 * 1024 * 128 / 4096, // 128 blocks based on 64kB sized blocks
.cache_size = sizeof(FS_read_buffer), // Size of block caches in bytes (must = read/prog buffer size)
.lookahead_size = 64 * 1024 * 128 / 4096 / 8, // Size of the lookahead buffer in bytes
.block_cycles = 0x200, // Number of erase cycles before moving to another block
.prog_buffer = FS_prog_buffer,
.read_buffer = FS_read_buffer,
.lookahead_buffer = FS_lookahead_buffer, // lookahead buffrer size must be 64 * 1024 * 128 / 4096 / 8 Byte.
}; |
Hello all,
I am using LittleFS with an chip running at 40MHz and interfacing an 8MByte QSPI Flash chip.
I am able to perform all the file functions needed of creating, editing, deleting, etc, but my main concern is the speed of operation. I am writing 64 bytes of data to SPI flash, and it takes 2.5 seconds, and this is after ramping up the clock speed to 40MHz from 16MHz. At 16MHz, it was even closer to 5-6 seconds.
Reading posts online and in this repo, I see speed is a common performance issue, but can someone tell me if the times I am seeing are common or is there possibly a configuration issue here? I've put my configuration below.
Sidenote: My File_System_Flash_Sync function currently only returns 0, I don't have a cache flush yet.
Thank you!
The text was updated successfully, but these errors were encountered: