espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.79k stars 7.31k forks source link

RMT in RX Mode causes memory corruption with ESP32-S3 (SOC_RMT_SUPPORT_RX_PINGPONG) (IDFGH-12393) #13419

Open domonoky opened 8 months ago

domonoky commented 8 months ago

Answers checklist.

IDF version.

v4.4.7

Espressif SoC revision.

ESP32-S3

Operating System used.

Windows

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

Development Kit.

Custom Board

Power Supply used.

External 3.3V

What is the expected behavior?

RMT Driver in RX mode should work without memory corruption like on ESP32

What is the actual behavior?

The RMT Driver is used to recieve 433Mhz remote commands from a remote. When the environment is very nosy i get many outputs of "RMT RX BUFFER is FULL" and "---RX buffer too small". And after sometime the system reboots with different memory errors. Mostly the stack overflow check for one of my threads is triggered. I then tested it by making sure this thread does not do any stack allocations, but the stack overflow check still triggers. The Free stack check goes from ~6k free to 0, which indicates some memory overflow/ overwriting issues. The same code works fine on ESP32

If i disable SOC_RMT_SUPPORT_RX_PINGPONG (set it to 0 in soc_caps.h for esp32s3) then everything is working again. So this is very likely an issue with the rmt driver when the RX_PINGPONG code is active.

Steps to reproduce.

This is difficult to reproduce, as this might only happen in noisy enviroments when the RMT rx ringbuffer is full.

Debug Logs.

No response

More Information.

No response

suda-morris commented 8 months ago

@domonoky Thanks for reporting the issue in the legacy RMT driver, we need some time to investigate the legacy driver.

But if your project can upgrade to use esp-idf v5.x, then you can try out the new RMT driver there. I believe there's a better memory management. What's more, as you're using the esp32s3, you can enable the DMA feature, this feature only exit in the new driver.

The most close example to your application is this NEC encoder and decoder example