Description
I try to show image from SD , but failed to allocate dynamic memmory. it neeeds to allocate dynamic memmory to store the image(the size of the image is 9 k),no matter how much I increase the memory, it always prompts " lv_fs_read_cached: Asserted at expression: file_p->cache->buffer != NULL (Out of memory) lv_fs.c:228"
What MCU/Processor/Board and compiler are you using?
ESP32 s3
What LVGL version are you using?
9.1
What do you want to achieve?
Show image from SD card
What have you tried so far?
I’ve tried to increase the memory in the lv_conf.h or change a smaller image ,but it doesn’t work
Code to reproduce
here is my lv_conf.h
#if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN
/*Size of the memory available for `lv_malloc()` in bytes (>= 2kB)*/
//#define LV_MEM_SIZE (16 * 1024U) /*[bytes]*/
#define LV_MEM_SIZE (32 * 1024U) /*[bytes]*/
//#define LV_MEM_SIZE (64 * 1024U) /*[bytes]*/
//#define LV_MEM_SIZE (128 * 1024U) /*[bytes]*/
/*Size of the memory expand for `lv_malloc()` in bytes*/
#define LV_MEM_POOL_EXPAND_SIZE 0
/*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
#endif
#endif /*LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN*/
/*API for FATFS (needs to be added separately). Uses f_open, f_read, etc*/
#define LV_USE_FS_FATFS 1
#if LV_USE_FS_FATFS
#define LV_FS_FATFS_LETTER 'S' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
//#define LV_FS_FATFS_CACHE_SIZE 1024*12 /*>0 to cache this number of bytes in lv_fs_read()*/
//#define LV_FS_FATFS_CACHE_SIZE 1024*24 /*>0 to cache this number of bytes in lv_fs_read()*/
#define LV_FS_FATFS_CACHE_SIZE 1024*48 /*>0 to cache this number of bytes in lv_fs_read()*/
#endif
here is my test code
void setup()
{
Serial.begin(115200);
SPIClass spi = SPIClass(HSPI);
spi.begin(40 /* SCK */, 39 /* MISO */, 41 /* MOSI */, 42 /* SS */);
if (!SD.begin(42 /* SS */, spi, 80000000)) {
Serial.println("Card Mount Failed");
return;
}
else Serial.println("Card Mount Success");
pinMode(5, OUTPUT);
//wifi_int();
GT911_init();
lvgl_init();
// lv_fs_file_t f;
// lv_fs_res_t res;
// res = lv_fs_open(&f, "S:hello.txt", LV_FS_MODE_RD);
// if (res != LV_FS_RES_OK) {
// Serial.println("Open fail");
// }
// else {
// Serial.println("Open OK");
// uint32_t read_num;
// uint8_t buf[6];
// res = lv_fs_read(&f, buf, 6, &read_num);
// Serial.printf("read:%s", buf);
// lv_fs_close(&f);
// }
lv_obj_t *img_bg = lv_img_create(lv_scr_act());
lv_img_set_src(img_bg, "S:/3.png");
lv_obj_center(img_bg);
//main_desk();
}
the EEROR
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0xb (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x44c
load:0x403c9700,len:0xbd8
load:0x403cc700,len:0x2a80
entry 0x403c98d0
Card Mount Success
[Error] (0.882, +882) lv_fs_read_cached: Asserted at expression: file_p->cache->buffer != NULL (Out of memory) lv_fs.c:228
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.