2
votes

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);
    }
}
1
Hmm. Can you describe the hardware environment at all? What kind of NOR flash are you using?Steve Friedl
Have you tried to write the same amount of data to your SPI Flash directly without to see how long it ftakes ?Clonk
@Clonk, Yes I tried, it was success, I filled the buffer for 2KB and wrote using LFS filesystem, tat too was success, but given above code, it takes me too much time.Indu
@SteveFriedl Control STM32H753BIT6 NOR: winbond.com/resource-files/…Indu

1 Answers

0
votes

I have added some delays in my SPI driver. The issue is solved. Before receiving the response from the nor chip, tried to send the next command made such issues.