SD card memory use

themindfactory
Posts: 17
Joined: Mon Mar 26, 2018 7:57 pm

SD card memory use

Postby themindfactory » Wed Jun 06, 2018 4:40 am

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

ESP_igrr
Posts: 1028
Joined: Tue Dec 01, 2015 8:37 am

Re: SD card memory use

Postby ESP_igrr » Wed Jun 06, 2018 6:06 am

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.

themindfactory
Posts: 17
Joined: Mon Mar 26, 2018 7:57 pm

Re: SD card memory use

Postby themindfactory » Wed Jun 06, 2018 12:06 pm

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

ESP_igrr
Posts: 1028
Joined: Tue Dec 01, 2015 8:37 am

Re: SD card memory use

Postby ESP_igrr » Wed Jun 06, 2018 12:18 pm

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.

themindfactory
Posts: 17
Joined: Mon Mar 26, 2018 7:57 pm

Re: SD card memory use

Postby themindfactory » Wed Jun 06, 2018 1:49 pm

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

ESP_igrr
Posts: 1028
Joined: Tue Dec 01, 2015 8:37 am

Re: SD card memory use

Postby ESP_igrr » Wed Jun 06, 2018 4:13 pm

Yes, AFAIK the upcoming Arduino update should include PSRAM support.

themindfactory
Posts: 17
Joined: Mon Mar 26, 2018 7:57 pm

Re: SD card memory use

Postby themindfactory » Wed Jun 06, 2018 5:30 pm

When might that be ??

ESP_igrr
Posts: 1028
Joined: Tue Dec 01, 2015 8:37 am

Re: SD card memory use

Postby ESP_igrr » Wed Jun 06, 2018 5:40 pm

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.

themindfactory
Posts: 17
Joined: Mon Mar 26, 2018 7:57 pm

Re: SD card memory use

Postby themindfactory » Wed Jun 06, 2018 7:20 pm

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

Who is online

Users browsing this forum: No registered users and 1 guest