Page 1 of 2
SD card memory use
Posted: Wed Jun 06, 2018 4:40 am
by themindfactory
Is it possible to cut the 27K required for the SD card to function to a more reasonable level when all you need is one file open!
I wrote a FAT32 driver years back that handled many files and used under 2K, a couple 512 byte buffers and some overhead....
Thanks!
RichardS
Re: SD card memory use
Posted: Wed Jun 06, 2018 6:06 am
by ESP_igrr
By default, sd_card example in IDF uses 27K as you have mentioned.
First of all, if you only need 1 file and not 5 files open at the same time, you can modify ".max_files = 5" to ".max_files = 1" in the example source code.
Next, if you are not using wear_levelling library in your application, you can go into menuconfig > Component config > Wear levelling and change sector size from 4096 bytes to 512 bytes. Then FATFS will only support 512-byte sectors, which will reduce size of scratch buffers in FATFS library.
With these two changes the example will use around 3K or heap.
Re: SD card memory use
Posted: Wed Jun 06, 2018 12:06 pm
by themindfactory
ESP_igrr wrote:By default, sd_card example in IDF uses 27K as you have mentioned.
First of all, if you only need 1 file and not 5 files open at the same time, you can modify ".max_files = 5" to ".max_files = 1" in the example source code.
Next, if you are not using wear_levelling library in your application, you can go into menuconfig > Component config > Wear levelling and change sector size from 4096 bytes to 512 bytes. Then FATFS will only support 512-byte sectors, which will reduce size of scratch buffers in FATFS library.
With these two changes the example will use around 3K or heap.
I think this does not work if its Arduino IDE related, I find no reference in any files to change.... I will keep looking, let me know if this does work with Arduino IDE.
RichardS
Re: SD card memory use
Posted: Wed Jun 06, 2018 12:18 pm
by ESP_igrr
Sorry, i didn't notice that this was posted on Arduino forum. Number of files seems to be hardcoded in Arduino:
https://github.com/espressif/arduino-es ... MC.cpp#L56. Suggest opening an issue in arduino-esp32 repository, requesting to make the number of files parameter configurable.
Re: SD card memory use
Posted: Wed Jun 06, 2018 1:49 pm
by themindfactory
And that seems to only be in the SD_MMC lib, I am using SD lib and accessing over SPI....
I have a large project and am out of memory, hence the issue....
Whats the status of WROVER and the extra PSRAM?? Has that been worked into Arduino IDE?
RichardS
Re: SD card memory use
Posted: Wed Jun 06, 2018 4:13 pm
by ESP_igrr
Yes, AFAIK the upcoming Arduino update should include PSRAM support.
Re: SD card memory use
Posted: Wed Jun 06, 2018 5:30 pm
by themindfactory
When might that be ??
Re: SD card memory use
Posted: Wed Jun 06, 2018 5:40 pm
by ESP_igrr
There is no firm date set for that, as there are still a few moving parts which need to be fixed before the release. But this is likely a matter of a few weeks.
Re: SD card memory use
Posted: Wed Jun 06, 2018 7:20 pm
by themindfactory
OK let me know, I could test for you guys also, I have a fairly large project right now running out of RAM!
I need to get my hands on some WROVERS however, I should use the also the 16MBytes versions, Arduino supports the larger flash too?
RichardS
Re: SD card memory use
Posted: Sun Sep 16, 2018 9:38 am
by snahmad75
This example
https://github.com/espressif/esp-idf/bl ... ple_main.c
uses allocation_unit_size . Does this allocation happens using malloc on internal RAM.
How can I configure SD card to use external RAM for allocation?