Skip to content

esp32/network: Use non-PSRAM Wi-Fi settings if PSRAM fails to initialise #12968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

projectgus
Copy link
Contributor

@projectgus projectgus commented Nov 14, 2023

In ESP-IDF, enabling SPIRAM in menuconfig sets a Kconfig option called Wi-Fi Cache TX Buffers and switches the default TX Buffer type to Dynamic. These settings use 54,528 bytes of heap at runtime.

Not a problem if PSRAM is available, but it's quite a lot of RAM to use up if PSRAM failed to initialise! As we use the same config for PSRAM & no-PSRAM devices now, this either causes Wi-Fi to fail to initialise (seen on S2) or will eat quite a lot of RAM (seen on S3).

Original ESP32 has separate builds for SPIRAM vs "no SPIRAM", so this doesn't change anything there.

The difference in free IDF Heap between an ESP32-S3 build (PSRAM fails to initialise) is 54,528 bytes after Wi-Fi initialises. Building MicroPython with Kconfig set to disable PSRAM (and Wi-Fi settings restored to default) shows another 1856 bytes free at boot, unsure what this is used for (probably not Wi-Fi related).

Closes #12750.

This work was funded through GitHub Sponsors.

@dpgeorge
Copy link
Member

Great find!

@projectgus projectgus marked this pull request as draft November 15, 2023 07:58
@projectgus
Copy link
Contributor Author

projectgus commented Nov 15, 2023

Marking as draft as I think there's one more config field we can switch over in this case.

EDIT: This is done

@projectgus projectgus force-pushed the bugfix/esp32_static_wifi_no_psram branch 2 times, most recently from 2aeddca to ff2efdd Compare November 21, 2023 00:17
@projectgus projectgus changed the title esp32/network: Disable "Wi-Fi Cache TX Buffers" if PSRAM not found. esp32/network: Use non-PSRAM Wi-Fi settings if PSRAM fails to initialise Nov 21, 2023
@projectgus projectgus marked this pull request as ready for review November 21, 2023 00:20
In ESP-IDF, enabling SPIRAM in menuconfig sets some Kconfig options:

- "Wi-Fi Cache TX Buffers" enabled. By default this tries to allocate 32 of
these when Wi-Fi is initialised, which requires 54,400 bytes of free heap.

- Switches "Type of WiFi TX buffers" from Dynamic to Static. This
pre-allocates all of the Wi-Fi transmit buffers.

Not a problem if PSRAM is initialised, but it's quite a lot of RAM if PSRAM
failed to initialise! As we use the same config for PSRAM & no-PSRAM builds
now, this either causes Wi-Fi to fail to initialise (seen on S2) or will
eat quite a lot of RAM.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
@dpgeorge dpgeorge force-pushed the bugfix/esp32_static_wifi_no_psram branch from ff2efdd to 960eef7 Compare November 23, 2023 00:54
@dpgeorge dpgeorge merged commit 960eef7 into micropython:master Nov 23, 2023
@projectgus projectgus deleted the bugfix/esp32_static_wifi_no_psram branch November 1, 2024 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

esp32s2 v1.21 network.WLAN(network.STA_IF) RuntimeError: Wifi Unknown Error 0x0101
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy