|
1 | 1 | /* |
2 | | - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD |
| 2 | + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD |
3 | 3 | * |
4 | 4 | * SPDX-License-Identifier: Apache-2.0 |
5 | 5 | */ |
|
82 | 82 | #include "esp_rom_md5.h" |
83 | 83 | #ifdef CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY |
84 | 84 | #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 |
85 | 89 | #endif |
86 | 90 |
|
87 | 91 | #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, |
169 | 173 |
|
170 | 174 | /* |
171 | 175 | * 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. |
176 | 179 | */ |
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())); |
179 | 183 | #endif |
180 | 184 |
|
181 | 185 | md5_context_t ctx; |
|
0 commit comments