I configured the LFS filesystem with SPI clock speed 100 Mhz, when trying to write continuously a structure value of 64bytes, after 8 to 9 structure data, my NOR flash device is returning me busy and write enable. SPI data transmission is continuously done without end.
Hence, I changed the design for each write, file open and close, in this case, at some lines, my file close is taking me too much of time. To write my entire data (2560 byte) it takes me 27 Sec, which is not acceptable.
// LFS Configuration
cfg.read_size = 256;
cfg.prog_size = 256;
cfg.block_size = 4096;
cfg.block_count = 4095;
cfg.lookahead_size = 256;
cfg.cache_size = 512;
void fileWriteSM(const char* filename) {
volatile uint32_t pos;
for(int i=0; i<TOTAL_LINE ;i++){
pos = lfs_file_write(&lfs, &fileInit, &syringeLib[i],
sizeof(syringeLib[i]));
}
}
void Logging_Task::run() // Function Definition
{
res = lfs_file_opencfg(&lfs, &fileInit, filenameInit, LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND, &bufconfInit);
fileWriteSM("filenameInit");
lfs_file_close(&lfs, &fileInit);
while(1);
}
// Changed Design, it takes 27 Sec
void fileWriteSM() {
volatile uint32_t pos;
for(int i=0; i<TOTAL_LINE ;i++){
pos = lfs_file_opencfg(&lfs, &fileInit, filenameInit,
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND, &bufconfInit);
pos = lfs_file_write(&lfs, &fileInit, &syringeLib[i],
sizeof(syringeLib[i]));
lfs_file_close(&lfs, &fileInit);
}
}