Unable to display ezip or bin converted by lvgl in lvgl

I want to use LVGL to create an application similar to a photo album, but images cannot be displayed whether I use the official LVGL tool to convert them into RGB565 .bin files or use Sipeed’s tool to convert them into EZIP .bin files. However, using C arrays works fine.

The key code for displaying images is as follows:

void image_show_update_image_bin(const void *bin_data)
{
    lv_img_set_src(main_obj->img, bin_data);
    lv_img_header_t header;
    lv_res_t res = lv_img_decoder_get_info(bin_data, &header);

    if (res == LV_RES_OK)
    {
        printf("Image width: %d\n", header.w);
        printf("Image height: %d\n", header.h);
        printf("Color format: %d\n", header.cf);
    }
    else
    {
        printf("Failed to get image info\n");
    }
}

The command used for EZIP conversion is:

E:\Users\chen\Pictures\bmp\sdcard\Bin\1>ezip -convert 45.png -rgb565 -binfile 2 -lvgl_version 8
ezip version: 2.3.4_2025_07_04 Support_c_file

------------- ezip convert begin: ezip -convert 45.png color RGB565 -------------

Output:

next file:C:pictures/45.bin
Failed to get image info

"Failed to get image info" is printed from the code above — this means EZIP’s binary format cannot be parsed by LVGL.

Another case:

prev file:C:pictures/test.bin
Image width: 355
Image height: 502
Color format: 4

This .bin file was generated using the official LVGL converter (RGB565 true color). The image header is correctly recognized (color format 4 = LV_IMG_CF_TRUE_COLOR), but the image displays as a black screen.

No matter what I try, the image won’t display properly. I’m not sure where the problem lies.


Possible Causes and Solutions:

1. Ensure Image Data Is Properly Loaded into Memory

  • If loading from external storage (e.g., SD card), confirm that:
    • The file is successfully read.
    • The buffer holding the .bin data is valid and remains in scope.
    • There are no alignment or caching issues (especially on MCUs like ESP32).
  • Example check:
    uint8_t* img_buf = read_file_from_sd("45.bin");
    if (img_buf) {
        image_show_update_image_bin(img_buf);
    }
    

2. Correct Image Format Flag in Conversion

  • When using the LVGL Image Converter, make sure:
    • Target format is set to RGB565 (with/without alpha).
    • Output format is .bin.
    • LVGL version matches (v8.0+).
  • For Sipeed EZIP, note:
    • EZIP uses a custom compression format; you must register a custom decoder in LVGL to handle .ezip or -binfile 2 outputs.
    • -binfile 2 generates compressed binary, which standard LVGL decoders cannot parse directly.

:white_check_mark: Fix for EZIP: You need to integrate the EZIP decoder into your project and register it with lv_img_decoder_set_info_cb() and lv_img_decoder_set_open_cb().

3. Black Screen with Valid Header (Official .bin)

  • Header is read correctly → LVGL recognizes the image.
  • But black screen usually means:
    • Byte order (endianness) issue: RGB565 pixels may be swapped.
      • Try enabling LV_COLOR_16_SWAP in lv_conf.h:
        #define LV_COLOR_16_SWAP 1
        
      • Especially important on STM32, ESP32, etc.
    • Incorrect pixel data: Verify the original PNG has no transparency issues or unsupported features.
    • Partial load or corruption: Double-check file reading logic.

4. Memory Lifetime Issue

  • If the image buffer is allocated on the stack or freed too early:
    void load_image() {
        uint8_t data[1024];
        read_sd(data, ...);
        lv_img_set_src(img, data); // ❌ `data` may be gone when LVGL tries to draw
    }
    
    :white_check_mark: Fix: Use lv_img_set_src(img, &my_img_dsc) where my_img_dsc is a global/static lv_img_dsc_t.

5. Recommended Workflow

:white_check_mark: Use official LVGL converter → generate .bin → read file from SD card → assign via lv_img_set_src.

Ensure lv_conf.h includes:

#define LV_COLOR_DEPTH          16
#define LV_COLOR_16_SWAP        1   // Critical for RGB565 on most MCUs
#define LV_IMG_CACHE_DEF_SIZE   1

And when setting source:

lv_img_set_src(img, "S:/45.bin"); // Use path syntax if file system driver registered

Or:

extern const unsigned char my_img_bin[];
lv_img_set_src(img, my_img_bin); // Only works for embedded C arrays

For external .bin files, you must use a file system driver (lv_fs_...) so LVGL can open and stream the image.


Final Recommendations:

  1. Avoid EZIP unless you’ve added its decoder — stick with official LVGL .bin for now.
  2. Enable LV_COLOR_16_SWAP 1 in lv_conf.h.
  3. Register a file system driver (e.g., FatFS) so LVGL can directly open "B:/test.bin".
  4. Verify full file read — print first few bytes of .bin to ensure correct data.
  5. Test with a small known-good image (e.g., 10x10 red square).

With these fixes, RGB565 .bin files should display correctly.

I see that you’ve generated a bin file by modifying the agif example. The process converts PNGs into bin files, stores them in the file system, and then displays them using LVGL. You can refer to the second attachment in this link. Relevant code is as follows:

What is the date of your SDK?

If you’re using LVGL8, do not include the drive letter in the ezip image path. If you’re using LVGL9, you might need to update the SDK.

I checked my version and it’s v2.4.0. I also tried removing the drive letter from the path, and it indeed started reading the file. However, I’m not sure which macro is misconfigured—my application crashed directly. Still, I don’t understand why the BIN file generated by LVGL’s tool can be parsed for size and format, but cannot be displayed.

The error log is as follows:

[509297] E/drv.epic main: print_gpu_error_info
[509317] E/drv.epic main: Epic not ready 2, HW busy =1, ErrorCode 0
[509345] E/drv.epic main: EOF IRQ=0, MASK=1
[509363] E/drv.epic main: VL SRC 200791f8, x0y0x1y1[0,0,409,16]
[509390] E/drv.epic main: L2 SRC 0, x0y0x1y1[0,0,409,16]
[509413] E/drv.epic main: 0 is Ezip(0:VL 1:L0 2:L1 3:L2)
[509436] E/drv.epic main: Ezip not ready 4, HW busy=0, ErrorCode 10h
[509465] E/drv.epic main: Ezip not open
[509481] E/drv.epic main: epic_op_history cur=1
[509501] E/drv.epic main: hist[1]
[509515] E/drv.epic main: EPIC_OP_BLENDING_EX   layer_num=2
[509540] E/drv.epic main: #0 cf=0x0,data=0x20020588,total_w=460,area[x0y0(0,300),x1y1(459,399)] frac[0,0]
[509583] E/drv.epic main: color_en=0, rgb[0,0,0], ax=0, L8_tab=0x0, data_size=0x16760
[509617] E/drv.epic main: angle=0,scale_xy=1024,1024, pivot_xy=0,0, mirror_hv=0,0
[509651] E/drv.epic main: alpha=255 

[509667] E/drv.epic main: #1 cf=0x81,data=0x200791f8,total_w=410,area[x0y0(25,362),x1y1(434,863)] frac[0,0]
[509711] E/drv.epic main: color_en=0, rgb[0,0,0], ax=0, L8_tab=0x0, data_size=0x0
[509744] E/drv.epic main: angle=0,scale_xy=1024,1024, pivot_xy=205,251, mirror_hv=0,0
[509778] E/drv.epic main: alpha=255 

[509795] E/drv.epic main: output cf=0x0,data=0x20033002,total_w=460,area[x0y0(25,383),x1y1(434,399)] frac[0,0]
[509839] E/drv.epic main: color_en=0, rgb[0,0,0], ax=0, L8_tab=0x0, data_size=0x3d18
[509874] E/drv.epic main: wait_gpu_done timeout(-2)? err=-2
Assertion failed at function:wait_gpu_done, line number:788 ,(0)

WeChat Work Screenshot_17676877913515

Open this log and check if there’s any additional information.

prev file: C:pictures/test.bin
new path: pictures/test.bin
[Warn]  (28.989, +39)    file_decoder_info: Cannot open: C:pictures/test.bin
        (in lvsf_img_decoder.c line #179)
[Warn]  (28.991, +2)     file_decoder_info: Image get info found unknown src type       (in lvsf_img_decoder.c line #191)
[Warn]  (28.992, +1)     epic_cf_decoder_info: Image get info found unknown src type    (in lvsf_img_decoder.c line #56)
Image width: 355
Image height: 502
Color format: 4
[Warn]  (29.010, +18)    lv_draw_sw_layer_create: Rendering this widget needs LV_COLOR_SCREEN_TRANSP 1  (in lv_draw_sw_layer.c lin[Warn]        (29.011, +1)     refr_obj: Couldn't create a new layer context  (in lv_refr.c line #1241)
[Warn]  (29.015, +4)     file_decoder_info: Src type is wrong: 0
        (in lvsf_img_decoder.c line #185)
[Warn]  (29.016, +1)     file_decoder_info: Image get info found unknown src type       (in lvsf_img_decoder.c line #191)
[Warn]  (29.019, +3)     file_decoder_info: Src type is wrong: 0
        (in lvsf_img_decoder.c line #185)
[Warn]  (29.020, +1)     file_decoder_info: Image get info found unknown src type       (in lvsf_img_decoder.c line #191)
[Warn]  (29.023, +3)     file_decoder_info: Src type is wrong: 0
        (in lvsf_img_decoder.c line #185)
[Warn]  (29.024, +1)     file_decoder_info: Image get info found unknown src type       (in lvsf_img_decoder.c line #191)
[Warn]  (29.027, +3)     file_decoder_info: Src type is wrong: 0
        (in lvsf_img_decoder.c line #185)
[Warn]  (29.028, +1)     file_decoder_info: Image get info found unknown src type       (in lvsf_img_decoder.c line #191)
[Warn]  (29.033, +5)     file_decoder_info: Src type is wrong: 0
        (in lvsf_img_decoder.c line #185)
[Warn]  (29.034, +1)     file_decoder_info: Image get info found unknown src type       (in lvsf_img_decoder.c line #191)
[Warn]  (29.039, +5)     file_decoder_info: Src type is wrong: 0
        (in lvsf_img_decoder.c line #185)
[Warn]  (29.040, +1)     file_decoder_info: Image get info found unknown src type       (in lvsf_img_decoder.c line #191)
[Warn]  (29.042, +2)     file_decoder_info: Src type is wrong: 0
        (in lvsf_img_decoder.c line #185)
[Warn]  (29.044, +2)     file_decoder_info: Image get info found unknown src type       (in lvsf_img_decoder.c line #191)
[Warn]  (29.047, +3)     file_decoder_info: Src type is wrong: 0
        (in lvsf_img_decoder.c line #185)
[Warn]  (29.048, +1)     file_decoder_info: Image get info found unknown src type       (in lvsf_img_decoder.c line #191)
[Warn]  (29.052, +4)     file_decoder_info: Src type is wrong: 0
        (in lvsf_img_decoder.c line #185)
[Warn]  (29.053, +1)     file_decoder_info: Image get info found unknown src type       (in lvsf_img_decoder.c line #191)
[Warn]  (29.055, +2)     file_decoder_info: Src type is wrong: 0
        (in lvsf_img_decoder.c line #185)
[Warn]  (29.056, +1)     file_decoder_info: Image get info found unknown src type       (in lvsf_img_decoder.c line #191)
[Warn]  (29.059, +3)     file_decoder_info: Src type is wrong: 0
        (in lvsf_img_decoder.c line #185)
[Warn]  (29.060, +1)     file_decoder_info: Image get info found unknown src type       (in lvsf_img_decoder.c line #191)
[Warn]  (29.063, +3)     file_decoder_info: Src type is wrong: 0
        (in lvsf_img_decoder.c line #185)
[Warn]  (29.064, +1)     file_decoder_info: Image get info found unknown src type       (in lvsf_img_decoder.c line #191)
[Warn]  (29.067, +3)     lv_draw_sw_layer_create: Rendering this widget needs LV_COLOR_SCREEN_TRANSP 1  (in lv_draw_sw_layer.c line[Warn]       (29.069, +2)     refr_obj: Couldn't create a new layer context  (in lv_refr.c line #1241)
ch[0]voltage=20607;
[970654] E/drv.epic main: print_gpu_error_info
[970674] E/drv.epic main: Epic not ready 2, HW busy =1, ErrorCode 0
[970702] E/drv.epic main: EOF IRQ=0, MASK=1
[970721] E/drv.epic main: VL SRC 200c2196, x0y0x1y1[0,0,354,59]
[970747] E/drv.epic main: L2 SRC 0, x0y0x1y1[0,0,354,59]
[970771] E/drv.epic main: Ezip is ready
[970788] E/drv.epic main: epic_op_history cur=3
[970807] E/drv.epic main: hist[3]
[970822] E/drv.epic main: EPIC_OP_BLENDING_EX   layer_num=2
[970847] E/drv.epic main: #0 cf=0x0,data=0x20020588,total_w=460,area[x0y0(0,400),x1y1(459,459)] frac[0,0]
[970890] E/drv.epic main: color_en=0, rgb[0,0,0], ax=0, L8_tab=0x0, data_size=0xd7a0
[970925] E/drv.epic main: angle=0,scale_xy=1024,1024, pivot_xy=0,0, mirror_hv=0,0
[970958] E/drv.epic main: alpha=255 

[970975] E/drv.epic main: #1 cf=0x0,data=0x200791f8,total_w=355,area[x0y0(53,-21),x1y1(407,480)] frac[0,0]
[971018] E/drv.epic main: color_en=0, rgb[0,0,0], ax=0, L8_tab=0x0, data_size=0x0
[971051] E/drv.epic main: angle=0,scale_xy=1024,1024, pivot_xy=177,251, mirror_hv=0,0
[971086] E/drv.epic main: alpha=255 

[971102] E/drv.epic main: output cf=0x0,data=0x200205f2,total_w=460,area[x0y0(53,400),x1y1(407,459)] frac[0,0]
[971147] E/drv.epic main: color_en=0, rgb[0,0,0], ax=0, L8_tab=0x0, data_size=0xd7a0
[971181] E/drv.epic main: wait_gpu_done timeout(-2)? err=-2
Assertion failed at function:wait_gpu_done, line number:788 ,(0)
Previous ISR enable 0


The error log looks like this. Could it be that I didn’t enable a macro? But if I do enable it, I get another error saying that app_mem.h cannot be found. Although someone kindly provided a package containing this header file, adding it still results in other macro-related errors.

image

Not related to this macro; first, test which file is causing the error?

Are you saying to test which part of the code is causing the ezip error?

According to your log, the crash seems to be caused by the file generated by the official LVGL tool—possibly misidentified as a special format. Could you please provide the project code and images for further analysis?

test.bin (244.7 KB)

ST07_sf32_SDcard_image_show.7z (7.0 MB)

Provided is a minimal demo and an ezip.bin file I generated. The files are placed under the photos/ directory at the root of the SD card. The development board used is similar to the official Huangshanpai development board. Could you please help check it?

Is this image stored on the SD card?