Page 1 of 1

WIFI + PSRAM - Settings Clarification

Posted: Thu Jul 01, 2021 10:02 am
by SimonWillis
Hi There,

I have an application that is fairly large in size and is beginning to cause wifi to fail with a "wifi: m f null" error (and not much else). I've started adjusting the memory allocation for wifi and have had success in improving the wifi stability. I'd just like to clarify what is written in the ESP documentation as I find it a little contradictory and I want to make sure I have the settings correct for maximum stability (speed is less of a concern for our application).

Reference (screenshot below): https://docs.espressif.com/projects/esp ... sing-psram

I have by settings as follows:
  • SPIRAM allocation is set to the SPIRAM_USE_MALLOC option. My understanding is that this makes the Wifi TX buffer dynamic
  • SPIRAM_TRY_ALLOCATE_WIFI_LWIP is set.
  • I have set SPIRAM_MALLOC_RESERVE_INTERNAL to 98K which I calculated as my FreeRTOS stacks + wifi TX and RX buffers (12 * 1600 * 2) for wifi dynamic buffer sizes of 12 (both TX and RX).
  • I have configured the wifi buffers as per the documentation guide for memory saving (https://docs.espressif.com/projects/esp ... parameters). This is giving me 48K free on the internal heap.
  • I have IRAM optimisation disabled.
I tested the settings used in the PSRAM table and it appeared to work OK and gave me 73K free on the internal heap. However, I'm a little concerned on it since some of the buffer sizes are recommended to be very large and I'm concerned we may overflow the internal heap (see my questions below).
PSRAM Table.png
PSRAM Table.png (163.9 KiB) Viewed 5275 times
It would be very much appreciated if someone could clarify the following for me:
  • Why is WIFI_DYNAMIC_RX_BUFFER_NUM set to such a large size? Is this buffer being stored in PSRAM? If so, I assume this means we
    can ignore it in the calculation for SPIRAM_MALLOC_RESERVE_INTERNAL.
  • In the Memory Saving column it suggests setting static RX BUFFER size to 4 with AMPDU enabled (WIFI_RX_BA_WIN). HOwever, the documentation suggests AMPDU should be disabled with an RX BUFFER size less than 6.
  • Why is it recommend to increase the LWIP buffers to 65K (maximum value)? Are these stored on PSRAM?
  • Finally, why do the IRAM_OPT rows have numbers in them? These are booleans.
Thanks in advance for any help you may provide. I hope this helps others.

Re: WIFI + PSRAM - Settings Clarification

Posted: Tue Sep 21, 2021 2:14 pm
by gd_code
Hi,

It would be great as some of these questions could be answered by the ESP WiFi team, as I agree that documentation on this is quite contradictory.

Kind regards,
gd_code

Re: WIFI + PSRAM - Settings Clarification

Posted: Thu Sep 23, 2021 12:31 pm
by ns1668
I would also like a response from the espressif dev team to the questions above.

Re: WIFI + PSRAM - Settings Clarification

Posted: Mon Dec 04, 2023 10:24 am
by math045d
Did anyone gain further knowledge about this worth noting ? :)

I am experiencing stability issues while sending large files (10 - 50MB) (random sudden blocks/race condition type scenario) from ESP32S3 with PSRAM enabled, to an AWS bucket.

Re: WIFI + PSRAM - Settings Clarification

Posted: Sat Mar 23, 2024 10:46 pm
by DrMickeyLauer
This is one of the areas where I really wish ESP-IDF configurability was less fine grained. With these options, it‘s combinatorial explosion to check what works best. Perhaps three choices of performance/ram pressure ranks would have been better.