Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 1d0e264

Browse files
committed
Fix crash when pin ISR handler fires (i.e. LoRa TX done) during flash operation (i.e. ota_write() call)
I was seeing crashes with "Cache disabled but cached memory region accessed" as reason. The coredump showed one of the threads being inside spi_flash_op_block_func(), while the thread that caused the crash was an ISR (with LoRa's OnRadioTxDone handler somewhere in the stacktrace). The comment above spi_flash_op_block_func(), suggests that if an interrupt handler accesses PSRAM, it must not be part of the "IRAM" ISR handlers, so it will be disabld during flash ops. This change will flag all ISR handlers for the Pin module as non-IRAM and thereby preventing the crashes.
1 parent 7b83c6d commit 1d0e264

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

esp32/mods/machpin.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,13 @@ DECLARE PRIVATE DATA
108108
DEFINE PUBLIC FUNCTIONS
109109
******************************************************************************/
110110
void pin_preinit(void) {
111-
gpio_isr_register(machpin_intr_process, NULL, ESP_INTR_FLAG_IRAM, NULL);
111+
intr_handle_t isr_handle;
112+
if (ESP_OK == gpio_isr_register(machpin_intr_process, NULL, ESP_INTR_FLAG_IRAM, &isr_handle)) {
113+
// Probably non-optimal, but assume the ISR handler will access PSRAM (which is the case with the LoRa TX done
114+
// handler) and thus the interrupt will have to be disabled during a flash operation to prevent crashes.
115+
// See comment with spi_flash_op_block_func().
116+
esp_intr_set_in_iram(isr_handle, false);
117+
}
112118
}
113119

114120
void pin_init0(void) {

0 commit comments

Comments
 (0)
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