Skip to content

Commit 781fb9e

Browse files
authored
Merge pull request #10328 from eightycc/issue-9937
Fix Intermittent ESP32 Crashes by Wrapping `longjmp`
2 parents b044c4c + 06a2fe1 commit 781fb9e

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

ports/espressif/Makefile

+18-11
Original file line numberDiff line numberDiff line change
@@ -202,21 +202,24 @@ else
202202
endif
203203

204204
ifeq ($(IDF_TARGET_ARCH),xtensa)
205-
# Remove the last two flags once TinyUSB is updated with the `#include <xtensa_api.h>` instead of
206-
# `#include "xtensa/xtensa_api.h"`.
205+
# Remove the last two flags once TinyUSB is updated with the `#include <xtensa_api.h>` instead of
206+
# `#include "xtensa/xtensa_api.h"`.
207207

208-
CFLAGS += -mlongcalls -isystem esp-idf/components/xtensa/deprecated_include/ -Wno-error=cpp
208+
CFLAGS += -mlongcalls -isystem esp-idf/components/xtensa/deprecated_include/ -Wno-error=cpp
209+
210+
# Wrap longjmp with a patched version that protects register window update with a critical section
211+
LDFLAGS += -Wl,--wrap=longjmp
209212
else ifeq ($(IDF_TARGET_ARCH),riscv)
210213

211-
ifeq ($(IDF_TARGET),esp32p4)
212-
CFLAGS += -march=rv32imafc_zicsr_zifencei_xesppie -mabi=ilp32f
213-
else
214-
CFLAGS += -march=rv32imac_zicsr_zifencei
215-
endif
214+
ifeq ($(IDF_TARGET),esp32p4)
215+
CFLAGS += -march=rv32imafc_zicsr_zifencei_xesppie -mabi=ilp32f
216+
else
217+
CFLAGS += -march=rv32imac_zicsr_zifencei
218+
endif
216219

217-
LDFLAGS += \
218-
-Lesp-idf/components/riscv/ld \
219-
-Trom.api.ld
220+
LDFLAGS += \
221+
-Lesp-idf/components/riscv/ld \
222+
-Trom.api.ld
220223
endif
221224

222225
$(BUILD)/lib/tlsf/tlsf.o: CFLAGS += -Wno-cast-align
@@ -546,6 +549,10 @@ else
546549
DEBUG_SDKCONFIG = esp-idf-config/sdkconfig-opt.defaults
547550
endif
548551

552+
ifeq ($(ENABLE_JTAG), 1)
553+
CFLAGS += -DENABLE_JTAG=1
554+
endif
555+
549556
SDKCONFIGS := esp-idf-config/sdkconfig.defaults;$(DEBUG_SDKCONFIG);$(FLASH_SIZE_SDKCONFIG);$(FLASH_MODE_SDKCONFIG);$(FLASH_SPEED_SDKCONFIG);$(PSRAM_SDKCONFIG);$(PSRAM_SIZE_SDKCONFIG);$(PSRAM_MODE_SDKCONFIG);$(PSRAM_SPEED_SDKCONFIG);$(TARGET_SDKCONFIG);boards/$(BOARD)/sdkconfig
550557
ifneq ($(CIRCUITPY_BLEIO_NATIVE),0)
551558
SDKCONFIGS := esp-idf-config/sdkconfig-ble.defaults;$(SDKCONFIGS)

0 commit comments

Comments
 (0)