External RAM enabled and performance tuning

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

External RAM enabled and performance tuning

Postby snahmad75 » Wed Sep 19, 2018 8:45 pm

I set my menuconfig.


CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL = 4096
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=50768
CONFIG_SPIRAM_USE_MALLOC=y


Once internal ram free is less than 50768 than all allocation using new/alloc will start happening from external ram.

As I understood. I need to keep 50-60 k internal ram always free to be used by Wifi module.

Option #1
I am using standard alloc and new.

As I understood. Any ram buffer allocation more than 4k will be allocated from external ram always. less than on internal ram.

I reserve my internal ram minimum free space= 50768 to be used Wifi and other system libraries. I guess used by mongoose networking libraries for tcp/udp connections.

My free internal ram stats shows that free internal ram still 80k. which is good for WIFI


Option # 2
I am trying to avoid explicit malloc calls heap_caps_malloc(size, MALLOC_CAP_SPIRAM) or internal.
I did try it. I found that after my firmware/application starts. It do ram free stats. It is showing that internal ram left is about 50k.
not much. If I starts web server and open my website with some files gets read from sd card which is about 2.3 Mb. It consume internal ram during reading SD card. My internal ram goes down to 40k and Wifi stop working.

I am looking to use Option #1

Is this good settings and options to be used. i have wifi with its own access point and STA.
I am using mongoose web server as well be some TCP, UDP sockets.
CAN driver also used to send and receive messages. SD card also used to read/write with Mongoose Http Web server

Do suggest any tuning for optimal performance.

All my Tasks /Threads are running on CPU1. CPU0 is assigned for Wifi.

Thanks,
Naeem.

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

Re: External RAM enabled and performance tuning

Postby snahmad75 » Thu Sep 20, 2018 8:51 am

Can anyone reply to me on this thread about usage of external ram. Does option 1 and option 2 effects remaining internal/external ram used by ESP32 system libraries ( WIFI, drivers).


Can anyone explain to me. what are these options means

CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=8192

CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL means any buffer allocation more than 8k will go external ram.

CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768

CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL ???

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

Re: External RAM enabled and performance tuning

Postby ESP_Sprite » Fri Sep 21, 2018 1:59 am

RESERVE_INTERNAL means that there is a pool reserved for allocations that *need* to be in internal memory, for example because they're used in DMA transfers. 'Normal' allocations will not touch this pool, the memory in here is only given out if an allocation specifically requests internal memory.

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: External RAM enabled and performance tuning

Postby fly135 » Fri Sep 21, 2018 9:14 pm

I know you said you don't want to do this, but I use heap_caps_malloc(size, MALLOC_CAP_SPIRAM) and it works great. Gives you full control over using ext ram.

Also I found out you can free up a ton of memory (~90K) by disabling Bluetooth. I only use Bt when provisioning the device. So I reboot after it's provisioned.

John A

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

Re: External RAM enabled and performance tuning

Postby snahmad75 » Sat Sep 22, 2018 11:05 am

Hi John,

Thanks for reply. i appreciate it.

for now any allocation more than CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=8192 gets allocated on external ram.
and less than goes to internal ram.
Good enough for now.

Thanks,
Naeem

Who is online

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