jkent / frogfs

Fast Read-Only General-purpose File System (ESP-IDF and ESP8266_RTOS_SDK compatible)
https://frogfs.readthedocs.io
Mozilla Public License 2.0
25 stars 32 forks source link

Add support for memory mapped files #30

Closed X-Ryl669 closed 2 years ago

X-Ryl669 commented 2 years ago

Right now, there's only a small function addition to support memory mapped files and this PR adds this. Usually, when reading a file from ESPFS, one will need to allocate a buffer in the heap to read a file into. For small files, it's ok, but for decent files, it can be painful on such limited memory device.

With this patch, you'll write the ESPFS to a SPI Flash's partition and let esp-idf memory map the partition. Then the patch adds a mmap_file function so you can get a read-only view of the file, without allocating in the heap.

Typically, this is useful for GUI stuff where you can store bitmap images in ESPFS, Lottie's JSON files and so on.

Fix #29 and #28

X-Ryl669 commented 2 years ago

Ok, done.

Please notice that espfs.yaml.example in the repository is using a root node paths while I think it should be filters. However, if you try to set keys (like *.txt) that aren't declared in espfs_default.yaml), it fails at run-time.

This is something that need fixing, but it's not part of this PR.

jkent commented 2 years ago

I've re-worked the entire image build system by splitting out preprocessing and image binary creation into two separate scripts with a rewrite. It is much easier understand. I still need to do some testing and a little more CMake cleanup.

X-Ryl669 commented 2 years ago

This PR is now useless, thanks for your changes. Closing!