SD card mount internal RAM usage high

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

SD card mount internal RAM usage high

Postby snahmad75 » Tue Nov 27, 2018 2:53 pm

Hi,

I ma doing SD card mount

// Options for mounting the filesystem.
// If format_if_mount_failed is set to true, SD card will be partitioned and
// formatted in case when mounting fails.
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
.format_if_mount_failed = true,
.max_files = 5,
.allocation_unit_size = 16 * 1024
};


It used my internal ram of 20k after mount. How can I reduce it. I need high number of CONFIG_FATFS_FS_LOCK. Web browser access files simultaneously.

My FATFS config is

#
# FAT Filesystem support
#
CONFIG_FATFS_CODEPAGE_DYNAMIC=
CONFIG_FATFS_CODEPAGE_437=y
CONFIG_FATFS_CODEPAGE_720=
CONFIG_FATFS_CODEPAGE_737=
CONFIG_FATFS_CODEPAGE_771=
CONFIG_FATFS_CODEPAGE_775=
CONFIG_FATFS_CODEPAGE_850=
CONFIG_FATFS_CODEPAGE_852=
CONFIG_FATFS_CODEPAGE_855=
CONFIG_FATFS_CODEPAGE_857=
CONFIG_FATFS_CODEPAGE_860=
CONFIG_FATFS_CODEPAGE_861=
CONFIG_FATFS_CODEPAGE_862=
CONFIG_FATFS_CODEPAGE_863=
CONFIG_FATFS_CODEPAGE_864=
CONFIG_FATFS_CODEPAGE_865=
CONFIG_FATFS_CODEPAGE_866=
CONFIG_FATFS_CODEPAGE_869=
CONFIG_FATFS_CODEPAGE_932=
CONFIG_FATFS_CODEPAGE_936=
CONFIG_FATFS_CODEPAGE_949=
CONFIG_FATFS_CODEPAGE_950=
CONFIG_FATFS_CODEPAGE=437
CONFIG_FATFS_LFN_NONE=
CONFIG_FATFS_LFN_HEAP=
CONFIG_FATFS_LFN_STACK=y
CONFIG_FATFS_MAX_LFN=255
CONFIG_FATFS_API_ENCODING_ANSI_OEM=y
CONFIG_FATFS_API_ENCODING_UTF_16=
CONFIG_FATFS_API_ENCODING_UTF_8=
CONFIG_FATFS_FS_LOCK=7
CONFIG_FATFS_TIMEOUT_MS=10000
CONFIG_FATFS_PER_FILE_CACHE=y

Any idea how can I reduce it. How can I used external ram for SD card.

Thanks,
Naeem

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: SD card mount internal RAM usage high

Postby snahmad75 » Thu Nov 29, 2018 10:26 am

Can some answer my query.

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

Re: SD card mount internal RAM usage high

Postby ESP_igrr » Thu Nov 29, 2018 10:31 am

Hi snahmad75,
Currently you can only move FATFS allocations into external RAM if you tweak the allocation threshold (https://docs.espressif.com/projects/esp ... ysinternal).
We plan to add a configuration option to prefer external RAM for FATFS data structures, in IDF 3.3.

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: SD card mount internal RAM usage high

Postby snahmad75 » Thu Nov 29, 2018 11:57 am

ESP_igrr wrote:
Thu Nov 29, 2018 10:31 am
Hi snahmad75,
Currently you can only move FATFS allocations into external RAM if you tweak the allocation threshold (https://docs.espressif.com/projects/esp ... ysinternal).
We plan to add a configuration option to prefer external RAM for FATFS data structures, in IDF 3.3.
I am ok for now. I was getting low on internal ram. I reduce my

CONFIG_FATFS_FS_LOCK=7 to CONFIG_FATFS_FS_LOCK=5

and change.

CONFIG_LWIP_IRAM_OPTIMIZATION=y
CONFIG_TCPIP_TASK_AFFINITY_CPU1=y

Now I can access my embedded mongoose web server with 2-3 web browser clients.

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: SD card mount internal RAM usage high

Postby snahmad75 » Tue Jan 29, 2019 9:52 pm

Hi,

Does max_files have effect on access files simultaneous from web server . I am using mongoose webserver. Modern browser access files in parallel. I miss some files browser fail to load and it is slow.

esp_vfs_fat_sdmmc_mount_config_t mount_config = {
.format_if_mount_failed = true,
.max_files = 3,
.allocation_unit_size = 16 * 1024
};

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: SD card mount internal RAM usage high

Postby snahmad75 » Thu Feb 07, 2019 5:57 pm

My mongoose web server is reading files via http serve to read files from sd card.

Internal ram goes down very quickly. any idea which line of code is allocating internal ram. I do not want to alloc heap when reading files. stack memory should be good enough.

I (60191) W2K: Internal Heap free: 54856

D (60359) W2K: enter vfs_fat_open path=/wwwroot/index.html
D (60365) W2K: exit vfs_fat_open path=1:/wwwroot/index.html, fd=0
D (60380) W2K: vfs_fat_close fd=0
D (60421) W2K: enter vfs_fat_open path=/wwwroot/assets/bootstrap.min.css
D (60431) W2K: exit vfs_fat_open path=1:/wwwroot/assets/bootstrap.min.css, fd=0
D (60474) W2K: enter vfs_fat_open path=/wwwroot/assets/style.css
D (60481) W2K: exit vfs_fat_open path=1:/wwwroot/assets/style.css, fd=1
D (60514) W2K: enter vfs_fat_open path=/wwwroot/styles.0e4338761429b4eb16ac.css
D (60522) W2K: exit vfs_fat_open path=1:/wwwroot/styles.0e4338761429b4eb16ac.css, fd=2
D (60527) W2K: vfs_fat_close fd=2
D (60578) W2K: enter vfs_fat_open path=/wwwroot/assets/js/jquery-3.3.1.slim.min.js
D (60590) W2K: exit vfs_fat_open path=1:/wwwroot/assets/js/jquery-3.3.1.slim.min.js, fd=2
D (60646) W2K: enter vfs_fat_open path=/wwwroot/main.4229da4ed6e9ace97a97.js
D (60652) W2K: exit vfs_fat_open path=1:/wwwroot/main.4229da4ed6e9ace97a97.js, fd=3
D (60697) W2K: enter vfs_fat_open path=/wwwroot/runtime.ec2944dd8b20ec099bf3.js
D (60703) W2K: exit vfs_fat_open path=1:/wwwroot/runtime.ec2944dd8b20ec099bf3.js, fd=4
D (60736) W2K: enter vfs_fat_open path=/wwwroot/polyfills.d6c80b389a3c780d347c.js
E (60738) vfs_fat: open: no free file descriptors
D (60759) W2K: vfs_fat_close fd=4
D (61002) W2K: vfs_fat_close fd=1
D (61021) W2K: vfs_fat_close fd=0
I (61191) W2K: Internal Heap free: 39896

Who is online

Users browsing this forum: Bing [Bot] and 134 guests