Skip to content

ESP32 RMT not working with WS2811 on 3.2.10 #835

Closed

Description

@brycedjohnson

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!

Activity

  1. jrhun commented on Jul 11, 2019

    @jrhun

    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.

    #include <FastLED.h>
    
    #define NUM_LEDS_PER_STRIP 20
    #define NUM_STRIPS 8
    
    CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP];
    
    void setup() {
      FastLED.addLeds<WS2812B, 27, GRB>(leds, 0 * NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP).setCorrection( TypicalSMD5050 );
      FastLED.addLeds<WS2812B, 14, GRB>(leds, 1 * NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP).setCorrection( TypicalSMD5050 );
      FastLED.addLeds<WS2812B, 12, GRB>(leds, 2 * NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP).setCorrection( TypicalSMD5050 );
      FastLED.addLeds<WS2812B, 13, GRB>(leds, 3 * NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP).setCorrection( TypicalSMD5050 );
      FastLED.addLeds<WS2812B, 26, GRB>(leds, 4 * NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP).setCorrection( TypicalSMD5050 );
      FastLED.addLeds<WS2812B, 25, GRB>(leds, 5 * NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP).setCorrection( TypicalSMD5050 );
      FastLED.addLeds<WS2812B, 33, GRB>(leds, 6 * NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP).setCorrection( TypicalSMD5050 );
      FastLED.addLeds<WS2812B, 32, GRB>(leds, 7 * NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP).setCorrection( TypicalSMD5050 );
      FastLED.setBrightness(32);
    
    }
    
    void loop() {
      static uint8_t hue = 0;
      for (int i = 0; i < NUM_STRIPS; i++) {
        for (int j = 0; j < NUM_LEDS_PER_STRIP; j++) {
          leds[(i * NUM_LEDS_PER_STRIP) + j] = CHSV((32 * i) + hue + j, 192, 255);
        }
      }
    
      hue++;
    
      LEDS.show();
      FastLED.delay(10);
    }
    

    Tested with FastLED 3.2.10 on esp32 doit devkit v1, with Arduino 1.8.9.

  2. samguyer commented on Jul 11, 2019

    @samguyer
    Contributor

    Hmmm. Sounds like I need to do some debugging!

  3. brycedjohnson commented on Jul 11, 2019

    @brycedjohnson
    Author

    Yes I was doing 8 strips as well. Never tried with less though.

  4. Nagymadar commented on Jul 15, 2019

    @Nagymadar

    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?

  5. samguyer commented on Jul 15, 2019

    @samguyer
    Contributor

    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.

  6. Nagymadar commented on Jul 15, 2019

    @Nagymadar

    Thanks a lot in advance.

  7. samguyer commented on Jul 18, 2019

    @samguyer
    Contributor

    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.

  8. jrhun commented on Jul 18, 2019

    @jrhun

    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.

  9. samguyer commented on Jul 18, 2019

    @samguyer
    Contributor

    @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

  10. Nagymadar commented on Jul 18, 2019

    @Nagymadar

    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.

  11. Nagymadar commented on Jul 22, 2019

    @Nagymadar

    Any progress? Can I help with testing?

  12. MartyMacGyver commented on Aug 1, 2019

    @MartyMacGyver
    Contributor

    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.h

    Where
    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.h

    Where
    #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_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)).


    Here's how the calculations differ:

      #define C_NS0(_NS)   (_NS * ((CLOCKLESS_FREQUENCY / 1000000L)  + 999)  / 1000)
      #define C_NS1(_NS) (((_NS * ((CLOCKLESS_FREQUENCY / 1000000L)) + 999)) / 1000)
    ....
      Serial.println(F_CPU);
      Serial.println(CLOCKLESS_FREQUENCY);
      Serial.println(C_NS0(10));
      Serial.println(C_NS0(100));
      Serial.println(C_NS0(1000));
      Serial.println(C_NS1(10));
      Serial.println(C_NS1(100));
      Serial.println(C_NS1(1000));
    

    We get:

    240000000
    240000000
    12
    123
    1239
    3
    24
    240
    

    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

  13. samguyer commented on Aug 1, 2019

    @samguyer
    Contributor

    @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?

  14. samguyer commented on Aug 1, 2019

    @samguyer
    Contributor

    Also: why is the ESP8266 support an issue here? The ESP32 code should affect it at all.

  15. MartyMacGyver commented on Aug 1, 2019

    @MartyMacGyver
    Contributor

    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

  16. 74 remaining items

  17. drzony commented on Jul 21, 2020

    @drzony
    Contributor

    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.

  18. samguyer commented on Jul 21, 2020

    @samguyer
    Contributor

    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

  19. drzony commented on Jul 22, 2020

    @drzony
    Contributor

    @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.

  20. samguyer commented on Jul 22, 2020

    @samguyer
    Contributor

    @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.

  21. samguyer commented on Jul 23, 2020

    @samguyer
    Contributor

    @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.

  22. added
    type: bug
    platform: esp32
    area: drivers
    status: stale
    status: triage
    on Apr 16, 2026
  23. zackees commented on Aug 1, 2026

    @zackees
    Member

    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:

    1. Double buffering — ping-pong refills, listed first in the README as "Eliminates Wi-Fi interference"
    2. Network-aware channel management — a NetworkDetector raises the per-channel buffer from 2× to 3× when WiFi/BT/Ethernet is active
    3. 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.)
    4. 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.

  24. moved this from Triage to Done in FastLED Trackeron Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: driversplatform: esp32status: stalestatus: triagetype: bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions