https://github.com/copych/sdmmc_esp32_read_only
Simplified Read Only FAT32 implementation for SD MMC on ESP32 and ESP32S3
https://github.com/copych/sdmmc_esp32_read_only
Last synced: about 2 months ago
JSON representation
Simplified Read Only FAT32 implementation for SD MMC on ESP32 and ESP32S3
- Host: GitHub
- URL: https://github.com/copych/sdmmc_esp32_read_only
- Owner: copych
- Created: 2024-02-14T10:45:41.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-09T09:36:29.000Z (about 1 year ago)
- Last Synced: 2025-01-14T12:29:18.266Z (4 months ago)
- Language: C++
- Size: 53.7 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Simplified READ-ONLY FAT32 class for fast accessing and reading of (in my case WAV) files.
Cluster chains are to be pre-cached (on the application side) for directory files, and stored in memory as a collection of linear sector chain boundaries. Ideally, when no fragmentation appears, only a single pair of sectors (beginning/end) per file needed.calls are like this:
```
SDMMC_FAT32 Card;
SDMMC_FileReader Reader(&Card);entry_t* entry;
Card.begin();
Card.testReadSpeed(READ_BUF_SECTORS /*sectors per read*/, 8 /*total MBytes to test*/);
// List root folder
Card.setCurrentDir("/");
Card.printCurrentDir();entry = Card.nextEntry();
while (!entry->is_end) {
if (entry->is_dir) {
Card.setCurrentDir(entry->name);
Card.printCurrentDir();
break;
}
entry = Card.nextEntry();
}str_max_t str="";
Reader.open("config.ini");
while (Reader.available()) {
Reader.read_line(str);
DEBUG(str.c_str());
}
Reader.close();Card.end();
```It is neither a product nor a code of beauty, but some stuff one can find useful for particular needs. For example, this may help with reading files from the SD with a reasonable good speed and constant low access time.
For example, standard Arduino ESP32 core lib gives ~5 ms lag before opening first file in the given directory, and ~20 ms lag for the 200th file, because of scanning directory entries.
This class allows addressing files directly by sectors, and reading of sector-aligned blocks.This is what I have measured for an old random 16GB Card that I had.
|sectors per read | reading speed, MB/s |
|------------------|----------------------|
| 1 | 0.90 |
| 2 | 1.57 |
| 4 | 2.82 |
| 8 | 5.00 |
| 16 | 7.79 |
| 32 | 11.12 |
| 64 | 13.85 |
| 128 | 15.75 |