How to increase speed of load large image .bin file

Descriptions

I’m use .bin files to save images, when i load large image it too slow

What MCU/Processor/Board and compiler are you using?

ESP32-S3

What LVGL version are you using?

V8.3

What do you want to achieve?

I wanna load lager image .bin file quickly

What have you tried so far?

increase drv->cache_size it not work still slow

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

static void * fs_open(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode)
{
    lv_fs_res_t res = LV_FS_RES_NOT_IMP;

    void * f = NULL;

    if(mode == LV_FS_MODE_WR) {
        /*Open a file for write*/
        f = "wb";         /*Add your code here*/
    }
    else if(mode == LV_FS_MODE_RD) {
        /*Open a file for read*/
        f = "rb";         /*Add your code here*/
    }
    else if(mode == (LV_FS_MODE_WR | LV_FS_MODE_RD)) {
        /*Open a file for read and write*/
        f = "rb+";         /*Add your code here*/
    }

    char filepath[256]={0};
    sprintf(filepath, LV_FS_PATH "%s", path);
    ESP_LOGI(TAG, "filepath: %s", filepath);
    FILE* pf = fopen(filepath, f);

    uint16_t size;
    fseek(pf, 0, SEEK_END);
    size = ftell(pf);
    drv->cache_size = size;
    rewind(pf);
    ESP_LOGI(TAG, "file total size: %d", size);
    if (pf == NULL)
    {
        ESP_LOGE(TAG, "open file failed ");
    }
    return pf;//fopen(filepath, f);
}

static lv_fs_res_t fs_read(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br)
{
    lv_fs_res_t res = LV_FS_RES_NOT_IMP;

    /*Add your code here*/
    ESP_LOGE(TAG, "real read file size: %ld ", btr);
    *br = fread(buf, 1, btr, file_p);

    return (int32_t)(*br) < 0 ? LV_FS_RES_UNKNOWN : LV_FS_RES_OK;
}

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.
飞书20240912-113218

image

anybody could help please? I have the same issue

Maybe go back to basic school and calculate real max of system AxBxC/D…
Only one way exist preload in some memory with higher B… But preload time still slow down system

There could be other issues at play, but I’d say the speed of loading and drawing a BIN image is mostly dependent on your flush buffer driver speed when writing to the screen, and your SD card read speed (both the drive speed and the card speed).

You need to consider optimizing those two items for speed independently of this, look for information about increasing performance of the LVGL flush buffer, your devices SD Card, and whatever driver you are using to write to the screen.

Try measuring, via a simple program of your own, how long it takes to read the full file from your SD card. Try another experiment of measuring how long your screen driver takes to send a full screen update to the screen. Those two timings will mostly define the timing of loading and displaying a BIN image via LVGL.

I load an 800 * 480 * 16 bit LVGL generated BIN image, loaded using LVGL file system callbacks in 1600 byte chunks, and it is virtually instantaneous, even only using a partial screen buffer, because I have both a fast device (Teensy 4.1) and have optimized my screen flush code and driver and SD card settings - the LVGL overhead in this process is minimal, the speed comes mostly from my flush buffer driver and the SD card speed.

If your timing experiments above on the SD card read speed and full-screen update speed are a lot faster than what you are seeing the BIN image displayed via LVGL, then you can target assessing issues within LVGL.

Thank you so much for your reply that was helpful :slightly_smiling_face: