r/FastLED • u/lorenzo_mancini • Jan 02 '25
Support Parallel LED output on ESP32S3 slower than ESP32
Hello! I'm working on a LED propeller display hobby project, using Arduino to write the software and FastLED to drive a strip of WS2813 LED. I have both a ESP32 and a ESP32S3 dev boards around and I'm comparing their performance.
ESP32 S3: ESP32-S3-WROOM-1
ESP32: ESP32-WROOM-32D
Arduino ESP32 core: https://github.com/espressif/arduino-esp32/releases/tag/2.0.17 (version 2.0.17)
FastLED: https://github.com/FastLED/FastLED/releases/tag/3.9.8 (version 3.9.8)
In order to squeeze the maximum performance out of the platform, I split the LED strip in 4 segments, to drive each one from a separate PIN.
To my surprise though, I'm getting way better performance from the plain ESP32, which is able to complete a full 20 iteration set of FastLED.show() in 14ms, while ESP32S3 does the same in 25ms.
I'm attaching a couple gists to reproduce this. You don't need to actually attach a LED strip in order to repeat the measurements, just upload and run:
ESP32: https://gist.github.com/lmancini/ce7432fd25ebfcef71a6310b71ee27c8
ESP32S3: https://gist.github.com/lmancini/6fde5819d0526b8d0a4e47091f4bfd67
I made sure to disable the max refresh rate for the test. Only the pin numbers change from one program to the other. I tried the recent overclocking #defines but they didn't help. Both CPUs run at 240Mhz.
I could just re-wire the strips to the ESP32... but I would really like to understand why the older board is faster than the newer one.
I don't really have experience in communication bus development, but I'm proficient in C and would gladly help getting this fixed in FastLED (of course, assuming this is a library issue and not my fault somehow). Thanks!
7
u/PsychoticSpoon Jan 03 '25
I would guess that it's a difference in RMT channels. FastLED on ESP32 family uses RMT to write to multiple LED strips in parallel. WS2812s take signals at 800 kilobaud and requires 24 bits per LED (8 per color channel). Your code is updating 18 LEDs 20 times, and 1000000 / 800000 * 24 * 18 * 20 = 10.8 ms, which with the additional overhead of your preparing seems in line with your 14 ms observation. It looks like on ESP32-S3, the RMT channels were restricted and half of them are dedicated to input and half to output (I don't have a better official source for this claim though). But my guess would be that FastLED on ESP32-S3 is writing to 2 of the strips in parallel, and then to the other 2, bumping the total time up to 25 ms.
5
u/ZachVorhies Zach Vorhies Jan 03 '25
It's RMT5.
Set this build flag and you'll be back at the performance you expect:
4
u/YetAnotherRobert Jan 03 '25
RMT on S3 is a bit weird, as PsychoticSpam describes. The leading contender peripherals for driving a ton of strips on S3 seem to be LCD and, just to get back to where we started, I2S.
This isn't FastLED, but it's by a (former?) FastLED contributor. Since you seem to have the ability to benchmark things easily, can you knock up a simlar test with this library and see how it does on S3 with a bunch of pins?
https://github.com/hpwit/I2SClockLessLedDriveresp32s3/tree/main
I'm not sure if the innovation is "drives 16 pins" or "drives N pins faster", so this may be a goose chase, but it also might be a lead on an integration exercise if it plays out for you.
I think the API is intended to be a FastLED hardware backend, but that's not actually mentioned. (Maybe it's more of a NeoPixelLib backend...these libs start to all look the same at some level of my memory.) I also won't die of shock if it doesn't work with Arduino 3 because it doesn't seem to have a large development community and it's possible it's not been updated since the Arduino3 breaking API changes hit. So if it seems totally broken, just be prepared to temporarily pin back to 2.x.
There's a procedural question if you're testing a useful measure, though. ISTR that show() now only blocks if it's waiting for the hardware. So timing that loop really only matters if you're cramming everything to the display as fast as you can instead of locking it to some fixed rate where a little jitter won't present as a stutter. If you lock the display to, say, 45fps, you may have some difference in the amount of inter-frame calculation youcan do, but the key question is, "is it enough?" Also, depending on your LEDs, you may be able to use the recent overclock modes and buy back any difference you're seeing here.
Finally, Zachees has been churning out the versions rapidly lately and the new ESP32 backend has been an area of active development. I've lost track of the FastLED4 and 3.9.x branching scheme, but it's entirely possible that you'll be asked to try a different branch/fork. Sounds like you have good tooling and skills to handle that, though.
Cool project, though. I'm happy to see discussions here that don't end in "use a common ground between the strip and the controller". :-)
2
u/ZachVorhies Zach Vorhies Jan 04 '25
Try the new 3.9.9 release that's submitted and will be available in a few hours. It also features a new I2S driver that should be much faster.