Lv_img_set_src(img1, "S:/LOGO.png") hangs


I have an Arduino program based on LVGLDemo. When the program enters the lv_img_set_src it hangs. I know that it is this function that creates a problem because a print statement prior to this function is being executed. The error log shows this

18:01:06.152 -> [Trace]	(7.266, +1)	 lv_mem_alloc: allocating 56 bytes 	(in lv_mem.c line #127)
18:01:06.152 -> 
18:01:06.152 -> [Trace]	(7.266, +0)	 lv_mem_alloc: allocated at 0x24003a18 	(in lv_mem.c line #160)
18:01:06.152 -> 

I think it has something to do with this call in lv_mem.c

#if LV_MEM_CUSTOM == 0
    void * new_p = lv_tlsf_realloc(tlsf, data_p, new_size);
    void * new_p = LV_MEM_CUSTOM_REALLOC(data_p, new_size);
    if(new_p == NULL) {
        LV_LOG_ERROR("couldn't allocate memory");
        return NULL;

    MEM_TRACE("allocated at %p", new_p);
    return new_p;

My memory settings in lv_conf.h are as follows

/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/
#define LV_MEM_CUSTOM 0
#if LV_MEM_CUSTOM == 0
    /*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
    //#define LV_MEM_SIZE (48U * 1024U)          /*[bytes]*/  //origineel
    #define LV_MEM_SIZE (128U * 1024U)          /*[bytes]*/
    /*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/
    #define LV_MEM_ADR 0     /*0: unused*/
    /*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/
    #if LV_MEM_ADR == 0
        #undef LV_MEM_POOL_INCLUDE
        #undef LV_MEM_POOL_ALLOC

#else       /*LV_MEM_CUSTOM*/
    #define LV_MEM_CUSTOM_INCLUDE <stdlib.h>   /*Header for the dynamic memory function*/
    #define LV_MEM_CUSTOM_ALLOC   malloc
    #define LV_MEM_CUSTOM_FREE    free
    #define LV_MEM_CUSTOM_REALLOC realloc
#endif     /*LV_MEM_CUSTOM*/

I also tried with #define LV_MEM_CUSTOM 1 but to no avail.

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

Arduino G1 using Arduino IDE editor

What LVGL version are you using?


What do you want to achieve?

I want to understand why lv_img_set_src is hanging.

What have you tried so far?

Tried different memory settings in lv_conf.h

Code to reproduce

This is where it goes wrong

  Serial.println("Preparing image");

  lv_obj_t * img1 = lv_img_create(obj);
  //lv_png_init(); niet herkend door de compiler
  lv_obj_set_size(img1, 32, 32);
    lv_obj_set_pos(img1, 130, 70);

  for (int i=0;i<20;i++) {Serial.println();}

  //lv_img_set_src(img1, &img_arduinologo); //This one displays perfectly on the screen
  lv_img_set_src(img1, "S:/LOGO.png"); // tried different calls S:LOGO.PNG S:/LOGO.PNG  etc

 Serial.println("Done Preparing image");

Code hangs at lv_img_set_src.
Suggestions are welcome.

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.