You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
8 RMT Channels Borks with PlatformIO only on ESP32 #771
I have an app that's pretty demanding - it's doing LZ decompression on one core of a stream of WiFI data received on the other, and drawing it using FastLED on 8 channels at once using RMT. So I'm really pushing things, but after some careful balancing of the load, all works well, at least if I build it using the Arduino IDE or the VSCode wrapper thereof.
If I compile it with PlatformIO (still Arduino Core, not ESPIDF) then it gets corruption, if anything at all, when talking to the LEDs. Basically FastLED.show() doesn't work. I recompile the same files with Arduino IDE, it works.
I appear to be using the same version of FastLED and other libraries that I inspected, so it almost seems like a compiler issue. Other than "I have a repro of this" I'm not sure what to do from here, but wondering if anyone else has had issues with PlatformIO and multiple channels on the ESP32?
Naturally, a simple case of one or two channels works fine...
I found the difference - board config in PlatformIO had PSRAM enabled, so that made for at least one different compiler flag, which I changed. That fixed it, even though the board did not have PSRAM and I was not calling PSRAMInit() or anything!
So, long story short, you can't even BUILD with PSRAM support enabled and have it work with >4 channels at once. That should be an easy repro, but how urgent it makes it I have no idea...
I stop seeing the intermittent crashes that Dave's talking about if I remove ESP_INTR_FLAG_IRAM | from the esp_intr_alloc call in clockless_rmt_esp32.cpp:132.
Trouble is removing ESP_INTR_FLAG_IRAM causes issues with timing stability for driving LEDs, since the inturrupt doesn't run while the flash is locked. I am going to see if I can hunt down what the compiler is storing in flash and see if we can't fix the issue by adding DRAM_ATTR to the declaration.
I am seeing the below stack trace when I have more than a couple of channels enabled. Is this the issue you're seeing too? Or is this another issue entirely?
Guru Meditation Error: Core 1 panic'ed (Cache disabled but cached memory region accessed)
Core 1 register dump:
PC : 0x4016f9ac PS : 0x00060734 A0 : 0x80081434 A1 : 0x3ffc0250
A2 : 0x3ffc4fa0 A3 : 0x00000002 A4 : 0x8008c658 A5 : 0x3ffba150
A6 : 0x00000000 A7 : 0x00000002 A8 : 0x800813de A9 : 0x3ffc0230
A10 : 0x00000002 A11 : 0x00000000 A12 : 0x00000005 A13 : 0x3ffba130
A14 : 0x3ff000dc A15 : 0x00000001 SAR : 0x0000001a EXCCAUSE: 0x00000007
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
Core 1 was running in ISR context:
EPC1 : 0x40081559 EPC2 : 0x00000000 EPC3 : 0x4008a1ac EPC4 : 0x4016f9ac
ELF file SHA256: 0000000000000000
Backtrace: 0x4016f9ac:0x3ffc0250 0x40081431:0x3ffc0270 0x400814da:0x3ffc0290 0x4008154e:0x3ffc02c0 0x40089b71:0x3ffc02e0 0x4008a1a9:0x3ffba1f0 0x4008730f:0x3ffba210 0x4008c556:0x3ffba230
#0 0x4016f9ac:0x3ffc0250 in rmt_set_pin at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/driver/rmt.c:394
#1 0x40081431:0x3ffc0270 in ESP32RMTController::startNext(int) at lib/FastLED/src/platforms/esp/32/clockless_rmt_esp32.cpp:430 (discriminator 4)
#2 0x400814da:0x3ffc0290 in ESP32RMTController::doneOnChannel(rmt_channel_t, void*) at lib/FastLED/src/platforms/esp/32/clockless_rmt_esp32.cpp:430 (discriminator 4)
#3 0x4008154e:0x3ffc02c0 in ESP32RMTController::interruptHandler(void*) at lib/FastLED/src/platforms/esp/32/clockless_rmt_esp32.cpp:430 (discriminator 4)
#4 0x40089b71:0x3ffc02e0 in _xt_medint3 at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/xtensa_vectors.S:1323
#5 0x4008a1a9:0x3ffba1f0 in spi_flash_op_block_func at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/spi_flash/cache_utils.c:203
#6 0x4008730f:0x3ffba210 in ipc_task at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/ipc.c:62
#7 0x4008c556:0x3ffba230 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1)
FWIW, I have in the past run 8 channels with this, both on the bench and for the umbrella project. There could have been a regression since then I suppose!
Closing — @BeldrothTheGold's 2021 diagnosis was correct, and both halves of it are resolved in the current drivers.
The diagnosis was right
@davepl found the trigger (-DBOARD_HAS_PSRAM + -mfix-esp32-psram-cache-issue in the PlatformIO board config, absent from the Arduino IDE build) — which is why it looked like "PlatformIO vs Arduino IDE" rather than a code bug.
I believe this is being caused by something in the FastLED esp32 interrupt handler accessing the flash while the flash cache is disabled
and the stack trace proves it — Cache disabled but cached memory region accessed, Core 1 was running in ISR context, with rmt_set_pin ← startNext() ← doneOnChannel(). The ISR was installed ESP_INTR_FLAG_IRAM, promising it would run with the cache off, then called an IDF function that lives in flash. The PSRAM cache workaround widens the windows where the cache is disabled, which is why those flags surfaced it.
His follow-up was also right that simply dropping ESP_INTR_FLAG_IRAM trades a crash for timing instability — that's not a fix.
Where it stands now
RMT5 — the default on ESP-IDF ≥ 5.0 (feature_flags/enabled.h:120-124, auto-selected; Arduino-ESP32 3.x is IDF 5.x): the hazard class is structurally absent. Grepping the whole RMT5 driver for esp_intr_alloc, ESP_INTR_FLAG_IRAM and rmt_set_pin returns nothing — it delegates to the IDF 5 RMT driver's own ISR rather than installing a hand-rolled IRAM handler. There is no FastLED ISR left to call flash from.
RMT4 — legacy path, still installs its ISR with ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_LEVEL3 (rmt4_peripheral_esp.cpp.hpp:133). But the crashing call path no longer exists: setGpio() (which wraps rmt_set_pin) is now reached only from configureChannel(), itself called only from acquireChannel() at task context — note it does FL_WARN_F logging, which an IRAM ISR could not do. None of the IRAM_ATTR functions in channel_driver_rmt4.h (handleInterrupt, onTxDoneInterrupt, fillNextBuffer, …) touch GPIO configuration. Pin assignment happens once when a channel is acquired, not on every channel handoff.
So the doneOnChannel → startNext → rmt_set_pin sequence from your trace has been designed out rather than patched around.
If you're still on this
Prefer a current Arduino-ESP32 3.x / IDF 5.x toolchain so you land on RMT5.
You should no longer need to strip the PSRAM flags to drive 8 channels — and if you're on a board that genuinely has PSRAM, you shouldn't have to choose.
FastLED also has non-RMT clockless backends on ESP32 now (I2S, SPI, PARLIO, LCD_CAM), which matters because RMT is the peripheral that contends most with the radio.
Thanks @davepl for an unusually well-isolated report — narrowing it to two compiler flags is what made it tractable — and @BeldrothTheGold for reading the ISR path and finding the actual mechanism. If anyone reproduces frame corruption on 8 channels with a current FastLED, please open a fresh issue with chip variant, IDF version and whether DMA is in use; that would be a new finding against a rewritten driver.
Activity
davepl commentedon Apr 13, 2019
I found the difference - board config in PlatformIO had PSRAM enabled, so that made for at least one different compiler flag, which I changed. That fixed it, even though the board did not have PSRAM and I was not calling PSRAMInit() or anything!
So, long story short, you can't even BUILD with PSRAM support enabled and have it work with >4 channels at once. That should be an easy repro, but how urgent it makes it I have no idea...
outlandnish commentedon Sep 12, 2019
@davepl what was the flag you disabled in PlatformIO to get it to work? I can't get it to work with more than 2 channels before it borks.
davepl commentedon Oct 12, 2021
Two years later: the two flags are
BeldrothTheGold commentedon Oct 31, 2021
I believe this is being caused by something in the FastLED esp32 interrupt handler accessing the flash while the flash cache is disabled.
I found this discussed here:
espressif/esp-idf#6164 (comment)
I stop seeing the intermittent crashes that Dave's talking about if I remove
ESP_INTR_FLAG_IRAM |from the esp_intr_alloc call in clockless_rmt_esp32.cpp:132.BeldrothTheGold commentedon Nov 1, 2021
Trouble is removing ESP_INTR_FLAG_IRAM causes issues with timing stability for driving LEDs, since the inturrupt doesn't run while the flash is locked. I am going to see if I can hunt down what the compiler is storing in flash and see if we can't fix the issue by adding DRAM_ATTR to the declaration.
BeldrothTheGold commentedon Nov 1, 2021
I am seeing the below stack trace when I have more than a couple of channels enabled. Is this the issue you're seeing too? Or is this another issue entirely?
davepl commentedon Nov 1, 2021
zackees commentedon Aug 1, 2026
Closing — @BeldrothTheGold's 2021 diagnosis was correct, and both halves of it are resolved in the current drivers.
The diagnosis was right
@davepl found the trigger (
-DBOARD_HAS_PSRAM+-mfix-esp32-psram-cache-issuein the PlatformIO board config, absent from the Arduino IDE build) — which is why it looked like "PlatformIO vs Arduino IDE" rather than a code bug.@BeldrothTheGold found the mechanism:
and the stack trace proves it —
Cache disabled but cached memory region accessed,Core 1 was running in ISR context, withrmt_set_pin←startNext()←doneOnChannel(). The ISR was installedESP_INTR_FLAG_IRAM, promising it would run with the cache off, then called an IDF function that lives in flash. The PSRAM cache workaround widens the windows where the cache is disabled, which is why those flags surfaced it.His follow-up was also right that simply dropping
ESP_INTR_FLAG_IRAMtrades a crash for timing instability — that's not a fix.Where it stands now
RMT5 — the default on ESP-IDF ≥ 5.0 (
feature_flags/enabled.h:120-124, auto-selected; Arduino-ESP32 3.x is IDF 5.x): the hazard class is structurally absent. Grepping the whole RMT5 driver foresp_intr_alloc,ESP_INTR_FLAG_IRAMandrmt_set_pinreturns nothing — it delegates to the IDF 5 RMT driver's own ISR rather than installing a hand-rolled IRAM handler. There is no FastLED ISR left to call flash from.RMT4 — legacy path, still installs its ISR with
ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_LEVEL3(rmt4_peripheral_esp.cpp.hpp:133). But the crashing call path no longer exists:setGpio()(which wrapsrmt_set_pin) is now reached only fromconfigureChannel(), itself called only fromacquireChannel()at task context — note it doesFL_WARN_Flogging, which an IRAM ISR could not do. None of theIRAM_ATTRfunctions inchannel_driver_rmt4.h(handleInterrupt,onTxDoneInterrupt,fillNextBuffer, …) touch GPIO configuration. Pin assignment happens once when a channel is acquired, not on every channel handoff.So the
doneOnChannel→startNext→rmt_set_pinsequence from your trace has been designed out rather than patched around.If you're still on this
Thanks @davepl for an unusually well-isolated report — narrowing it to two compiler flags is what made it tractable — and @BeldrothTheGold for reading the ISR path and finding the actual mechanism. If anyone reproduces frame corruption on 8 channels with a current FastLED, please open a fresh issue with chip variant, IDF version and whether DMA is in use; that would be a new finding against a rewritten driver.