lbernstone / IR32

Infrared remote using rmt peripheral on esp32
MIT License
17 stars 11 forks source link

library crash on xRingbufferReceive(_rb, &rx_size, RMT_RX_BUF_WAIT); #5

Open marcmerlin opened 5 years ago

marcmerlin commented 5 years ago

The example code works fine on my ESP32, but when I integrate your lib in a much bigger code base that uses DMA and probably one code to push to the RGBPanels (in the SmartMatrix library), your library crashes here:

uint32_t IRRecv::read(char* &timingGroup, bool preferredOnly)
{
    if (!available()) return 0;

    size_t rx_size = 0;
    rmt_item32_t* item = (rmt_item32_t*) xRingbufferReceive(_rb, &rx_size, RMT_RX_BUF_WAIT); <<<
0x4008a1b0: invoke_abort at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/esp32/panic.c line 155
0x4008a3e1: abort at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/esp32/panic.c line 170
0x4008600b: xRingbufferReceive at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/esp_ringbuf/ringbuf.c line 845
0x400e221e: IRRecv::read(char*&, bool) at /home/merlin/Arduino/libraries/IR32/src/IRRecv.cpp line 128
0x400ded35: check_IR_serial() at /home/merlin/arduino/prg/Neopixel/NeoMatrix-FastLED-IR/NeoMatrix-FastLED-IR.ino line 2273
0x400dfb93: setup() at /home/merlin/arduino/prg/Neopixel/NeoMatrix-FastLED-IR/NeoMatrix-FastLED-IR.ino line 3158
0x400e46b3: loopTask(void*) at /home/merlin/Arduino/hardware/espressif/esp32/cores/esp32/main.cpp line 14
0x400861f1: vPortTaskWrapper at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/port.c line 143

19:24:56.431 -> Backtrace: 0x4008a1b0:0x3ffb1ea0 0x4008a3e1:0x3ffb1ec0 0x4008600b:0x3ffb1ee0 0x400e221e:0x3ffb1f20 0x400ded39:0x3ffb1f50 0x400dfb93:0x3ffb1f80 0x400e46b3:0x3ffb1fb0 0x400861f1:0x3ffb1fd0
19:24:56.431 -> 
19:24:56.431 -> Rebooting...
19:24:56.431 -> ets Jun  8 2016 00:22:57
19:24:56.431 -> 
19:24:56.431 -> rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
19:24:56.504 -> configsip: 0, SPIWP:0xee
19:24:56.504 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

Is there a way to make this compatible with SmartMatrix?

marcmerlin commented 5 years ago

You can find the (huge) code that uses your lib here: https://github.com/marcmerlin/NeoMatrix-FastLED-IR/blob/c9a8df6c95c3ea62ae20d200fe9b09f57ca0d89d/NeoMatrix-FastLED-IR.ino#L2267

I realize it will likely be hard for you to know what's wrong by just looking at it or trying to reproduce given how big the code, is, but maybe we can have a guess that it's a dual core issue and conflict with SmartMatrix?

lbernstone commented 4 years ago

Well, is Neomatrix using the rmt peripheral? I would think the conflict is there. If both the IR and Neomatrix are trying to use the same device, it is going to have issues getting at the memory locations.

marcmerlin commented 4 years ago

FastLED does use RMT (single channel) on ESP32. I thought 2 different libraries could use RMT, but maybe they can't. If you confirm that they can't both use RMT, I'll see if I can get FastLED to use bit banging, or its new I2S mode instead of RMT.

gldhnchn commented 4 years ago

I ran into the same problem using FastLED and another RMT module to control an IR LED. But I think the problem is not with this library here. It is possibly a problem in FastLED or in the build in RMT driver. Using FastLED with #define FASTLED_ESP32_I2S true (for Neopixel) did it for me.