Increase read buffer to 512 bytes

PLATFORM: Espressif 32 (3.4.0) > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash

Dependency Graph
|-- lvgl 8.1.0
| |-- ESP32 BLE Arduino 1.0.1
|-- LovyanGFX 0.4.10
| |-- SPI 1.0
| |-- Wire 1.0.1
|-- SD(esp32) 1.0.5
| |-- FS 1.0
| |-- SPI 1.0
|-- SPI 1.0

In a FreeRTOS task, BMP images are read one after the other from the SD card and displayed on the current screen. The BMP images are 100 X 100 pixels with a bit depth of 16 and have a file size of approximately 20KB. It takes a long time (about 1.1 seconds) to read and display a single image. I wrote a test program which reads 40 * 512 bytes in 0.126 seconds via the SD library.

An image is initially read with 3 * 54 bytes and then read in in approximately 50 increments of 200 bytes each, then the file is closed and then reopened and then 2 * 54 and 50 * 200 bytes are read until the complete image is read.

Question: Is there a way to increase the 200 bytes to 512 bytes and if so, how.
Many thanks for the help.

There was a PR that meant to fix it but it was closed due to inactivity.

It seemed almost ready and i’d be great a to finish it. Are you interested in helping with it?

Yes, I would like to help. What do you expect from me?

Great! :slight_smile:

The PR I mentioned seems like a good starting point. Please create a new PR based on the existing one.

I had a few minor comments in the original PR that should be fixed.

And the result should be tested. :slight_smile:

The changes to the three files of the PR 2401 from PGNetHun are merged manually in my LVGL fork. Unfortunately the flag enable_cache is not set anywhere. This means that the new function lv_fs_read_cached is never called.
For test purposes I have set the flags f.drv-> enable_cache = true; and f.drv-> cache_size = 512; in the file lv_bmp.c in the function decoder_info so that the new function lv_fs_read_cached is called in the file misc / lv_fs.c. Then the system crashed in the new function lv_fs_read_cached with the instructionuint32_t file_position = file_p-> cache-> file_position;because the cache structure is probably not initialized correctly.
Question: where and how must the cache structure lv_fs_file_cache_t be correctly initialized based on lv_conf.h.

Thanks for looking into this!
Pleas send a PR with the current state. It’s much easier discuss it on GitHub.

I have created the PR 2979

1 Like