Skip to content

Read performance of QSPI Flash #447

Closed
@wdx04

Description

@wdx04

Hi,

I did a little benchmark of read performance of the QSPI Flash on some of my STM32 boards.
The QSPI frequency passed to QSPIFBlockDevice's constructor is 100MHz.
I thought I could get at least 20-30MB/s speeds, but I only got these results:

Board Flash Chip Read Speed
STM32F746I-DISCO N25Q128A 4.51MB/s
STM32F469I-DISCO N25Q128A 2.47MB/s
Custom STM32H723ZG W25Q64JV 0.51MB/s
Custom STM32U575VG W25Q32JV 0.48MB/s

I know DMA is not used in current STM32 QSPI/OSPI implementation, so I won't get the speeds close to the theoretical maximum.
But these results are still quite disappointing, especially with the W25Qxx flash chips.
I even doubt I bought these boards with inferior W25Qxx chips by accident.
Has anyone gotten similar results to me? How much speed up can we expect if DMA is used?

Here is my code for testing the read performance of a block device:

void do_perf(BlockDevice *block_device)
{
    constexpr off_t read_buffer_size = 32768;
    static char read_file_buffer[read_buffer_size];
    if(block_device == nullptr)
    {
        printf("invalid block device.\n");
        return;
    }
    off_t total_size = std::min(off_t(8 * 1024 * 1024), (off_t) block_device->size());
    if(total_size <= 0)
    {
        // very large SD cards
        total_size = 8 * 1024 * 1024;
    }
    off_t source_size = total_size;
    bd_addr_t offset = 0;
    Timer perf_timer;
    perf_timer.start();
    while(source_size > 0)
    {
        off_t batch_size = source_size > read_buffer_size ? read_buffer_size: source_size;
        block_device->read(read_file_buffer, offset, batch_size);
        source_size -= batch_size;
        offset += batch_size;
    }
    perf_timer.stop();
    long long elapsed_time_ms = chrono::duration_cast<chrono::milliseconds>(perf_timer.elapsed_time()).count();
    printf("finished read %ld bytes in %lld ms.\n", total_size, elapsed_time_ms);
    if(elapsed_time_ms == 0)
    {
        printf("read time too short, errors occured!\n", elapsed_time_ms);
    }
    else
    {
        float speed_mbps = float(total_size) / float(1024 * 1024) / float(elapsed_time_ms) * 1000.0f;
        printf("read speed: %.2fMB/s\n", speed_mbps);
    }
}

I also tested the read performance of SD cards, with DMA and a SDIO clock overclocked to 200MHz, on a custom STM32H563VI board. The read performance is 57.14MB/s with a 32KB buffer and 86.02MB/s with a 320K(max size without SDRAM) buffer.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions