eclipse-threadx / filex

Eclipse ThreadX - FileX is a high-performance, FAT-compatible file system that’s fully integrated with Eclipse ThreadX RTOS
https://github.com/eclipse-threadx/rtos-docs/blob/main/rtos-docs/filex/index.md
MIT License
27 stars 22 forks source link

Write Performance on NAND Flash is very low when using Fault Tolerant Mode #53

Open sonmara opened 6 months ago

sonmara commented 6 months ago

I'm using a NAND-Flash (W25N01GV) in combination with a STM32H7B3 controller. After enabling the FaultTolerantMode and writing data to to the flash, the write performance gets very low. The W25N01GV has the following coarse specs: • FlashSize 125MByte • 2kB Page Size • 1024 Blocks with 64 pages • using quadSPI On my controller I'm using threadX, fileX and levelX with the version 6.4.0. and the TX_TIMER_TICKS_PER_SECOND are set to 1000. To compare different settings I did a write of 8MByte of data to the flash. The write is done by chunks of 512Byte.

for(int i= 0; i< 8192*2; ++i)
{
    fx_file_write(&_file, buffer, 512);
}

The settings of the fx_media_format was the following:

fx_media_format(&_media,
                          nandDriver,                         // Driver entry
                          nullptr,                                // Device info pointer
                          (UCHAR*)sectorBuffer,       // Media buffer pointer
                          2048,                                  // Media buffer size
                          "C",                                     // Volume Name
                          1,                                        // Number of FATs
                          32,                                      // Directory Entries
                          0,                                        // Hidden sectors
                          (1024 - 1) * 64,                   // Total sectors
                         2048,                                   // Sector size
                          1,                                        // Sectors per cluster
                          1,                                        // Heads
                          1);                                       // Sectors per track

First Setp

Measuring write Speed without FaultTolerantMode enabled: Without calling fx_fault_tolerant_enable the write speed is about 500kByte/sec.

Second Step

Measuring write Speed with FaultTolerantMode enabled: Compared to the first step, I only enabled the fault tolerant mode in the fx_user.h and called fx_fault_tolerant_enable():

fx_fault_tolerant_enable(&_media
                          (VOID*)faultTolerantBuffer,          // faultTolerantBuffer 
                           4096);                                           // faultTolerantBuffer size

At the beginning of the 8MByte write process the write speed is 13kByte/sec. But after short time, the write speed breaks down to 2kByte/sec. I also played a bit with the possible defines in the fx_user.h and lx_user.h (e.g. LX_NOR_SECTOR_MAPPING_CACHE_SIZE) but nothing had an impact on the write speed.

Questions

rahmanih commented 5 months ago

Hi @sonmara

Could you try to call thelx_nand_flash_extended_cache_enable() API after openeing the NAND flash instance.

regards Haithem.

sonmara commented 4 months ago

Hi @rahmanih,

in the levelx version in use this function is deprecated and looks like the following:

UINT  _lx_nand_flash_extended_cache_enable(LX_NAND_FLASH  *nand_flash, VOID *memory, ULONG size)
{

    LX_PARAMETER_NOT_USED(nand_flash);
    LX_PARAMETER_NOT_USED(memory);
    LX_PARAMETER_NOT_USED(size);

    /* Return not supported.  */
    return(LX_NOT_SUPPORTED);
}

I don't think its worth trying to call that one, sorry.