Skip to content

feat(websocket): add PSRAM allocation options - #1117

Open
gabsuren wants to merge 1 commit into
masterfrom
pr-980-fix
Open

feat(websocket): add PSRAM allocation options#1117
gabsuren wants to merge 1 commit into
masterfrom
pr-980-fix

Conversation

@gabsuren

@gabsuren gabsuren commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Add Kconfig options for PSRAM allocations in esp_websocket_client, including external-memory task stack gating with FREERTOS_TASK_CREATE_ALLOW_EXT_MEM.

Related

This PR builds on #980 and simplifies the external task-stack implementation.


Note

Medium Risk
PSRAM task stacks impose cache-disabled constraints on WebSocket task and event-handler code; misconfiguration can cause subtle runtime faults, though options are off by default and failures fail closed without internal-RAM fallback.

Overview
Adds optional PSRAM placement for esp_websocket_client to reduce internal RAM use on SPIRAM-enabled builds.

ESP_WS_CLIENT_ALLOC_IN_EXT_RAM moves the main client object and its websocket_config_storage_t to PSRAM via heap_caps_calloc / heap_caps_free (no fallback—esp_websocket_client_init() returns NULL on failure). Other allocations (strings, RX/TX buffers, transports, mutexes, etc.) stay on internal RAM.

ESP_WS_CLIENT_TASK_STACK_IN_EXT_RAM creates the WebSocket worker with xTaskCreatePinnedToCoreWithCaps() so only the stack lives in PSRAM (TCB stays internal). The task exits with vTaskDeleteWithCaps(NULL); this path requires ESP-IDF ≥ 5.3.1 (compile-time #error otherwise). Failed stack allocation makes esp_websocket_client_start() return ESP_FAIL. Kconfig documents cache-off restrictions for code running on that task (including event handlers).

Reviewed by Cursor Bugbot for commit 2512950. Bugbot is set up for automated code reviews on this repo. Configure here.

@gabsuren gabsuren self-assigned this Jul 30, 2026
@gabsuren
gabsuren force-pushed the pr-980-fix branch 2 times, most recently from 3ec0aff to 1132650 Compare July 30, 2026 08:07
Comment thread components/esp_websocket_client/examples/target/sdkconfig.ci.psram Outdated
@gabsuren
gabsuren force-pushed the pr-980-fix branch 2 times, most recently from 846f197 to 5d6b0ca Compare July 30, 2026 10:23

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5d6b0ca. Configure here.

Comment thread components/esp_websocket_client/examples/target/sdkconfig.ci.psram Outdated
Add Kconfig options for PSRAM allocations in esp_websocket_client, including external-memory
task stack gating with FREERTOS_TASK_CREATE_ALLOW_EXT_MEM.
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.

2 participants