Giter Site home page Giter Site logo

bbulkow / fastled-idf Goto Github PK

View Code? Open in Web Editor NEW
160.0 15.0 40.0 711 KB

FastLED port to the ESP-IDF 4.0 development environment

Home Page: https://fastled.io/

License: MIT License

CMake 0.17% Makefile 0.06% C++ 84.28% C 15.49%
esp32 esp32-idf fastled fastled-library leds led-controller led-display esp-idf espressif freertos

fastled-idf's Introduction

FastLED-idf & Patterns

TL;DR

This port of FastLED 3.3 runs under the 4.x ESP-IDF development environment. Enjoy.

Updates: Aug, Sept 2020:

  • I2S hardware working and now default.
  • RMT interface well tested.
  • WS2812FX library ported and working.

There are some new tunables, and if you're also fighting glitches, you need to read components/FastLED-idf/ESP-IDF.md.

Note you must use the ESP-IDF environment, and the ESP-IDF build system. That's how the paths and whatnot are created.

Here is the link to the ESP-IDF getting started guide. https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/

Pull requests welcome.

Why we need FastLED-idf

The ESP32 is a pretty great SOC package. It has two cores, 240Mhz speed, a meg of DRAM ( sorta ), low power mode, wifi and bluetooth, and can be had in pre-built modules at prices between $24 ( Adafruit, Sparkfun ), $10 (Espressif-manufactured boards through Mauser and Digikey), or 'knock off' boards for $4 from AliExpress as of 2020.

If you're going to program this board, you might use Arduino. Although I love the concept of Arduino - and the amazing amount of libraries - the reality is the Arduino IDE is a mess, and the compile environment is "funky", that is, it's not really C - about my first minute in the IDE, I managed to write a perfectly valid C preprocessor directive that's illegal in Arduino.

Enter ESP-IDF, which is Espressif's RTOS for this platform. It's based on FreeRTOS, but they had to fork it for multiple cores. It's based on FreeRTOS 9, but has some of the work done later backported so it has a few of the FreeRTOS 10 functions, apparently. Development seems vibrant, and they use the stock GCC 8.0 compiler with no strange overlays.

There are a TON of useful modules included with ESP-IDF. Notably, nghttp server, mdns, https servers, websockets, json, mqtt, etc etc.

What I tend to do with embedded systems is blink LEDs! Sure, there's other fun stuff, but blinking LEDs is pretty good. The included ledc module in ESP-IDF is only for changing the duty cycle and brightness, it doesn't control color-controlled LEDs like the WS8211.

Thus, we need FastLED

WS8212FX

Playing around, there are "a lot of nice libraries on FastLED", but each and every one of them requires porting. At least, now there's a single one to start with. See the underlying component, and use it or not. If you don't want it, just don't bring that component over into your project.

I2S vs RMT

At first, I focused the port on RMT, as it seemed the hardware everyone talked about. As you see below, the RMT interface even has a Espressif provided example! Thus the journey of getting the MEM_BUFS code working and soak up the interrupt latency.

But, the I2S hardware is almost certainly better than RMT. It has more parallelism, and less code, and seems enormously resistant to glitches.

The default is I2S, see below.

TL;DR about this repo

As with any ESP-IDF project, there is a sdkconfig file. It contains things that might or might not be correct for your ESP32. I've checked in a version that runs at 240Mhz, runs both cores, uses 40Mhz 4MB DIO Flash, auto-selects the frequency of the clock, and only runs on Rev1 hardware, and has turned off things like memory poisoning.

Because I'm trying to support different versions of esp-idf, and the sdkconfig files seem contradictory, the one in this repo matches "current" master, with a 4.0, 4.1, and 4.2 version. If you'd like to test my starting point, copy the correct one over to sdkconfig and give it a try.

For master, either use the standard sdkconfig or build your own. Remove this one, and idf.py menuconfig, and set whatever paramenters you need. There is nothing in this library that's specific to any particular version.

I tend to set the compiler into -O2 mode.

a note about level shifting

I've now read a lot of reddit posts about people saying "but I hook LEDs up to an Arudino and it works, but the ESP32 is flakey". Why yes. That's because ESP32 pins are 3.3v, Arduino pins are 5v, and LED signal levels are 5v. Either you get lucky with the LEDs you have, or you go find out about level shifting.

Adafruit's page on level shifting is perfectly good, although you don't need a breakout board, and using a 4-pin package isn't so cool as an 8 pin package, since an ESP32 can drive 8 channels. That's SN74HCT245N , and they're to be had from Digikey at $0.60. Read the datasheet carefully and get the direction and the enable pins right - they can't float.

Use of ESP32 I2S hardware for 3 wire LEDs

this is really good

Mid 2019, The following post showed up on reddit: https://www.reddit.com/r/FastLED/comments/bjq0sm/new_24way_parallel_driver_for_esp32/ which announced using I2S hardware instead of RMT hardware that had been used in the past.

I2S hardware is aimed to generate sound, but it can also be configured (as it is in this case) to provide a parallel bus interface. It is best understood by reading the Espressif documentation.

https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/i2s.html

What you'll see is there's 12 parallel pins that can be supported with each hardware module, and frankly if you need more than 12 way parallelism I worry about you. That should be enough for a module of this size.

Which to use?

From Sam's post: WARNINGS and LIMITATIONS

-- All strips must use the same clockless chip (e.g., WS2812). Due to the way the I2S peripheral works, it would be much more complicated to drive strips that have different timing parameters, so we punted on it. If you need to use multiple strips with different chips, use the default RMT-base driver.

-- Yves has written some mad code to compute the various clock dividers, so that the output is timing-accurate. If you see timing problems, however, let us know.

-- This is new software. We tested it on our machines. If you find bugs or other issues, please let us know!

Of course, new in 2019 is not so new now :-).

I have set the default to I2S, because it ran all of my torture tests immediately and flawlessly. I am somewhat unclear why it's so good. It's hard to suss out how deep the DMA queue is at a glance in time, and it seems that the interupt handler might be running at a different priority. I don't know if I can argue that it's doing less work. Since it's written for audio, there might be more attention paid to the driver.

Obviously, if you need the I2S hardware for something else, you'll want RMT, but there are two I2S components on an ESP32 and one on a ESP32-S2. The other uses of I2S include ( according to the documentation ) LCD master transmitting mode, camera slave receiving mode, and ADC / DAC mode ( feed directly to the DAC for output ).

You can still fall back to RMT, see below.

the code is a little inscrutable

The I2S code uses the underlying hardware interface ( ll ) fast and furious. For this reason, nothing you see in the official documentation about I2S matches what the code is written to. Just to beware.

Use of ESP32 RMT hardware for 3 wire LEDs

Cookbook - enable it

There's a #define at the top of fastled.h which chooses I2S or RMT. Switch to RMT by commenting out.

Comment back in "platforms/esp/32/clockless_rmt_esp32.cpp" from components\FastLED-idf\CMakeLists.txt

To compile the default I2S, you need to remove the RMT file from the compile because you don't want to waste RAM, and there are colliding symbols. You can't use both because there's no current way to define which strings use which hardware. If there was a new interface, you'd fix the colliding symbols and enable both.

background

The ESP32 has an interesting module, called RMT. It's a module that's meant to make arbitrary waveforms on pins, without having to bang each pin at the right time. While it was made for IR Remote Control devices, it works great for LEDs, and appears to be better than the PWM hardware.

There are 8 channels, which tends to match well with the the desires of most people for LED control. 8 channels is basically still a ton of LEDs, even if the FastLED ESP32 module is even fancier and multiplexes the use of these channels.

With the 800k WS8211 and similar that are now common, the end result of the math and the buffers is you need to fill the RMT hardware buffer about every 35microseconds. Even with an RTOS, it seems this is problematic, using C code. For this reason, the default settings are to use two "memory buffers", which double the depth of the RMT hardware buffer, and means that interrupt jitter of up to about 60us can be absorbed without visual artifact. However, this means getting hardware accelleration with only 4 channels instead of 8. This can be changed back to 8.

Please see the lengthy discussion under components/FastLED-idf/ESP-IDF.md to enable some tracing to find your timers, and similar.

The FastLED ESP32 RMT use has two modes: one which uses the "driver", and one which doesn't, and claims to be more efficient due to when it's converting between LED RGB and not.

The ESP-IDF driver does support a translate mode which would be the same as what the internal mode does.

Four wire LEDs ( APA102 and similar )

Interestingly, four wire LEDs can't use the RMT interface, because the clock and data lines have to be controled together ( duh ), and the RMT interface doesn't do that. What does do that is the SPI interface, and I don't think I've wired that up.

The I2S interface, on the other hand, appears synchronized. I think you could write an APA102 driver using I2S and it would be fast and happy.

However, simply doing hardware SPI using the single SPI driver should be good enough. Work to do.

Since hardware banging is used ( that's the big ugly warning ), these LEDs are very likely far slower, and probably do not respond to parallelism the same way.

I have pulled in enough of the HAL for the APA102 code to compile, but I don't know if it works, since I don't have any four-wire LEDs around. Since it's very much a different code path, I'm not going to make promises until someone tries it.

async mode

The right way to use a system like this is with some form of async mode, where the CPU is loading and managing the RMT buffer(s), but then goes off to do other works while that's happening. This would allow much better multi-channel work, because the CPU could fill one channel, then go off and fill the next channel, etc. For that, you'd have to use the LastLED async interfaces.

It turns out this all works just peachy, it's just that the FastLED interface is a little peculiar. If you see the THREADING document in this directory, you'll see that this port is enabling multi-channel mode when using 3-wire LEDs, which means you change all the pixels, and when you call FastLED.show(), they'll all bang on the RMT hardware, and use very little main CPU.

It would be nicer if FastLED had some sort of Async mode, but that's not really the Arduino way, and this code is meant for arduino. Arduino doesn't have threads of control or message queues or anything like that.

A bit about esp-idf

ESP-IDF, in its new 4.x incarnation, has moved entirely to a cmake infrastructure. It creates a couple of key files at every level: CMakeLists.txt , Kconfig.

The CMakeLists.txt is where elements like which directories have source and includes live. Essentially, these define your projects.

The Kconfig files allow you to create variables that show up in MenuConfig. When you're building a new project, what you do is run idf.py menuconfig and that allows you to set key variables, like whether you want to bit-bang or use optimized hardware, which cores to run on, etc.

One element of esp-idf that took a while to cotton onto is that it doesn't build a single binary then you build your program and link against it. Since there are so many interdependancies - it's an RTOS, right - what really happens is when you build your code, you build everything in the standard set too. This means compiles are really long because you're rebuilding the entire system every time.

There's no way to remove components you're not using. Don't want to compile in HTTPS server? Tough. The menuconfig system allows you to not run it, but you can't not compile it without going in and doing surgery.

ESP-IDF versions

First of all, if you're changing versions, you have to be quite careful. The only foolproof method I've found is a brand new clone, a new install.sh, manually removing the project's build directory, and using the defult sdkconfig with a menuconfig, setting the parameters you need within this version.

Within menuconfig, I tend to use the following settings. Minimum required silicon rev to 1, because there are speed workarounds at Rev0 that get compiled in. I change the compiler options to -O2 instead of -Os or -Og. Default flash size to 4M, because all the devices I have are 4G.

A short plug for Microsoft's WSL

Although ESP-IDF v4.x has apparently made great strides in working with VS and Platform.io, they still suggest you use cmake in windows. This avoids the elephant which is WSL - Windows Service for Linux. I use that exclusively for this project, and all of the instructions on how to install and use ESP-IDF for Linux work great, including flashing devices over USB. Serial devices are mounted as "/dev/ttySX", where X is the COMM number in the device. Really works nicely.

History

The other FastLED-idf

It appears that set of code was an earlier version of FastLED, and probably only still works with ESP-IDF 3.x. There was a major update to ESP-IDF, a new build system, lots of submodule updates, cleaned up headers and names, which seem to be all for the better - but with lots of breaking changes.

Thus, updating both, and using eskrab's version as a template, I attempt to have a running version of FastLED with the ESP-IDF 4.0 development environment

ESP-IDF already has a LED library

Not really. There is an included 'ledc' library, which simply changes the duty cycle on a pin using the RMT interface. It doesn't do pixel color control. It can be an example of using the RMT system, that's it.

There is an example of LED control, using the RMT interface directly. If you just want to it like that, without all the cool stuff in FastLED, be everyone's guest!

Interestingly, the LED library uses RMT, has glitches just like the older versions of RMT that FastLED had, and don't support I2S which is far more stable.

I did reach out to Espressif. I think they should include or have a FastLED port. In their forums, they said they don't intend to do anything like that.

SamGuyer's fork

When I started on this journey, I read a series of Reddit posts saying that Sam's FastLED port was the best for ESP32. It used RMT by default, and it still glitched a lot, which put me down the path of doing major work on the RMT code and finding the fundamental issue which he backported.

The code for the I2S driver, however, just came over peachy, and once I enabled it, the entire system was far more stable.

Kudos to Sam for getting the code to a better point, where it was amenable to the optimizations I did.

https://github.com/samguyer/FastLED

TODO: use the rmt_translator_init function

There is no reason to have ones own ISR. The ESP-IDF system has a 'translator', which is a function which will take pixel bytes to RMT buffers. This is the structure of the code already, so the entire ISR can be removed. This functionality is not in the Arduino implementation of RMT, which is why its not used here yet.

However, now that one has the I2S code, I would think improving the RMT code is a low priority.

Updating

This package basically depends on three packages: two that you pull in, and the fact that you've got to use the version that works with your intended version of esp-idf. Those two packages are FastLED, and also arduino-esp32, since FastLED is using the arduino interfaces.

It would have been possible to just have at the FastLED code and nuke the portions that are Arduino-ish, however, that removes the obvious benefit of eventually being able to update FastLED.

As a starting point, then I've taken the choice of keeping the libraries as unmodified as possible.

FastLED

Drop this into the components/FastLED-idf directory. Now, it might have been cleaner to create a subdirectory with nothing but the FastLED-source code, this could be an organizational change the future.

Arduino-esp32

You need a few of the HAL files. Please update these in the subdirectory hal. Don't forget to close the pod bay doors.

Timing and speed

On an ESP32 running at 240Mhz, I was able to time 40 pixels at 1.2 milliseconds. I timed showLeds() at 3.0 milliseconds at 100 LEDs.

However, if you use more than one controller ( see the THREADING document ), three different controllers each will do 100 LEDs in 3 milliseconds. I have tested this with 1, 3, and 6 controllers. They all take the same amount of time.

If 30 milliseconds makes 30fps, then you should be able to do 1000 pixels on one of the two cores, and still, potentially, have the ability to do some extra work, because you've got the other CPU.

I have not determined if this is using the RMT interface, which would mean we could use an async internal interface. The timing, however, is very solid.

Use(age) notes

What I like about using FreeRTOS and a more interesting development environment is you should be able to use more of the CPU for other things. Essentially, you should be able to have the RMT system feeding itself, which then allows the main CPU to be updating the arrays of colors, and multiple channels to be doing the right thing all at the same time.

However, really being multi-core would mean having a locking semantic around the color array, or double buffering. FastLED doesn't seem to really think that way, rightfully so.

Licensing

FastLED is MIT license.

I intend my portions to be MIT license. AKA the don't sue me license.

However, the Espressif HAL code is LGPL. Mostly, these are used as headers, not as code itself. There's very little of value there. If LGPL bothers you, I would propose a quick rewrite of those files, and submit a pull request that would be under MIT license.

I am honestly not sure what happens to LGPL in this case. It's a component in an embedded system, which is morally a library, but it is clearly very statically linked and in the "application", which I think would generate a copy-left. OTOH, that would also mean that ESP-IDF is all GPL and copy-left, and Espressif doesn't seem to think so ... whatever.

I don't intend to make any money off this, don't charge people, and do not intend the use for commercial art projects, so the use is safe for me. But don't say I didn't warn you.

Gotchas and Todos

ESP32 define

I banged my head for a few hours on how to define ESP32, which is needed by FastLED to choose its platform. This should be doable in the CMakeLists.txt, but when I followed the instructions, I got an error about the command not being scriptable. Thus, to move things along, I define-ed at the top of the FastLED.h file.

Someone please fix that!

lots of make threads makes dev hard

This is just a whine about esp-idf.

It seems idf.py build uses cores+2. That means when you're actually building your component, you're compiling all the other esp idf components, and you'll see a lot of stuff compile then finally what you want.

However, in recent versions of ESP-IDF, they've fixed a lot of things about the build system, so we really shouldn't complain. Builds are now really fast, and build just builds what's not touched.

Thanks, espressif!

micros

Defined in arduino, maps to esp_timer_get_time() . There is an implementation of this in esp32-hal-misc.c, but no definition, because you are meant to supply a function that is defined by Arduino.

I have defined these functions in esp32-hal.h out of a lack of other places to put them. And, wouldn't it be better to use defines for these instead of functions???

port access for GPIO banging

The FastLED code is fast because it doesn't call digital read and digital write, it instead grabs the ports and ors directly into them. This is done with digitalPinToBitMask and digitalPinToPort. Once you have the port, and you have the mask, bang, you can go to town.

The esp-idf code supports the usual set of function calls to bang bits, and they include if statements, math, and a huge check to see if your pin number is right, inside every freaking inner loop. No wonder why a sane person would circumvent it. However, the ESP32 is also running at 240Mhz instead of 16Mhz, so performance optimizations will certainly matter less.

Looking at the eshkrab FastLED port, it appears that person just pulled in most of the registers, and has run with it.

HOWEVER, what's more interesting is the more recent FastLED code has an implementation of everything correctly under platforms///fastpin_esp32.h. There's a template there with all the right mojo. In a q-and-a section, it says that the PIN class is unused these days, and only FastPin is used. FastPin still uses 'digitalPinToPort', but has a #define in case those functions don't exist.

The following github issue is instructive. FastLED/FastLED#766

It in fact says that the FASTLED_NO_PINMAP is precisely to be used in ports where there is no Arduino. That's me! So let's go set that and move along to figuring out how to get the FastPins working.

GPIO defined not found - get the hal

Best current guess. There is an arduino add-only library called "Arduino_GPIO", which has the same basic structure, and that's what's being used to gain access to the core register pointers and such.

Essentially, this has to be re-written, because GPIO in that way doesn't exist.

A few words about bitbanging here.

There appears to be 4 32-bit values. They are w1tc ( clear ) and w1ts ( set ). When you want to write a 1, you set the correct values in w1ts, and when you want to clear, you set 1 to the values you want to clear in w1tc. Since there are 40 pins, there are two pairs of these.

Explained here: https://esp32.com/viewtopic.php?t=1987 . And noted that perhaps you can only set one value at a time, and it makes the system atomic, where if you try to read, mask, write in a RTOS / multicore case, you'll often hurt yourself. No taking spinlocks in this case, which is great.

There are also two "out" values. Oddly, there are both the GPIO.out, and GPIO.out.value. Unclear why. Reading the code naively, it looks like almost a bug. How could it be that the high pins have such a different name?

Another intereting post on the topic: https://www.esp32.com/viewtopic.php?t=1595 . This points to raw speeds being in the 4mhz / 10mhz range, and says "use the RMT interface". It also has questions about whether you need to or or set. The consensus seems to be that you don't need to do that, and you shoudn't need to disable interrupts either, because these actions are atomic.

Now, let's figure out the best way to adapt those to ESP-IDF.

https://docs.espressif.com/projects/esp-idf/en/v4.0/api-reference/peripherals/gpio.html

IT looks like there are defines for these values in ESP-IDF, so you really just need to find the places these are defined and change the names to GPIO_OUT_W1TS_REG , and GPIO_OUT_REG etc etc

soc/gpio_reg.h --- examples/peripherals/spi_slave or maybe just driver/gpio.h?

WRITE_PERI_REG(GPIO_OUT_W1TS_REG, 1 << GPIO_HANDSHAKE)

Looks like if you grab "gpio.h", it'll include what you need. For full information, it was bugging me where this structure is. It's in: soc/esp32/include/soc/gpio_struct.h . Which I also think is pulled in with gpio.h, or more correctly driver/gpio.h as below.

Hold up! It looks like driver/gpio.c uses the same exact GPIO. name. Is this a namespace or something? Should I just start including the same files gpio.c does?

#include <esp_types.h>
#include "esp_err.h"
#include "freertos/FreeRTOS.h"
#include "freertos/xtensa_api.h"
#include "driver/gpio.h"
#include "driver/rtc_io.h"
#include "soc/soc.h"
#include "soc/gpio_periph.h"
#include "esp_log.h"
#include "esp_ipc.h"

Let's start with:

#include <esp_types.h>
#include "esp_err.h"
#include "freertos/FreeRTOS.h"
#include "freertos/xtensa_api.h"
#include "driver/gpio.h"
#include "soc/gpio_periph.h"

Yay!

Note: what's up with registering the driver? I should, right? Make sure that's done in menuconfig? Doen't seem to be. There are no settings anywhere in the menuconfig regarding gpio. Should probably look at the examples to see if I have to enable the ISR or something.

GCC 8 memcpy and memmove into complex structures

/mnt/c/Users/bbulk/dev/esp/FastLED-idf/components/FastLED-idf/colorutils.h:455:69: error: 'void* memmove(void*, const void*, size_t)' writing to an object of type 'struct CHSV' with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Werror=class-memaccess]
         memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries));

Files involved are:

FastLED.h
bitswap.h
controller.cpp
colorutils.h 

( Note: bitswap.cpp is rather inscrutable, since it points to a page that no longer exists. It would be really nice to know what it is transposing, or shifting, AKA, what the actual function is intended to do, since the code itself is not readable without a roadmap. )

The offending code is here:

    CHSVPalette16( const CHSVPalette16& rhs)
    {
        memmove8( &(entries[0]), &(rhs.entries[0]), sizeof( entries));
    }

and I think is an unnessary and unsafe optimization. It would be shocking on this processor, with GCC8+, that the memmove8 optimization is sane. This is a straight-up initialization, and the code should probably be simplified to do the simple thing.

This particular warning can be removed in a single file through the following pattern:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"

https://stackoverflow.com/questions/3378560/how-to-disable-gcc-warnings-for-a-few-lines-of-code

After looking a bit, it doesn't seem unreasonable to remove all the memmoves and turn them into loops. It's been done in other places of the code. Otherwise, one could say "IF GCC8" or something similar, because I bet it really does matter on smaller systems. Maybe even on this one.

In the upstream code of FastLED, there is an introduction of a void * cast in these two places. That's the other way of doing it, and the code does "promise" that the classes in question can be memcpy'd. If someone re-ports the code, they could fix this.

Don't use C

Had a main.c , and FastLED.h includes nothing but C++. Therefore, all the source files that include FastLED have to be using the C++ compiler, and ESP-IDF has the standard rules for using C for C and CPP for CPP because it's not like they are subsets or something.

CXX_STUFF

There is some really scary code about guards. It is defined if ESP32, and seems to override the way the compiler executes a certain kind of guard. I've turned that off, because I think we should probably trust esp-idf to do the right and best thing for that

pulled in too much of the hal

In order to get 4-wire LEDs compiling, it's necessary to pull in the HAL gpio.c . Just to get one lousy function - pinMode. I probably should have simply had the function call gpio_set_direction(), which is the esp_idf function, directly. If you have a 4-wire system, I left a breadcrumb in the fastpin_esp32 directory. If the alternate code works, then you can take the gpio.c out of the hal compile.

interesting instability in RMT initialization

The code in ESP-IDF seems to really like using the pattern of having a macro for a default constructor. In the case of initializing the RMT structure, if I did it "by hand" and used the -O2 compile option, I got instability. The code is now written to do different things in different versions.

issues regarding ESP-IDF 4.1 and private interrupt handler

The underlying RMT code in ESP-IDF changed fairly radically between 4.0, 4.1, 4.2, and further. Specifically, the 4.1 code introduces the rmt_ll layer, but also initializes the structures used by _set_tx_thr_intr_en to set values in the chip only when the ESP-IDF interrupt handler is registered. This is resolved in 4.2, but in order to support 4.0, 4.1, and 4.2, I've put shadow versions of those functions. There are only three, so it's not a big deal.

using mRMT_channel

The definition of the RMT system states that if you're using a buffer size of greater than 1 MEM_BLOCK, one must not use all the RMT channels. Thus, unlike other similar code in other systems, there are 8 channels and 8 rmt channels, but because we support MEM_BLOCK, the number of channels is limited by the MEM_BLOCKs, and it's important to use mRMT_channel, which is the underlying RMT channel in every case.

message about no hardware SPI pins defined

It's true! There are no hardware SPI pins defined. SPI is used for 4-wire LEDs, where you have to synchronize the clock and data.

If you have 3-wire LEDs, you'll be using the RMT system, which is super fast anyway.

The upstream code doesn't seem to use SPI on ESP32 either, so that's just a big hairy todo, and don't worry overmuch.

fastled-idf's People

Contributors

bbulkow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fastled-idf's Issues

ESP-IDF built-in driver doesn't work right

In release versions 4.1, 4.2, and master, the system driver is enabled by default, because the code doesn't crash.

However, it also doesn't work. The colors are terribly wrong, so it seems the conversion going into ESP-IDF must be bad, or the bit rate is bad, or something.

First test will be to see if the build-in interrupt handler at least is working under the later releases just so something works, then to go after the actual flaw causing the driver to not work.

More than one channel doesn't work with mem_blocks_num

If you use the default code which uses mem_blocks_num of 2 ( or increase it further ), ESP-IDF demands that you skip channels. For example, if you use channel 0 with 2 memblocks, then you must skip channel 1 because its memory is already in use.

Until this issue is resolved, you can use one LED strip with greater mem_blocks, or you can use a mem_blocks_num of 1 and multiple strips. Looking at a fix over the next few days, pull requests welcome.

Thanks @samguyer for bringing this up.

Implementing FastLED-idf with espressif esp-homekit-sdk

Hello,

I am trying to make a firmware (based on example code from espressif's homekit SDK) for a board that uses homekit to control WS2812B lights. While trying to add the FastLed component to the lightbulb example, a ton of warnings and errors occur. I have attached a build log (the output of idf.py build) and the modified example. Can you please tell me what I am doing wrong and how I could fix it?

This is on a MacBook Pro running 11.2.1 with idf version ESP-IDF v4.4-dev-479-g1067b2870.

(I have removed the build folder to due github upload size limitation, please ask if I need to provide it)

build_log.txt
ledstrip.zip

Compiling the code as committed fails

I am using esp-idf 4.3 and cloned the repo and tried to compile the committed code. However i am getting lots of error messages all relating to the fastLED component. See below
../components/FastLED-idf/FastLED.h:263:113: note: template argument deduction/substitution failed:
../components/FastLED-idf/FastLED.h:273:131: note: candidate expects 3 arguments, 4 provided
case SK9822: { static SK9822Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER> c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); }
^
../components/FastLED-idf/FastLED.h:313:25: note: candidate: 'template<template<unsigned char DATA_PIN, EOrder RGB_ORDER> class CHIPSET, unsigned char DATA_PIN, EOrder RGB_ORDER> static CLEDController& CFastLED::addLeds(CRGB*, int, int)'
static CLEDController &addLeds(struct CRGB data, int nLedsOrOffset, int nLedsIfOffset = 0) {
^~~~~~~
../components/FastLED-idf/FastLED.h:313:25: note: template argument deduction/substitution failed:
../components/FastLED-idf/FastLED.h:273:131: note: candidate expects 3 arguments, 4 provided
case SK9822: { static SK9822Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER> c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); }
^
../components/FastLED-idf/FastLED.h:319:25: note: candidate: 'template<template<unsigned char DATA_PIN, EOrder RGB_ORDER> class CHIPSET, unsigned char DATA_PIN> static CLEDController& CFastLED::addLeds(CRGB
, int, int)'
static CLEDController &addLeds(struct CRGB data, int nLedsOrOffset, int nLedsIfOffset = 0) {
^~~~~~~
../components/FastLED-idf/FastLED.h:319:25: note: template argument deduction/substitution failed:
../components/FastLED-idf/FastLED.h:273:131: note: candidate expects 3 arguments, 4 provided
case SK9822: { static SK9822Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER> c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); }
^
../components/FastLED-idf/FastLED.h:325:25: note: candidate: 'template<template class CHIPSET, unsigned char DATA_PIN> static CLEDController& CFastLED::addLeds(CRGB
, int, int)'
static CLEDController &addLeds(struct CRGB data, int nLedsOrOffset, int nLedsIfOffset = 0) {
^~~~~~~
../components/FastLED-idf/FastLED.h:325:25: note: template argument deduction/substitution failed:
../components/FastLED-idf/FastLED.h:273:131: note: candidate expects 3 arguments, 4 provided
case SK9822: { static SK9822Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER> c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); }
^
../components/FastLED-idf/FastLED.h:369:25: note: candidate: 'template<template class CHIPSET, EOrder RGB_ORDER> static CLEDController& CFastLED::addLeds(CRGB
, int, int)'
static CLEDController &addLeds(struct CRGB data, int nLedsOrOffset, int nLedsIfOffset = 0) {
^~~~~~~
../components/FastLED-idf/FastLED.h:369:25: note: template argument deduction/substitution failed:
../components/FastLED-idf/FastLED.h:273:131: note: candidate expects 3 arguments, 4 provided
case SK9822: { static SK9822Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER> c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); }
^
../components/FastLED-idf/FastLED.h:375:25: note: candidate: 'template<template class CHIPSET> static CLEDController& CFastLED::addLeds(CRGB
, int, int)'
static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
^~~~~~~
../components/FastLED-idf/FastLED.h:375:25: note: template argument deduction/substitution failed:
../components/FastLED-idf/FastLED.h:273:131: note: candidate expects 3 arguments, 4 provided
case SK9822: { static SK9822Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER> c; return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset); }
^
ninja: build stopped: subcommand failed.
ninja failed with exit code 1

This there an easy way to get round this error?

ESP32C3 Compatibility

I am pretty well versed in the esp-idf, but I was wondering if I could get some direction on getting this to work with an esp32C3? I am looking at potentially adding the c3 to the platforms.

vTaskDelay(pdMS_TO_TICKS(9)) is zero

I'm writing this because I've wasted several hours debugging and maybe someone else can avoid my pain.

I have a nice sample program which breaks above 100fps. The root cause is vTaskDelay(pdMS_TO_TICKS(10)) delays for 10ms but vTaskDelay(pdMS_TO_TICKS(9)) delays for 0ms!

pdMS_TO_TICKS is just a nice macro to avoid writing vTaskDelay(ms * 1000 / portTICK_PERIOD_MS) which might have helped clue me into this earlier.

What's the default TICK_PERIOD_MS? well that depends on configTICKRATE_HZ which defaults to 100 not allowing granularity below 10ms!

So if your program breaks when you try to increase fps beyornd 100 or with a delay of 9ms 8ms 7ms 6ms 5ms 4ms 3ms 2ms 1ms but not 10ms this might be why.

The solution?

Either increase configTICKRATE_HZ (under menuconfig -> Component config โ†’ FreeRTOS -> Tick Rate (HZ)) to 1000 or change to using the busy wait ets_delay_us() (defined in rom/ets_sys.h)

esp-idf v4.2 rmt_set_tx_thr_intr_en() panic

Hi @bbulkow, thanks for this great port. Cloning this repo fresh, copying the sdkconfig.4-1 to sdkconfig, and running the example against esp-idf v4.1 results in an rmt_set_tx_thr_intr_en() panic as described on this esp-idf issue (stacktrace copied below). I understand this is an issue introduced in esp-idf v4.1 as you discussed on this other esp-idf issue.

I'm just wondering, what would you suggest users of your fork to do in this situation? It's somewhat difficult to follow where this interrupt handler issue is headed and whether it would be solved by the espressif team, or if your port needs to address it. Should we just stick to v4.0 for now? I have some ota over ble bugs that were fixed in 4.2 and I'm looking to upgrade, but this is the one issue holding me up.

Thanks again!

EDIT: What I'm mainly asking is if there is a way to use fastled with esp-idf 4.2, whether that be this library or not. I was having trouble getting arduino-esp32 to run again esp-idf 4.2 which is why I moved from using the main FastLED library to this port so I could ditch arduino-esp32 entirely. But now there's this RMT issue. So if there is another port or approach to getting fastled and esp-idf to play nicely together, I'm all ears!

 entering app main, call add leds
 set max power
create task for led blinking
W (384) FastLED: controller init
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC      : 0x400d55a0  PS      : 0x00060833  A0      : 0x800d4818  A1      : 0x3ffaf8a0
0x400d55a0: rmt_set_tx_thr_intr_en at /Users/drewandre/esp/esp-idf/components/driver/rmt.c:389 (discriminator 2)

A2      : 0x00000000  A3      : 0x3ffb1390  A4      : 0x00000020  A5      : 0x3ffb1390
A6      : 0x000000b0  A7      : 0x00000000  A8      : 0x00000034  A9      : 0x00000000
A10     : 0x00000001  A11     : 0x00009470  A12     : 0x3ff560b0  A13     : 0xefffffff
A14     : 0xfff7ffff  A15     : 0xffffffbf  SAR     : 0x00000020  EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xfffffffd

ELF file SHA256: 005f4b4fdb53c297

Backtrace: 0x400d559d:0x3ffaf8a0 0x400d4815:0x3ffaf8d0 0x4008294d:0x3ffaf910 0x400d424f:0x3ffaf940 0x400d4641:0x3ffaf9a0 0x400d3b56:0x3ffaf9e0 0x400d1e54:0x3ffafa10
0x400d559d: rmt_ll_set_tx_limit at /Users/drewandre/esp/esp-idf/components/soc/esp32/include/hal/rmt_ll.h:177 (discriminator 2)
 (inlined by) rmt_set_tx_thr_intr_en at /Users/drewandre/esp/esp-idf/components/driver/rmt.c:389 (discriminator 2)

0x400d4815: _ZN18ESP32RMTController4initEv$part$2 at /Users/drewandre/Downloads/my-test-project/build/../components/FastLED-idf/platforms/esp/32/clockless_rmt_esp32.cpp:119

0x4008294d: ESP32RMTController::showPixels() at /Users/drewandre/Downloads/my-test-project/build/../components/FastLED-idf/platforms/esp/32/clockless_rmt_esp32.cpp:92
 (inlined by) ESP32RMTController::showPixels() at /Users/drewandre/Downloads/my-test-project/build/../components/FastLED-idf/platforms/esp/32/clockless_rmt_esp32.cpp:147

0x400d424f: CPixelLEDController<(EOrder)10, 1, 4294967295u>::show(CRGB const*, int, CRGB) at /Users/drewandre/Downloads/my-test-project/build/../components/FastLED-idf/platforms/esp/32/clockless_rmt_esp32.h:359
 (inlined by) CPixelLEDController<(EOrder)10, 1, 4294967295u>::show(CRGB const*, int, CRGB) at /Users/drewandre/Downloads/my-test-project/build/../components/FastLED-idf/controller.h:408

0x400d4641: CFastLED::show(unsigned char) at /Users/drewandre/Downloads/my-test-project/build/../components/FastLED-idf/controller.h:90
 (inlined by) CFastLED::show(unsigned char) at /Users/drewandre/Downloads/my-test-project/build/../components/FastLED-idf/FastLED.cpp:59

0x400d3b56: _fastfade_cb(void*) at /Users/drewandre/Downloads/my-test-project/build/../components/FastLED-idf/FastLED.h:506
 (inlined by) _fastfade_cb at /Users/drewandre/Downloads/my-test-project/build/../main/main.cpp:103

0x400d1e54: timer_process_alarm at /Users/drewandre/esp/esp-idf/components/esp_common/src/esp_timer.c:306
 (inlined by) timer_task at /Users/drewandre/esp/esp-idf/components/esp_common/src/esp_timer.c:327


Rebooting...

Build error "RMT_DEFAULT_CONFIG_TX" not declared.

I am getting the build error as stated in snippet below. I am using esp-idf v4.0. Does anyone have any ideas what might be wrong here? I am trying to build the example, but I am getting the same problem when I am trying to incoperate FastLED-idf to my project.

[2/8] Building CXX object esp-idf/FastLED-idf/CMakeFiles/__idf_FastLED-idf.dir/platforms/esp/32/clockless_rmt_esp32.cpp.obj
FAILED: esp-idf/FastLED-idf/CMakeFiles/__idf_FastLED-idf.dir/platforms/esp/32/clockless_rmt_esp32.cpp.obj 
/Users/jacobandersson/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++   -Iconfig -I../components/FastLED-idf -I../components/FastLED-idf/hal -I/Users/jacobandersson/esp/esp-idf/components/newlib/platform_include -I/Users/jacobandersson/esp/esp-idf/components/freertos/include -I/Users/jacobandersson/esp/esp-idf/components/heap/include -I/Users/jacobandersson/esp/esp-idf/components/log/include -I/Users/jacobandersson/esp/esp-idf/components/soc/esp32/include -I/Users/jacobandersson/esp/esp-idf/components/soc/include -I/Users/jacobandersson/esp/esp-idf/components/esp_rom/include -I/Users/jacobandersson/esp/esp-idf/components/esp_common/include -I/Users/jacobandersson/esp/esp-idf/components/xtensa/include -I/Users/jacobandersson/esp/esp-idf/components/xtensa/esp32/include -I/Users/jacobandersson/esp/esp-idf/components/esp32/include -I/Users/jacobandersson/esp/esp-idf/components/driver/include -I/Users/jacobandersson/esp/esp-idf/components/esp_ringbuf/include -I/Users/jacobandersson/esp/esp-idf/components/esp_event/include -I/Users/jacobandersson/esp/esp-idf/components/tcpip_adapter/include -I/Users/jacobandersson/esp/esp-idf/components/lwip/include/apps -I/Users/jacobandersson/esp/esp-idf/components/lwip/include/apps/sntp -I/Users/jacobandersson/esp/esp-idf/components/lwip/lwip/src/include -I/Users/jacobandersson/esp/esp-idf/components/lwip/port/esp32/include -I/Users/jacobandersson/esp/esp-idf/components/lwip/port/esp32/include/arch -I/Users/jacobandersson/esp/esp-idf/components/vfs/include -I/Users/jacobandersson/esp/esp-idf/components/esp_wifi/include -I/Users/jacobandersson/esp/esp-idf/components/esp_wifi/esp32/include -I/Users/jacobandersson/esp/esp-idf/components/esp_eth/include -I/Users/jacobandersson/esp/esp-idf/components/efuse/include -I/Users/jacobandersson/esp/esp-idf/components/efuse/esp32/include -I/Users/jacobandersson/esp/esp-idf/components/app_trace/include -mlongcalls -Wno-frame-address   -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -nostdlib -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -Og -std=gnu++11 -fno-exceptions -fno-rtti -D_GNU_SOURCE -DIDF_VER=\"v4.0\" -DGCC_NOT_5_2_0 -DESP_PLATFORM -MD -MT esp-idf/FastLED-idf/CMakeFiles/__idf_FastLED-idf.dir/platforms/esp/32/clockless_rmt_esp32.cpp.obj -MF esp-idf/FastLED-idf/CMakeFiles/__idf_FastLED-idf.dir/platforms/esp/32/clockless_rmt_esp32.cpp.obj.d -o esp-idf/FastLED-idf/CMakeFiles/__idf_FastLED-idf.dir/platforms/esp/32/clockless_rmt_esp32.cpp.obj -c ../components/FastLED-idf/platforms/esp/32/clockless_rmt_esp32.cpp
../components/FastLED-idf/platforms/esp/32/clockless_rmt_esp32.cpp: In static member function 'static void ESP32RMTController::init()':
../components/FastLED-idf/platforms/esp/32/clockless_rmt_esp32.cpp:100:31: error: 'RMT_DEFAULT_CONFIG_TX' was not declared in this scope
         rmt_config_t rmt_tx = RMT_DEFAULT_CONFIG_TX((gpio_num_t)0, rmt_channel_t(i));
                               ^~~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
ninja failed with exit code 1

FastLED breaking Ethernet using RMT (LAN8720) ? And wrong LED pattern using I2S

Hi ! I am currently developing something on an ESP32 using ESP IDF and I was adding your library to my project to light up a Neopixel Ring (24 pixels).

I encountered some problems regarding the use of Wi-Fi and FastLED, which I believe I solved (I will describe it later), but now I am stuck with a new problem : On the first call to FastLED.show(), my Ethernet connectivity breaks ; I don't see any receives.

Details on my working environment :

  • I'm using an Olimex EVB ESP32 board (with an ESP32 chip, obviously), which has a LAN Port (LAN8720) .
  • I'm using ESP IDF (idf.py -- version gives ESP-IDF v4.3-dev-907-g6c17e3a64-dirty ), and Visual Studio Code on Ubuntu.
  • I power up my board via USB (5V) and an other USB port (5v) with an adapter powers up my Neopixel Ring. Plus, I added a 10K Ohm resistor on the pin to which the ring is connected. I didn't add the capacitor as recommended on Adafruit website, because my power supply isn't that powerful.
  • I connect via LAN my PC and the board to the same router, so there are in the same subnet, and the router gives via DHCP the IPs to them.
  • I can use either GPIO 12 / 02 / 04 / 05
  • Here's my code to show what I am seeing : I just started my example from your main, so if someone wants to do this on his side, just replace the main folder of this repo. This is not my project, but this example is showing the same issue.
    main.zip

I'm also using the RMT driver, by commenting the (#define FASTLED_ESP32_I2S) line in FastLED.h and un-commenting ("platforms/esp/32/clockless_rmt_esp32.cpp") in CMakeLists.txt. Indeed, I am using the WS2812 LED chipset, and as I understood, this uses the RMT driver. Finally, I added a line inside IDF code, in "esp_eth_mac_esp32.c" in component esp_eth, to print transmits of the mac driver :

  • ESP_LOGD(TAG, "transmit len= %d, buff len= %d", sent_len, length); // (line226)

As my example is running on the Olimex, I am pinging it with my PC. After the initialization, I have no problem pinging it. But, on the first call to FastLED.show(), receives end, and the device is not responding to my pings. I can stop and restart the Ethernet handler, this won't change any thing. The only way is to destroy it (uninstall the driver), re-install it and restart it again. But once again, on the next show, this will stop working. If I don't restart it, receives don't happen, but also, after a while, I am starting to see that the line in "esp_eth_mac_esp32.c" :
MAC_CHECK(sent_len == length, "insufficient TX buffer size", err, ESP_ERR_INVALID_SIZE); // line227
is reporting an error .

At least, my LED are showing correctly =) .

There is also a Wi-Fi handler initialized, but removing it won't solve the problem.

I have no idea what is causing the PB : I have browsed everywhere, I cannot seem to find anything on that, except this :
espressif/esp-idf#2644
But the person's problem was on the RMT side with RX, not on the Ethernet side.
I don't know if the RMT here is messing with the SPI emac pins ( I don't know why it would do that).
I don't know either if it is interrupt - related ( I also cannot see why it would be because the RMT implementation is not using any I believe). EDIT : I may have been wrong, and I believe now that there are actually interrupts, because the RMT sends the signal in a devided way.
It might be my implementation somehow, but what is in the example is pretty basic (just esp_eth usage and one FastLED controller with not that many pins).

Do you think I have to write an issue on FastLED Github page or on ESP-IDF one's ? I mean if the issue is RMT related and not really FastLED-idf related, I can understand that solving this is not really in your interest.
Otherwise, do you have any idea what might be the issue here ? Ah, and here is a capture of the logging, where we can see during the blinking that no receives happen, until I destroy-restart the eth handler :

Ethernet-FastLED

PS : The problem I had with the use of Wi-Fi and FastLED was due, I think, to the fact that Wi-Fi main task is pinned to core 0 and doing FastLED.show() in this core would result in wrong LED show, for example, 5 LEDs light up instead of 2. So, I'm now calling show() in a task pinned to core 1, and the problem disappeared. Have you ever seen this issue with Wi-Fi before ? Thank you for reading me !

Crash during show in esp-idf 4.1

Ran into this with esp-idf 4.1 trying to run the provided main.

My investigation shows that it gets to .show(). I tried a ton of things and eventually found that setting FASTLED_RMT_BUILTIN_DRIVER to 1 made the issue disappear. I don't fully understand the implications of this, and if I should just live with it set to 1, but I don't need to use the RMT for anything else and the docs seems to make it seem like this isn't a great idea.

I am running this on a tinypico, if hardware or chip would make a difference.

Let me know if I can provide any other info.

Log here, although I don't think they'll be of any use. I could reproduce this with slightly different stack traces by changing compile options and the stack trace doesn't seem to have anything to do with the actual function.

ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4
load:0x3fff0034,len:7192
load:0x40078000,len:14036
load:0x40080400,len:4152
0x40080400: _init at ??:?

entry 0x40080690
I (29) boot: ESP-IDF v4.1 2nd stage bootloader
I (29) boot: compile time 01:05:26
I (30) boot: chip revision: 1
I (32) boot.esp32: SPI Speed      : 40MHz
I (37) boot.esp32: SPI Mode       : DIO
I (42) boot.esp32: SPI Flash Size : 4MB
I (46) boot: Enabling RNG early entropy source...
I (52) boot: Partition Table:
I (55) boot: ## Label            Usage          Type ST Offset   Length
I (62) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (70) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (77) boot:  2 factory          factory app      00 00 00010000 00100000
I (85) boot: End of partition table
I (89) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x06224 ( 25124) map
I (107) esp_image: segment 1: paddr=0x0001624c vaddr=0x3ffb0000 size=0x0219c (  8604) load
I (110) esp_image: segment 2: paddr=0x000183f0 vaddr=0x40080000 size=0x00404 (  1028) load
0x40080000: _WindowOverflow4 at /home/nigel/esp/esp-idf/components/freertos/xtensa_vectors.S:1778

I (116) esp_image: segment 3: paddr=0x000187fc vaddr=0x40080404 size=0x0781c ( 30748) load
I (137) esp_image: segment 4: paddr=0x00020020 vaddr=0x400d0020 size=0x15fec ( 90092) map
0x400d0020: _stext at ??:?

I (169) esp_image: segment 5: paddr=0x00036014 vaddr=0x40087c20 size=0x025e4 (  9700) load
0x40087c20: rtc_clk_32k_enable_common at /home/nigel/esp/esp-idf/components/soc/esp32/rtc_clk.c:118

I (179) boot: Loaded app from partition at offset 0x10000
I (179) boot: Disabling RNG early entropy source...
I (181) cpu_start: Pro cpu up.
I (185) cpu_start: Application information:
I (189) cpu_start: Project name:     FastLED-idf
I (195) cpu_start: App version:      83c0736-dirty
I (200) cpu_start: Compile time:     Sep  9 2020 01:05:23
I (206) cpu_start: ELF file SHA256:  001c818c895b989b...
I (212) cpu_start: ESP-IDF:          v4.1
I (217) cpu_start: Starting app cpu, entry point is 0x40081160
0x40081160: call_start_cpu0 at /home/nigel/esp/esp-idf/components/esp32/cpu_start.c:205 (discriminator 1)

I (209) cpu_start: App cpu up.
I (228) heap_init: Initializing. RAM available for dynamic allocation:
I (234) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (240) heap_init: At 3FFB2BF0 len 0002D410 (181 KiB): DRAM
I (247) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (253) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (259) heap_init: At 4008A204 len 00015DFC (87 KiB): IRAM
I (266) cpu_start: Pro cpu start user code
I (284) spi_flash: detected chip: gd
I (284) spi_flash: flash io: dio
I (284) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
 entering app main, call add leds
 set max power
create task for led blinking
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC      : 0x400d55d4  PS      : 0x00060033  A0      : 0x800d48e5  A1      : 0x3ffaf8b0
0x400d55d4: fopen at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/stdio/fopen.c:168

A2      : 0x00000000  A3      : 0x3ffb1390  A4      : 0x00000040  A5      : 0x3ffb1390
A6      : 0x000000b0  A7      : 0x00000000  A8      : 0x00000034  A9      : 0x00000000
A10     : 0x00000001  A11     : 0x00009470  A12     : 0x3ff560b0  A13     : 0xefffffff
A14     : 0xfff7ffff  A15     : 0xffffffbf  SAR     : 0x00000020  EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000  LBEG    : 0x400d4700  LEND    : 0x400d4711  LCOUNT  : 0x00000000
0x400d4700: rtc_isr at /home/nigel/esp/esp-idf/components/driver/rtc_module.c:72

0x400d4711: rtc_isr at /home/nigel/esp/esp-idf/components/driver/rtc_module.c:76


ELF file SHA256: 001c818c895b989b

Backtrace: 0x400d55d1:0x3ffaf8b0 0x400d48e2:0x3ffaf8e0 0x40082aec:0x3ffaf920 0x400d4257:0x3ffaf940 0x400d4649:0x3ffaf9a0 0x400d3b5e:0x3ffaf9e0 0x400d1e5c:0x3ffafa10
0x400d55d1: fopen at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/stdio/fopen.c:167

0x400d48e2: uart_set_stop_bits at /home/nigel/esp/esp-idf/components/driver/uart.c:202 (discriminator 5)

0x40082aec: spi_flash_cache_enabled at /home/nigel/esp/esp-idf/components/spi_flash/cache_utils.c:340

0x400d4257: esp_efuse_utility_process at /home/nigel/esp/esp-idf/components/efuse/src/esp_efuse_utility.c:63

0x400d4649: periph_module_enable at /home/nigel/esp/esp-idf/components/driver/periph_ctrl.c:33 (discriminator 1)

0x400d3b5e: esp_flash_init_default_chip at /home/nigel/esp/esp-idf/components/spi_flash/esp_flash_spi_init.c:183

0x400d1e5c: esp_ipc_call_and_wait at /home/nigel/esp/esp-idf/components/esp_common/src/ipc.c:115


Rebooting...

report: this crashes with NPE on ESP-IDF master

User reports an NPE on Master, when code has been tested with 4.0/release of ESP-IDF.

Claims that adding a call to register the rmt device even when the documentation says not to fixes the NPE.

It is hoped this code works with future versions of 4.x ESP-IDF as well as 4.0, so the task is to test again and see what's really going on. If ESP-IDF has an inconsistancy with their documentation, or had a breaking change to require init, then that should be reported and/or figured out under a compile header.

Unable to change I2S_DEVICE from 0 to 1

Hi @bbulkow, thanks again for this port and for the quality of maintenance. I've found it a breeze to work with so far and the readme is above and beyond.

I'm using this port in a project that uses the SGTL5000 audio codec on I2S bus 0 (which this port uses by default). BT audio stream comes in and is handled by I2S bus 0, pumped through a filter bank for audio analysis, and sent to the SGTL5000 using GPIO 0 for main clock.

I see that you should be able to change the default I2S bus in platforms/esp/32/clockless_i2s_esp32.h line 127, but when I set this to 1, nothing shows on the WS2811 strip I'm using. I understand i2s at a high level, but I'm not sure how to debug this, nor do I have access to a scope.

Is there something I'm missing here about which pins are usable with each i2s bus? I ask because I know i2s bus 0 must use GPIO 0 for its main clock, so maybe I'm just using the wrong pins? (I was running the included sketch on pin 13)

Steps to reproduce:

  • Clone latest FastLED-idf
  • Copy over the sdkconfig.4-2 config to sdkconfig, run idf.py menuconfig, and save
  • Do not change any of the pins/led sets used (I own a WS2811 strip and ran it on pin 13)
  • Run idf.py flash monitor and ensure included blinkWithFx_test fxn renders animations as expected
  • Add #define I2S_DEVICE 1 to very top of main.cpp
  • Run idf.py flash monitor again and observe that none of the animations are displayed

It would be great to have the flexibility to run FastLED using i2s bus 1, and all audio on i2s bus 0. That being said, is there anything I should watch out for here? Theoretically I should be able to do this, right? I remember earlier this summer when I was using this port and its RMT interface, outputting LED data completely killed my audio. It was all scrambled as if the RMT was interrupting the main clock or something. But it was way beyond my experience level and I didn't feel opening an issue was necessary. But now that the i2s interface has been ironed out in this port, I thought maybe this is again a good time to see if this port plays well with my audio pipeline. Happy to share code samples, too. Thanks!

Versions:

  • ESP-IDF 4.2 (from release/4.2 branch)
  • FastLED-idf (latest)

idf.py build fails

This version of FastLED appears to be what I need ... but it doesn't seem to build with the latest version of esp-idf. (v4.2-dev-1206-g741960d5c)

idf.py build gives the following read out (slightly abridged)

...
[7/367] Building C object esp-idf/driver/CMakeFiles/__idf_driver.dir/spi_bus_lock.c.obj
FAILED: esp-idf/driver/CMakeFiles/__idf_driver.dir/spi_bus_lock.c.obj 
...
~/Data/programming/triwave/esp/esp-idf/components/driver/spi_bus_lock.c: In function 'spi_bus_lock_init_main_dev':
~/Data/programming/triwave/esp/esp-idf/components/driver/spi_bus_lock.c:822:41: error: implicit declaration of function 'xSemaphoreCreateBinaryStatic'; did you mean 'xSemaphoreCreateBinary'? [-Werror=implicit-function-declaration]
     g_spi_lock_main_flash_dev->semphr = xSemaphoreCreateBinaryStatic(&main_flash_semphr);
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                         xSemaphoreCreateBinary
~/Data/programming/triwave/esp/esp-idf/components/driver/spi_bus_lock.c:822:39: warning: assignment to 'SemaphoreHandle_t' {aka 'void *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
     g_spi_lock_main_flash_dev->semphr = xSemaphoreCreateBinaryStatic(&main_flash_semphr);
                                       ^
cc1: some warnings being treated as errors
[8/367] Linking CXX static library esp-idf/nghttp/libnghttp.a
ninja: build stopped: subcommand failed.
ninja failed with exit code 1```

Undefined reference to 'pinMode' with ESP32/APA102

The example project compiles fine with the default example configuration, but if I change the FastLED.addLeds call to FastLED.addLeds<APA102, 12, 14, BGR>(leds, NUM_LEDS) (just for example) I get a linker error components/FastLED-idf/platforms/esp/32/fastpin_esp32.h:20: undefined reference to 'pinMode'.

This may just be a bug in FastLED, but I figured I'd report it here since I'm not using vanilla FastLED.

implicit declaration of function 'pinMatrixOutAttach'

I got further some steps, and now I'm getting a compile failure on various hal-files.

I traced back the steps and this function seems to be usually declared in esp32-hal-matrix.h, which is not included in this distribution.

I have to add I'm using platformio's Arduino / esp-idf special cocktail mix, and the arduino framework adds those header files itself too. Though it does not seem to be compiled along with this in this case.

Some excerpt:

.pio/libdeps/esp32dev/FastLED-idf/components/FastLED-idf/hal/esp32-hal-spi.c: In function 'spiAttachSCK':
.pio/libdeps/esp32dev/FastLED-idf/components/FastLED-idf/hal/esp32-hal-spi.c:88:5: error: implicit declaration of function 'pinMatrixOutAttach' [-Werror=implicit-function-declaration]
     pinMatrixOutAttach(sck, SPI_CLK_IDX(spi->num), false, false);
     ^~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
*** [.pio/build/esp32dev/libae2/FastLED-idf/components/FastLED-idf/hal/esp32-hal-rmt.c.o] Error 1
.pio/libdeps/esp32dev/FastLED-idf/components/FastLED-idf/hal/esp32-hal-spi.c: In function 'spiAttachMISO':
.pio/libdeps/esp32dev/FastLED-idf/components/FastLED-idf/hal/esp32-hal-spi.c:107:5: error: implicit declaration of function 'pinMatrixInAttach' [-Werror=implicit-function-declaration]
     pinMatrixInAttach(miso, SPI_MISO_IDX(spi->num), false);
     ^~~~~~~~~~~~~~~~~

Driving WS2812B Leds with ESP32, palette is not continuous after addressing more than 63 leds

#include <FastLED.h>
#define NUM_LEDS1 64
#define LED_PIN1 22
CRGB leds1[NUM_LEDS1];
uint8_t paletteIndex = 0;

DEFINE_GRADIENT_PALETTE(redLight){
0, 255, 0, 0,
//102, 0, 0, 0,
127, 0, 0, 0,
//153, 0, 0, 0,
255, 0, 0, 0
};

CRGBPalette16 redLightPalette = redLight;

void setup() {
FastLED.addLeds<WS2812B, LED_PIN1, GRB>(leds1, NUM_LEDS1);
FastLED.setBrightness(255);
FastLED.clear(true);
}
void loop(){
fill_palette(leds1, NUM_LEDS1, paletteIndex, 255 / NUM_LEDS1, redLightPalette, 255, LINEARBLEND);

EVERY_N_MILLISECONDS_I(speedTimer, 1) {
paletteIndex++;
}
speedTimer.setPeriod(20); //use purpleVal for GPS
FastLED.show();
}

Im relatively new to coding on the ESP32 and I cant find anybody else with this specific issue but when I address more than 63 leds on my strip I have a sort of delay between the start and end of the strip. I have only had issues when using the fill_palette function.

I have a circular strip of WS2812B leds which total to 99 leds which id like to run a continuous moving palette on for a project.

In the arduino board manager im using version 2.0.6 eps32 board by Espressif Systems and version 3.5.0 of the FastLed library.

Let me know if this is the wrong place to post this issue or any other issue.

Pin support unclear

Howdy, thank you so so much for your work on this project! I was able to clone the repo and get the main.cpp sample working with a ws2812b strip and my knockoff esp32 devkit in roughly an hour, looking forward to learning how to actually use the library now ๐Ÿ˜…

I am not sure what pins I can or should use? The default pin used in this example (18) worked great, but the second pin (13) didn't work at all. I tried switching DATA_PIN_1 to a few other values for some additional trial and error and found that the project won't even compile with DATA_PIN_1 set to some values (e.g. 9). Perhaps it's not as simple as just changing that one define?

I found this comment on reddit while falling down a rabbit hole of links from your readme, which seems to suggest there are right and wrong answers, but it's still not clear to me what they are. (Still learning and a lot of this is going over my head tbh.)

Thanks again!

build failed after enable bluetooth

Hello

idf.py build works fine after I clone this awesome repo.
But it went wrong after I execute:

make menuconfig
// then, choose Components->Bluetooth-> and enable Bluetooth item

I got error message like this:

../components/FastLED-idf/hal/esp32-hal-misc.c:31:10: fatal error: esp_bt.h: No such file or directory
 #include "esp_bt.h"
          ^~~~~~~~~~
compilation terminated.

I'm using esp-idf version v4.0.1 on Ubuntu20.20

for now, I did some dirty by comment the line 31 in file components/FastLED-idf/hal/esp32-hal-misc.c and build pass.

Let me know I miss somethings?

Glitching issues with patterns

First off, thanks for this port--this was the push I needed to migrate my big LED projects from Arduino to IDF with Arduino as a component. Let me know if I can be of help with the hardware SPI driver at all.

I'm testing out running WS2812FX patterns on WS2812B LEDs and noticing a few different glitching and ghosting issues:

  1. The last pixel always glitches white when I run a pattern. This happens on all patterns and with both the RMT and I2S driver. Disabling WiFi and Bluetooth doesn't make a difference. Here's an example running a color wipe on a 256 pixel matrix, same thing happens on standard strips: GIF link

  2. I think there may be a data overflow with the I2S driver while running patterns. When using the I2S driver, I get a bunch of extra glitching pixels on past the amount I have defined for the controller. I don't have this issue with the RMT driver. This is the same setup as above (256 LEDs on one output), when I attach additional LEDs I get all this extra glitchy stuff: GIF link

  3. I see some ghosting on the leading pixels of animations when WiFi or Bluetooth is enabled. It's hard to capture with my phone camera, but in the above two GIFs there's also an issue where the leading few pixels of the animation don't clear/animate smoothly sometimes. Disabling both WiFi and Bluetooth fixes the issue, so I assume this is due to jitter. I noticed in the I2S driver you put fillBuffer in IRAM, but I don't think the 0 flag for the esp_inter_alloc call adds ESP_INTR_FLAG_IRAM, does it? I can explicitly call ESP_INTR_FLAG_LEVEL as 1, 2, or 3, but if I add | ESP_INTR_FLAG_IRAM I no longer get any output. Setting ESP_INTR_FLAG_LEVEL to 4 or greater also results in no output. Any thoughts on how to set the priority higher to avoid jitter issues?

Thanks again!

APA102 LoadProhibited when Bluetooth is enabled and data pin 19 is used

Hi @bbulkow, thanks again for a great port and for keeping this port maintained with the latest esp32 fastled improvements. With dual mode bluetooth controller enabled on esp-idf v4.2, trying to run your fastfade on a single APA102 status led throws a LoadProhibited exception if my data pin is GPIO 19. The animation appears to run fine on WS2812B leds using GPIO 19 for data out.

I basically just cloned the master branch, enabled bluetooth and flashed the app. I have no bluetooth-specific code, just the component enabled and set to dual mode.

Steps to reproduce:

  • Clone fresh master branch
  • Copy sdkconfig.4-2 over to sdkconfig
  • In menuconfig, enable dual mode bluetooth
  • Comment out WS2812B addLeds call and switch with the APA102 example you already had in there, but with GPIO 19 as data.
FastLED.addLeds<APA102, 19, 15>(leds, NUM_LEDS);

Other than this, there are no changes to the main.cpp file. Immediately after "entering app main, call add leds" is logged, the error below is thrown (full application log pasted for context). Is there something about GPIO 19 that I may not understand? I see that it's used as an SPI pin according to this article, but the official datasheet doesn't seem to suggest that GPIO 19 is reserved when BT is in use.

Thanks!

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4
load:0x3fff0034,len:7412
load:0x40078000,len:14724
ho 0 tail 12 room 4
load:0x40080400,len:4232
0x40080400: _init at ??:?

entry 0x40080690
I (30) boot: ESP-IDF v4.2-dev-2084-g98d5b5dfd 2nd stage bootloader
I (30) boot: compile time 07:36:10
I (31) boot: chip revision: 1
I (35) boot.esp32: SPI Speed      : 40MHz
I (39) boot.esp32: SPI Mode       : DIO
I (44) boot.esp32: SPI Flash Size : 4MB
I (49) boot: Enabling RNG early entropy source...
I (54) boot: Partition Table:
I (58) boot: ## Label            Usage          Type ST Offset   Length
I (65) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (72) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (80) boot:  2 factory          factory app      00 00 00010000 00100000
I (87) boot: End of partition table
I (91) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x063d8 ( 25560) map
I (109) esp_image: segment 1: paddr=0x00016400 vaddr=0x3ffbdb60 size=0x02404 (  9220) load
I (113) esp_image: segment 2: paddr=0x0001880c vaddr=0x40080000 size=0x00404 (  1028) load
0x40080000: _WindowOverflow4 at /Users/drewandre/esp/esp-idf/components/freertos/xtensa/xtensa_vectors.S:1730

I (119) esp_image: segment 3: paddr=0x00018c18 vaddr=0x40080404 size=0x07400 ( 29696) load
I (139) esp_image: segment 4: paddr=0x00020020 vaddr=0x400d0020 size=0x156fc ( 87804) map
0x400d0020: _stext at ??:?

I (170) esp_image: segment 5: paddr=0x00035724 vaddr=0x40087804 size=0x02978 ( 10616) load
0x40087804: multi_heap_assert at /Users/drewandre/esp/esp-idf/components/heap/multi_heap_platform.h:65
 (inlined by) merge_adjacent at /Users/drewandre/esp/esp-idf/components/heap/multi_heap.c:242

I (180) boot: Loaded app from partition at offset 0x10000
I (180) boot: Disabling RNG early entropy source...
I (182) cpu_start: Pro cpu up.
I (186) cpu_start: Application information:
I (191) cpu_start: Project name:     FastLED-idf
I (196) cpu_start: App version:      1
I (200) cpu_start: Compile time:     Sep  2 2020 07:36:07
I (206) cpu_start: ELF file SHA256:  00e68454ee48f8ba...
I (212) cpu_start: ESP-IDF:          v4.2-dev-2084-g98d5b5dfd
I (219) cpu_start: Starting app cpu, entry point is 0x4008174c
0x4008174c: call_start_cpu1 at /Users/drewandre/esp/esp-idf/components/esp32/cpu_start.c:282

I (0) cpu_start: App cpu up.
I (229) heap_init: Initializing. RAM available for dynamic allocation:
I (236) heap_init: At 3FFAE6E0 len 0000F480 (61 KiB): DRAM
I (242) heap_init: At 3FFC0898 len 0001F768 (125 KiB): DRAM
I (248) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (255) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (261) heap_init: At 4008A17C len 00015E84 (87 KiB): IRAM
I (267) cpu_start: Pro cpu start user code
I (285) spi_flash: detected chip: gd
I (286) spi_flash: flash io: dio
W (286) spi_flash: Detected size(16384k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
I (296) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
 entering app main, call add leds
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x40082af0  PS      : 0x00060630  A0      : 0x800d2f60  A1      : 0x3ffb1eb0
0x40082af0: __pinMode at /Users/drewandre/Downloads/FastLED-idf/build/../components/FastLED-idf/hal/esp32-hal-gpio.c:131

A2      : 0x00000013  A3      : 0x00000002  A4      : 0x00000000  A5      : 0x3ffb3b50
A6      : 0x00000000  A7      : 0x3ffb3b60  A8      : 0x3f404860  A9      : 0x00000000
A10     : 0x00000074  A11     : 0x0a732520  A12     : 0x00060620  A13     : 0x00060623
A14     : 0x00000001  A15     : 0x00000000  SAR     : 0x00000014  EXCCAUSE: 0x0000001c
EXCVADDR: 0x0a732520  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xfffffff7

Backtrace:0x40082aed:0x3ffb1eb0 0x400d2f5d:0x3ffb1ed0 0x400d37c9:0x3ffb1ef0 0x400d3186:0x3ffb1f10 0x400d1907:0x3ffb1f40
0x40082aed: __pinMode at /Users/drewandre/Downloads/FastLED-idf/build/../components/FastLED-idf/hal/esp32-hal-gpio.c:131

0x400d2f5d: APA102Controller<(unsigned char)19, (unsigned char)15, (EOrder)10, 20u>::init() at /Users/drewandre/Downloads/FastLED-idf/build/../components/FastLED-idf/platforms/esp/32/fastpin_esp32.h:27
 (inlined by) ?? at /Users/drewandre/Downloads/FastLED-idf/build/../components/FastLED-idf/fastspi_bitbang.h:39
 (inlined by) APA102Controller<(unsigned char)19, (unsigned char)15, (EOrder)10, 20u>::init() at /Users/drewandre/Downloads/FastLED-idf/build/../components/FastLED-idf/chipsets.h:231

0x400d37c9: CFastLED::addLeds(CLEDController*, CRGB*, int, int) at /Users/drewandre/Downloads/FastLED-idf/build/../components/FastLED-idf/FastLED.cpp:39 (discriminator 4)

0x400d3186: app_main at /Users/drewandre/Downloads/FastLED-idf/build/../components/FastLED-idf/FastLED.h:252
 (inlined by) app_main at /Users/drewandre/Downloads/FastLED-idf/build/../main/main.cpp:272

0x400d1907: main_task at /Users/drewandre/esp/esp-idf/components/esp32/cpu_start.c:589



ELF file SHA256: 00e68454ee48f8ba

Rebooting...

RMT mode messes up pin 0

Hi there

I've noticed that, when using GPIO 0, using fastled with RMT mode messes up this pin. After a little digging I've come to the conclusion that the problem is caused by these lines:

rmt_config_t rmt_tx = RMT_DEFAULT_CONFIG_TX(gpio_num_t(0), rmt_channel);
#else
rmt_config_t rmt_tx;
memset((void*) &rmt_tx, 0, sizeof(rmt_tx));
rmt_tx.channel = rmt_channel;
rmt_tx.rmt_mode = RMT_MODE_TX;
rmt_tx.gpio_num = gpio_num_t(0); // The particular pin will be assigned later

From a quick scan of the original fastled code, it seems like they dont set it to pin zero first (anymore) (https://github.com/FastLED/FastLED/blob/master/src/platforms/esp/32/clockless_rmt_esp32.cpp#L109) so an update would hopefully be all thats needed to resolve this :)

Thank you for your work

Just a small message to say I appreciate the work you've done with this.

This past week I have really pulled my hair on controlling a WS2812 with esp-idf and RMT. Most notably I had issues where sometimes some LEDs were not getting lighted up properly and that happened at random --and that's with using a proper SN74LVC1T45 level translator. These glitches are in an environment where I have a RTC 1s interrupt on a pin and a web server running. I turned to FastLED but it's a too deeply intertwined with Arduino code that I do not want to touch this with a 10 foot pole.

I figured there must be some issues at play here with multi-threading and other interrupts generating issues with the RMT routine, though I could never confirm that.

I fixed the issue by doing all the WS2812 processing in its own task with a queue/message pump. Since then I haven't had any issues. I think the 10ms of the FreeRTOS default tick time is enough get interference with the rest of the code, although again I am not 100% sure about this, it's my hypothesis.

Code here if you wish to peek.

Linking issues

Hi, I'm so grateful you took the time to port this library! I think it'll be well worth the effort given the popularity of esp32 and fastled.

I wanted to let you know of couple issues I had trying to build this example repository.

  1. I didn't see any clear instructions in the readme on how to run. I'm assuming I can just run make, but do I need to include the arduino library as well? Some clear instructions here would be helpful for future users, even if its just git clone and make.
  2. esp32-hal.h was not found in two files - FastLED.h and platforms/esp/32/clockless_rmt_esp32.h. I changed these to hal/esp32-hal.h which resolved that issue.
  3. I'm currently stuck on this one - I'm getting linking errors related to any timing functions like millis, delay, and micros (see output below). Would you recommend I include Arduino in my components folder?

I'm using ESP-IDF version 4.1 and xtensa-esp32-elf-gcc toolchain version 5.2.0. I realized my tool chain was out of date so I updated to 8.2.x and got the same linking errors.

LD build/FastLED-idf.elf
/Users/drewandre/esp/FastLED-idf/build/main/libmain.a(main.o):(.literal._Z16blinkLeds_simplePv+0x10): undefined reference to `delay'
/Users/drewandre/esp/FastLED-idf/build/main/libmain.a(main.o): In function `CFastLED::show()':
/Users/drewandre/esp/FastLED-idf/components/FastLED-idf/controller.h:171: undefined reference to `delay'
/Users/drewandre/esp/FastLED-idf/build/FastLED-idf/libFastLED-idf.a(FastLED.o):(.literal._ZN8CFastLED8countFPSEi+0x8): undefined reference to `millis'
/Users/drewandre/esp/FastLED-idf/build/FastLED-idf/libFastLED-idf.a(FastLED.o):(.literal._ZN8CFastLED4showEh+0x4): undefined reference to `micros'
/Users/drewandre/esp/FastLED-idf/build/FastLED-idf/libFastLED-idf.a(FastLED.o): In function `CFastLED::countFPS(int)':
/Users/drewandre/esp/FastLED-idf/components/FastLED-idf/FastLED.cpp:236: undefined reference to `millis'
/Users/drewandre/esp/FastLED-idf/components/FastLED-idf/FastLED.cpp:236: undefined reference to `millis'
/Users/drewandre/esp/FastLED-idf/build/FastLED-idf/libFastLED-idf.a(FastLED.o): In function `CFastLED::show(unsigned char)':
/Users/drewandre/esp/FastLED-idf/components/FastLED-idf/FastLED.cpp:236: undefined reference to `micros'
/Users/drewandre/esp/FastLED-idf/components/FastLED-idf/FastLED.cpp:236: undefined reference to `micros'
collect2: error: ld returned 1 exit status
make: *** [/Users/drewandre/esp/FastLED-idf/build/FastLED-idf.elf] Error 1

Adding an LED strip on an RTC pin fails

First, thanks for creating this port for ESP-IDF!

I just switched from IDF 3.3 to IDF 4.1 and now whenever I add a Neopixel LED controller to GPIO33, I get the following error:

0x40088559: __pinMode at c:\users\nishanth\code\firmware-amp-idf\build/../components/FastLED-idf/hal/esp32-hal-gpio.c:131

0x400e3026: ClocklessController<33, 20, 50, 30, (EOrder)66, 0, false, 5>::init() at c:\users\nishanth\code\firmware-amp-idf\build/../components/FastLED-idf/platforms/esp/32/clockless_i2s_esp32.h:230

0x4010efbd: CFastLED::addLeds(CLEDController*, CRGB*, int, int) at c:\users\nishanth\code\firmware-amp-idf\build/../components/FastLED-idf/FastLED.cpp:39 (discriminator 4)

The code works fine for the other GPIO pins that I use (22, 26, and 14). This code worked fine for GPIO33 with IDF 3.3. If it helps, I'm using the I2S driver instead of the RMT driver at the moment.

Restructure respository to use components as submodules

To use this FastLED-idf component in my code and keep up to date with your changes, I keep my own respository that tracks these changes as an IDF component here: https://github.com/intentfulmotion/FastLED-idf

This allows me to use it as a submodule in my project and not have to keep a version of this component's source in my project repository (https://github.com/intentfulmotion/firmware-amp). It's the same repository structure used by Espressif to maintain their different components.

Would you be open to breaking off the FastLED-idf and WS2812FX-idf components into their own repositories and then using them as submodules in this repository similarly?

Thank you

I really want to thank you. You have made getting my degree so much easier. I love your work <3

Crash with 512 LEDs

I can report a very similar issue, though with version 4.2.
I'm (trying to) run 512 WS2812B's on a ESP32 Wroom, and am experiencing a very similar hard crash, whenever .show() i called.

`
entry 0x40080690
I (28) boot: ESP-IDF v4.2-dev-459-ge36516372-dirty 2nd stage bootloader
I (28) boot: compile time 12:28:27
I (29) boot: chip revision: 1
I (33) boot.esp32: SPI Speed : 40MHz
I (38) boot.esp32: SPI Mode : DIO
I (42) boot.esp32: SPI Flash Size : 4MB
I (47) boot: Enabling RNG early entropy source...
I (52) boot: Partition Table:
I (56) boot: ## Label Usage Type ST Offset Length
I (63) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (71) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (78) boot: 2 factory factory app 00 00 00010000 00100000
I (86) boot: End of partition table
I (90) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x0633c ( 25404) map
I (108) esp_image: segment 1: paddr=0x00016364 vaddr=0x3ffb0000 size=0x02238 ( 8760) load
I (111) esp_image: segment 2: paddr=0x000185a4 vaddr=0x40080000 size=0x00404 ( 1028) load
0x40080000: _WindowOverflow4 at /Users/nicolaidyre/esp/esp-idf/components/freertos/xtensa/xtensa_vectors.S:1817

I (117) esp_image: segment 3: paddr=0x000189b0 vaddr=0x40080404 size=0x07668 ( 30312) load
I (138) esp_image: segment 4: paddr=0x00020020 vaddr=0x400d0020 size=0x15e88 ( 89736) map
0x400d0020: _stext at ??:?

I (170) esp_image: segment 5: paddr=0x00035eb0 vaddr=0x40087a6c size=0x025f4 ( 9716) load
0x40087a6c: vPortExitCritical at /Users/nicolaidyre/esp/esp-idf/components/freertos/xtensa/port.c:410

I (179) boot: Loaded app from partition at offset 0x10000
I (179) boot: Disabling RNG early entropy source...
I (181) cpu_start: Pro cpu up.
I (185) cpu_start: Application information:
I (190) cpu_start: Project name: FastLED-idf
I (195) cpu_start: App version: 83c0736-dirty
I (201) cpu_start: Compile time: Sep 10 2020 12:28:33
I (207) cpu_start: ELF file SHA256: 04fc65b207ca56f2...
I (213) cpu_start: ESP-IDF: v4.2-dev-459-ge36516372-dirty
I (220) cpu_start: Starting app cpu, entry point is 0x40081164
0x40081164: call_start_cpu1 at /Users/nicolaidyre/esp/esp-idf/components/esp32/cpu_start.c:274

I (0) cpu_start: App cpu up.
I (230) heap_init: Initializing. RAM available for dynamic allocation:
I (237) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (243) heap_init: At 3FFB2F00 len 0002D100 (180 KiB): DRAM
I (249) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (255) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (262) heap_init: At 4008A060 len 00015FA0 (87 KiB): IRAM
I (268) cpu_start: Pro cpu start user code
I (286) spi_flash: detected chip: gd
I (287) spi_flash: flash io: dio
W (287) spi_flash: Detected size(16384k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
I (297) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
entering app main, call add leds
set max power
create task for led blinking
blink leds
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x400d5908 PS : 0x00060f33 A0 : 0x800d4671 A1 : 0x3ffb7b50
0x400d5908: rmt_set_tx_thr_intr_en at /Users/nicolaidyre/esp/esp-idf/components/driver/rmt.c:389

A2 : 0x00000000 A3 : 0x3ffb1394 A4 : 0x00000040 A5 : 0x3ffb1394
A6 : 0x000000b0 A7 : 0x00000000 A8 : 0x00000034 A9 : 0x00000000
A10 : 0x3ffb236c A11 : 0x00009470 A12 : 0x3ff560b0 A13 : 0xefffffff
A14 : 0xfff7ffff A15 : 0xffffffbf SAR : 0x00000020 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x400d4478 LEND : 0x400d4489 LCOUNT : 0x00000000
0x400d4478: calculate_unscaled_power_mW(CRGB const*, unsigned short) at /Users/nicolaidyre/esp/FastLED-idf/build/../components/FastLED-idf/power_mgt.cpp:60

0x400d4489: calculate_unscaled_power_mW(CRGB const*, unsigned short) at /Users/nicolaidyre/esp/FastLED-idf/build/../components/FastLED-idf/power_mgt.cpp:59

ELF file SHA256: 04fc65b207ca56f24f06871c87e8d00d8337f96ff2148385ae6e888246b89aa5

Backtrace: 0x400d5905:0x3ffb7b50 0x400d466e:0x3ffb7b80 0x40082814:0x3ffb7bc0 0x400d4003:0x3ffb7be0 0x400d43f1:0x3ffb7c40 0x400d3945:0x3ffb7c80
0x400d5905: rmt_ll_set_tx_limit at /Users/nicolaidyre/esp/esp-idf/components/soc/src/esp32/include/hal/rmt_ll.h:177
(inlined by) rmt_set_tx_thr_intr_en at /Users/nicolaidyre/esp/esp-idf/components/driver/rmt.c:389

0x400d466e: ESP32RMTController::init() at /Users/nicolaidyre/esp/FastLED-idf/build/../components/FastLED-idf/platforms/esp/32/clockless_rmt_esp32.cpp:233

0x40082814: ESP32RMTController::showPixels() at /Users/nicolaidyre/esp/FastLED-idf/build/../components/FastLED-idf/platforms/esp/32/clockless_rmt_esp32.cpp:265

0x400d4003: CPixelLEDController<(EOrder)10, 1, 4294967295u>::show(CRGB const*, int, CRGB) at /Users/nicolaidyre/esp/FastLED-idf/build/../components/FastLED-idf/platforms/esp/32/clockless_rmt_esp32.h:394
(inlined by) CPixelLEDController<(EOrder)10, 1, 4294967295u>::show(CRGB const*, int, CRGB) at /Users/nicolaidyre/esp/FastLED-idf/build/../components/FastLED-idf/controller.h:408

0x400d43f1: CFastLED::show(unsigned char) at /Users/nicolaidyre/esp/FastLED-idf/build/../components/FastLED-idf/controller.h:90
(inlined by) CFastLED::show(unsigned char) at /Users/nicolaidyre/esp/FastLED-idf/build/../components/FastLED-idf/FastLED.cpp:59

0x400d3945: blinkLeds_simple(void*) at /Users/nicolaidyre/esp/FastLED-idf/build/../components/FastLED-idf/FastLED.h:506
(inlined by) blinkLeds_simple(void*) at /Users/nicolaidyre/esp/FastLED-idf/build/../main/main.cpp:166

Rebooting...
`

SPI Support

Thanks a lot for this port! I'm currently still struggling to get it running with platformio (files aren't being found by default), but meanwhile I wanted to share a quick half-PR with you.

As far as I've seen, so far there is no ESP32 SPI output in FastLED yet.

https://gist.github.com/Ivorforce/adcc7dd68c2b43d8cbb1f58de36a09fe

This gist is a quick dump of my own SPI setup for another project, which is several times faster than bitbanging. I may make this into complete PRs (here and in the original repo) yet, but if someone suddenly feels the urge to include or finalize it, here's a starter. :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.