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
Updated an older version of fastled - (maybe 3.2.x) and the LEDs stopped working. Only tried on my WS2811 strips. Stepped the library back to 3.2.8 and it worked again. I'm guessing something in PR #789@samguyer? I checked with the oscilloscope and didn't see anything on the pins.
Switched over to use the I2S version and that works perfect with the same setup. Thanks for that! I was going to move forward with that anyways since I might as well use more the 8 parallel strings!
I've also found that the RMT driver isn't working for 8 parallel strings in the latest version.
It works for 1-7 strips, but at 8 there's no output on any of the strips.
Here's the code I'm using to reproduce it, this doesn't output anything at all as is. However, if you comment out any one of the strips it will work again.
I am having the same issue, but even does not work with 6 pins. I was pulling 90% of my hair out after 4 hours of finding the mistake in my code or to find a workaround. How to switch to I2S version? Quite lame question: actually what is that?
Ug. Sorry all. I will get cracking on this problem as soon as possible. In the meantime you can use the I2S implementation. It will work in most circumstances. Check the notes in clockless_esp32.h for details.
Hi all, I am trying to debug this problem, but I need your help. @jrhun can you try something for me? Modify your code to use only 7 strips -- and confirm that it works. Then add the following #define before you include fastled.h:
#define FASTLED_RMT_MAX_CHANNELS 7
Let me know if it still works, or if that breaks it.
Adding #define FASTLED_RMT_MAX_CHANNELS 7 works for both 7 strips and 8 strips.
Something I didn't realize before, is that the code I posted above will output data for strips 1-7 for the initial ~4-10 updates after each reset (I hadn't noticed this since I wasn't turning the LEDs off completely during tests). During these updates, strip 8 will output the wrong colors and sometimes just random data or nothing at all.
@focalintent
Dan, do you have a few minutes to double-check the fix that I pushed to you for the color order problem (making those key methods virtual)? Other than that change, 3.2.10 should be identical to 3.2.9
I tried with my example, 7 or 8 channels. (see bug #839) It just freezes like before. It shows 1 frame random something, or part of the correct image, that is all. Interestingly sometimes it keeps updating with random stuff, but the first 100~200 LEDs of the first channel only.
For the ESP32, F_CPU is at best 240000000 (and CLOCKLESS_FREQUENCY is == F_CPU). This macro sets the timings for the clockless mode chipsets (e.g., C_NS(1010)).
This appears to be a fix for #813, but this is also causing the RMT to act up. Without it, apparently the timings are wrong for an ESP8266. With it, the timings may be correct (for the 8266) but the RMT fails on the ESP32.
Edit: to be more exact, I think the timings end up so low that the RMT device is running faster than its interrupt handler can keep up with when all 8 channels are in use. It seems to become a problem when there are >=32 LEDs on the strips (for the purpose of this, each strip having the same number). That means the buffer is filled fully on init, but the interrupt-driven half-copies are failing after that point. 512 bytes of buffer / 8 channels / 3 colors * 1.5 (one and a half fills) = 32.
Bottom line - I'd revert that change, ensure it's stable on the ESP32 again at 8 channels, and come up with a way to handle ESP8266 that doesn't affect the '32.
I have always been a little concerned about the timings that result from the values passed in from chipsets.h. I'll take a look at the timing calculation more closely.
I can also look at the efficiency of the fill buffer function -- maybe there is some performance to be had there. We might even be able to detect online when the interrupt handler is dropping parts of the data.
The reason for making that method virtual is to handle cases where different kinds of strips are attached to the same microcontroller. The virtual dispatch will call the method that has the right template parameters baked into it. Does that make sense?
OK, I'm going to try a different tack: I'll just use the interrupt handler to signal to the user-level code to refill the RMT buffer. In some ways, that's more in the spirit of interrupt handlers anyway. It's going to require some restructuring of the code, but I'll let you know when I've got something working.
I also found a discussion on the ESP-IDF discussion forum that the WiFi task is pinned to Core 0, so it might be good to move the FastLED stuff to Core 1. See here:
@samguyer
By default on ESP32 Arduino task is pinned to core 1, so adding another task does not change anything (however as I've noticed before creating a task with higher priority helps a bit). The interrupt should be created on current core so that also should be good.
In case you are not using PlatformIO (I highly recommend it), it's available as an extension for VSCode and it contains everything that is required to work with it. When using it, just clone your FastLED into lib/ in my repo and you should be good to go.
@drzony I just pushed a version to my FastLED repo (not the main one) that changes the strategy for refilling the RMT buffer. The interrupt handler just records which channels (which strips) need attention, but the actual work is done outside the interrupt handler. I'd be interested to see if this approach improves the situation for you.
@drzony Actually, hold off using that code. I don't think it works correctly. But I think I'm getting closer to understanding what's going on in the interaction between FastLED and the WiFi subsystem.
Closing — this thread ran through two distinct problems over 94 comments, and the RMT5 rewrite addresses both by design rather than by patch.
Problem 1 — "works at 7 strips, dead at 8"
@brycedjohnson and @jrhun both hit this, and @jrhun's reduced repro (comment out any one of eight addLeds calls and it works again) was the key data point.
The ESP32 has 8 RMT channels, but each non-DMA channel needs multiple memory blocks, so the on-chip RMT memory runs out well before the channel count does. The RMT4 driver assumed one channel per strip and fell off a cliff at the limit.
RMT5 doesn't make that assumption. From the driver's own README:
Worker pooling — Supports N > K strips (where K = hardware channel count)
Strips are time-multiplexed across a pool of channels, so the strip count is no longer bounded by the hardware channel count. Memory is managed centrally, with the accounting documented per chip (ESP32-S3: 192 words on-chip; 96 words per non-DMA channel at 2× buffering, 144 at 3×; DMA channels consume zero on-chip words because they stream from DRAM).
Problem 2 — the WiFi interference this thread turned into
The second half — @drzony's single-frame glitches during TCP/MQTT traffic, and @samguyer instrumenting the refill interval and finding it stretch from ~9600 cycles to 13,000 right as TCP fired — is the same root cause as #771: network interrupts starving the RMT refill.
@drzony's analysis of why only one or two LEDs were affected rather than everything downstream was correct, and it's a genuinely subtle point worth preserving: each LED regenerates the signal for the next, and with a 50 µs reset the downstream pixels resynchronise. That's why a timing-sensitive serial protocol produced localised corruption, which had puzzled @samguyer.
Four things in RMT5 target exactly this:
Double buffering — ping-pong refills, listed first in the README as "Eliminates Wi-Fi interference"
Network-aware channel management — a NetworkDetector raises the per-channel buffer from 2× to 3× when WiFi/BT/Ethernet is active
Adaptive interrupt priority — raises the RMT interrupt above network interrupts where the platform allows. (@drzony noted in 2020 that LEVEL3 was the practical ceiling since LEVEL4+ requires assembly — that constraint is handled explicitly now.)
DMA mode — removes the refill interrupt from the picture entirely
@samguyer's last idea on the thread — "use the interrupt handler to signal to the user-level code to refill the RMT buffer" — is essentially the direction the driver ultimately took, moving work out of the ISR. He was on the right track before it stalled.
Practical notes
RMT5 is the default on ESP-IDF ≥ 5.0 (Arduino-ESP32 3.x), selected automatically.
If you're driving many strips with WiFi, DMA is the strongest lever — it sidesteps both the on-chip memory pressure and the refill ISR.
Watch for external RMT consumers: USB CDC on ESP32-S3 reserves ~48 words, which eats into the same budget.
@brycedjohnson — I2S remains a good option and is still supported, alongside SPI, PARLIO and LCD_CAM.
Thanks @jrhun for the minimal repro, @drzony for the reproducible test repo and the pixel-regeneration analysis, and @samguyer for the cycle-level instrumentation that identified the mechanism. If anyone still sees this on a current FastLED, please open a fresh issue with chip variant, IDF version, strip count and whether DMA is active — it would be a new finding against a rewritten driver.
Activity
jrhun commentedon Jul 11, 2019
I've also found that the RMT driver isn't working for 8 parallel strings in the latest version.
It works for 1-7 strips, but at 8 there's no output on any of the strips.
Here's the code I'm using to reproduce it, this doesn't output anything at all as is. However, if you comment out any one of the strips it will work again.
Tested with FastLED 3.2.10 on esp32 doit devkit v1, with Arduino 1.8.9.
samguyer commentedon Jul 11, 2019
Hmmm. Sounds like I need to do some debugging!
brycedjohnson commentedon Jul 11, 2019
Yes I was doing 8 strips as well. Never tried with less though.
Nagymadar commentedon Jul 15, 2019
I am having the same issue, but even does not work with 6 pins. I was pulling 90% of my hair out after 4 hours of finding the mistake in my code or to find a workaround. How to switch to I2S version? Quite lame question: actually what is that?
samguyer commentedon Jul 15, 2019
Ug. Sorry all. I will get cracking on this problem as soon as possible. In the meantime you can use the I2S implementation. It will work in most circumstances. Check the notes in clockless_esp32.h for details.
Nagymadar commentedon Jul 15, 2019
Thanks a lot in advance.
samguyer commentedon Jul 18, 2019
Hi all, I am trying to debug this problem, but I need your help. @jrhun can you try something for me? Modify your code to use only 7 strips -- and confirm that it works. Then add the following #define before you include fastled.h:
#define FASTLED_RMT_MAX_CHANNELS 7
Let me know if it still works, or if that breaks it.
jrhun commentedon Jul 18, 2019
Adding #define FASTLED_RMT_MAX_CHANNELS 7 works for both 7 strips and 8 strips.
Something I didn't realize before, is that the code I posted above will output data for strips 1-7 for the initial ~4-10 updates after each reset (I hadn't noticed this since I wasn't turning the LEDs off completely during tests). During these updates, strip 8 will output the wrong colors and sometimes just random data or nothing at all.
samguyer commentedon Jul 18, 2019
@focalintent
Dan, do you have a few minutes to double-check the fix that I pushed to you for the color order problem (making those key methods virtual)? Other than that change, 3.2.10 should be identical to 3.2.9
Nagymadar commentedon Jul 18, 2019
I tried with my example, 7 or 8 channels. (see bug #839) It just freezes like before. It shows 1 frame random something, or part of the correct image, that is all. Interestingly sometimes it keeps updating with random stuff, but the first 100~200 LEDs of the first channel only.
Nagymadar commentedon Jul 22, 2019
Any progress? Can I help with testing?
MartyMacGyver commentedon Aug 1, 2019
Some additional info (looking at this code here as well as the discussion on Reddit)
Looking at the delta, there are two interesting and potentially relevant diffs:
This one in
platforms/esp/32/clockless_rmt_esp32.hWhere
void IRAM_ATTR fillHalfRMTBuffer()becomes
virtual void IRAM_ATTR fillHalfRMTBuffer()This has no effect on the problem nor anything else that I can see, but I'm very curious why this was changed?
Edit: I see this is from #831 and it appears to be unique to FastLED's templating system.
This one in
chipsets.hWhere
#define C_NS(_NS) (_NS * ((CLOCKLESS_FREQUENCY / 1000000L) + 999) / 1000)becomes
#define C_NS(_NS) (((_NS * ((CLOCKLESS_FREQUENCY / 1000000L)) + 999)) / 1000)This is leading to the problem
For the ESP32,
F_CPUis at best240000000(andCLOCKLESS_FREQUENCYis ==F_CPU). This macro sets the timings for the clockless mode chipsets (e.g.,C_NS(1010)).Here's how the calculations differ:
We get:
This appears to be a fix for #813, but this is also causing the RMT to act up. Without it, apparently the timings are wrong for an ESP8266. With it, the timings may be correct (for the 8266) but the RMT fails on the ESP32.
Edit: to be more exact, I think the timings end up so low that the RMT device is running faster than its interrupt handler can keep up with when all 8 channels are in use. It seems to become a problem when there are >=32 LEDs on the strips (for the purpose of this, each strip having the same number). That means the buffer is filled fully on init, but the interrupt-driven half-copies are failing after that point. 512 bytes of buffer / 8 channels / 3 colors * 1.5 (one and a half fills) = 32.
Bottom line - I'd revert that change, ensure it's stable on the ESP32 again at 8 channels, and come up with a way to handle ESP8266 that doesn't affect the '32.
@focalintent - FYI
samguyer commentedon Aug 1, 2019
@MartyMacGyver
Martin, thanks for the analysis.
I have always been a little concerned about the timings that result from the values passed in from chipsets.h. I'll take a look at the timing calculation more closely.
I can also look at the efficiency of the fill buffer function -- maybe there is some performance to be had there. We might even be able to detect online when the interrupt handler is dropping parts of the data.
The reason for making that method virtual is to handle cases where different kinds of strips are attached to the same microcontroller. The virtual dispatch will call the method that has the right template parameters baked into it. Does that make sense?
samguyer commentedon Aug 1, 2019
Also: why is the ESP8266 support an issue here? The ESP32 code should affect it at all.
MartyMacGyver commentedon Aug 1, 2019
All I know is that #813 was specific to an 8266 problem, but that change is what breaks the ESP32.
The commit in question:
ca9e40b
74 remaining items
drzony commentedon Jul 21, 2020
Currently it's LEVEL3, according to headers LEVEL4 and above are "High level interrupts. Need to be handled in assembly.", so that would be tough.
samguyer commentedon Jul 21, 2020
OK, I'm going to try a different tack: I'll just use the interrupt handler to signal to the user-level code to refill the RMT buffer. In some ways, that's more in the spirit of interrupt handlers anyway. It's going to require some restructuring of the code, but I'll let you know when I've got something working.
I also found a discussion on the ESP-IDF discussion forum that the WiFi task is pinned to Core 0, so it might be good to move the FastLED stuff to Core 1. See here:
https://www.esp32.com/viewtopic.php?t=9497
drzony commentedon Jul 22, 2020
@samguyer
By default on ESP32 Arduino task is pinned to core 1, so adding another task does not change anything (however as I've noticed before creating a task with higher priority helps a bit). The interrupt should be created on current core so that also should be good.
I've created a repo with my tests: https://github.com/drzony/FastLED-tests
It includes the code for running FastLED.show() on a separate task pinned to any core.
In case you are not using PlatformIO (I highly recommend it), it's available as an extension for VSCode and it contains everything that is required to work with it. When using it, just clone your FastLED into lib/ in my repo and you should be good to go.
samguyer commentedon Jul 22, 2020
@drzony I just pushed a version to my FastLED repo (not the main one) that changes the strategy for refilling the RMT buffer. The interrupt handler just records which channels (which strips) need attention, but the actual work is done outside the interrupt handler. I'd be interested to see if this approach improves the situation for you.
samguyer commentedon Jul 23, 2020
@drzony Actually, hold off using that code. I don't think it works correctly. But I think I'm getting closer to understanding what's going on in the interaction between FastLED and the WiFi subsystem.
zackees commentedon Aug 1, 2026
Closing — this thread ran through two distinct problems over 94 comments, and the RMT5 rewrite addresses both by design rather than by patch.
Problem 1 — "works at 7 strips, dead at 8"
@brycedjohnson and @jrhun both hit this, and @jrhun's reduced repro (comment out any one of eight
addLedscalls and it works again) was the key data point.The ESP32 has 8 RMT channels, but each non-DMA channel needs multiple memory blocks, so the on-chip RMT memory runs out well before the channel count does. The RMT4 driver assumed one channel per strip and fell off a cliff at the limit.
RMT5 doesn't make that assumption. From the driver's own README:
Strips are time-multiplexed across a pool of channels, so the strip count is no longer bounded by the hardware channel count. Memory is managed centrally, with the accounting documented per chip (ESP32-S3: 192 words on-chip; 96 words per non-DMA channel at 2× buffering, 144 at 3×; DMA channels consume zero on-chip words because they stream from DRAM).
Problem 2 — the WiFi interference this thread turned into
The second half — @drzony's single-frame glitches during TCP/MQTT traffic, and @samguyer instrumenting the refill interval and finding it stretch from ~9600 cycles to 13,000 right as TCP fired — is the same root cause as #771: network interrupts starving the RMT refill.
@drzony's analysis of why only one or two LEDs were affected rather than everything downstream was correct, and it's a genuinely subtle point worth preserving: each LED regenerates the signal for the next, and with a 50 µs reset the downstream pixels resynchronise. That's why a timing-sensitive serial protocol produced localised corruption, which had puzzled @samguyer.
Four things in RMT5 target exactly this:
NetworkDetectorraises the per-channel buffer from 2× to 3× when WiFi/BT/Ethernet is active@samguyer's last idea on the thread — "use the interrupt handler to signal to the user-level code to refill the RMT buffer" — is essentially the direction the driver ultimately took, moving work out of the ISR. He was on the right track before it stalled.
Practical notes
Thanks @jrhun for the minimal repro, @drzony for the reproducible test repo and the pixel-regeneration analysis, and @samguyer for the cycle-level instrumentation that identified the mechanism. If anyone still sees this on a current FastLED, please open a fresh issue with chip variant, IDF version, strip count and whether DMA is active — it would be a new finding against a rewritten driver.