Skip to content

Commit d42cb3b

Browse files
committed
fix(lwip): allow task stack from SPIRAM except for ESP32 ECO2 and below
Closes #17827
1 parent 437ddd1 commit d42cb3b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

components/lwip/port/hooks/tcp_isn_default.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -82,6 +82,10 @@
8282
#include "esp_rom_md5.h"
8383
#ifdef CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
8484
#include "esp_memory_utils.h"
85+
#if CONFIG_IDF_TARGET_ESP32
86+
#include "hal/efuse_hal.h"
87+
#include "soc/chip_revision.h"
88+
#endif
8589
#endif
8690

8791
#ifdef CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT
@@ -169,13 +173,13 @@ lwip_hook_tcp_isn(const ip_addr_t *local_ip, u16_t local_port,
169173

170174
/*
171175
* Generate the hash using ROM MD5 APIs
172-
* This hook is invoked in the context of TCP/IP (tiT) task and
173-
* it is unlikely that its stack would be placed in SPIRAM. Hence
174-
* even with SPIRAM enabled case and ESP32 revision < 3, using ROM
175-
* APIs should not create any issues.
176+
* For ESP32 chips prior to ECO3, the stack pointer must not point to external RAM
177+
* to use the ROM MD5 functions.
178+
* Other chips (ESP32-S2, ESP32-S3, ESP32-C3, etc.) don't have this limitation.
176179
*/
177-
#if CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
178-
assert(!esp_ptr_external_ram(esp_cpu_get_sp()));
180+
#if CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY && CONFIG_IDF_TARGET_ESP32
181+
/* Only assert for ESP32 revision < ECO3 (revision 300) */
182+
assert(ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 300) || !esp_ptr_external_ram(esp_cpu_get_sp()));
179183
#endif
180184

181185
md5_context_t ctx;

0 commit comments

Comments
 (0)