Error when initializing PDM RX mode: gdma_register_rx_event_callbacks(513): user context not in internal RAM

JetForMe
Posts: 10
Joined: Mon Jan 27, 2025 8:55 am

Error when initializing PDM RX mode: gdma_register_rx_event_callbacks(513): user context not in internal RAM

Postby JetForMe » Sat Mar 08, 2025 7:44 am

I've got Arduino code targeting ESP32-S3 (ESP32-S3-WROOM1 Adafruit MatrixPortal S3) that sets up PDM receive via DMA, and uses a callback to put the samples into a FreeRTOS ring buffer. This has been working well up until now. While troubleshooting some other issue, I discovered the the Arduino IDE was adding include paths to multiple FreeRTOS installations for different platforms. I deleted those platforms, and have only the ESP-IDF version installed, and now when my code runs, I get these errors.

Code: Select all

23:30:42.843 -> E (2929) gdma: gdma_register_rx_event_callbacks(513): user context not in internal RAM
23:30:42.843 -> E (2931) i2s_common: i2s_init_dma_intr(809): Register rx callback failed
23:30:42.843 -> E (2931) i2s_pdm: i2s_channel_init_pdm_rx_mode(485): initialize dma interrupt failed
23:30:42.843 -> i2s_channel_init_pdm_rx_mode() failed with 258: ESP_ERR_INVALID_ARG
The code can be found here. I don't know why it worked before, but I'm at a loss now. What’s especially odd is that it complains about callbacks before I’ve actually registered my callback; I don’t know if it’s referring to an internal callback or what. In any case, how can I correct this issue in the Arduino environment? This is with esp32 3.2.0-RC1, ESP-IDF v5.4-561-gbcb3c32d3a-dirty.

Sprite
Espressif staff
Espressif staff
Posts: 10651
Joined: Thu Nov 26, 2015 4:08 am

Re: Error when initializing PDM RX mode: gdma_register_rx_event_callbacks(513): user context not in internal RAM

Postby Sprite » Sun Mar 09, 2025 6:23 am

Hm, I'm wondering if the 320K of ringbuffer you allocate beforehand has something to do with this... does the problem change if you make that a lot smaller?

JetForMe
Posts: 10
Joined: Mon Jan 27, 2025 8:55 am

Re: Error when initializing PDM RX mode: gdma_register_rx_event_callbacks(513): user context not in internal RAM

Postby JetForMe » Sun Mar 09, 2025 6:38 am

Hmm, that does seem rather large, doesn’t it? Unfortunately, I tried both making it 64,000 bytes, and moving that allocation to just before the enable call, and neither made a difference. The mode call still fails the same way and it never reaches the buffer allocation.

JetForMe
Posts: 10
Joined: Mon Jan 27, 2025 8:55 am

Re: Error when initializing PDM RX mode: gdma_register_rx_event_callbacks(513): user context not in internal RAM

Postby JetForMe » Tue Mar 11, 2025 8:22 am

I looked through the esp-idf sources to figure out exactly what it doesn't like. It's complaining that the handle I'm passing to `i2s_channel_init_pdm_rx_mode()` is not allocated in internal RAM. But the thing is, I get that from `i2s_new_channel()`, which ends up calling `heap_caps_calloc(1, sizeof(struct i2s_channel_obj_t), I2S_MEM_ALLOC_CAPS);`, which should be defined as `(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)`.

So I don’t know why this isn't working.

This is in the Arduino 3.2.0-RC1, which uses ESP-IDF verison: v5.4-561-gbcb3c32d3a-dirty, which logs line numbers a few off from where I find the calls in the v5.4 tag of esp-idf on github. But that's what I looked through to find out this is what it was complaining about.

It occurred to me maybe it had something to do with the version of arduino-esp32. I checked back to 3.1.1, and although the channel is still allocated in external memory, it does not get the "user context not in internal RAM" error. That error starts with arduino-esp32 v3.1.2.

It's the same as this issue: https://github.com/espressif/arduino-esp32/issues/11058, which was closed as a duplicate, but it doesn't say a duplicate of what.

JetForMe
Posts: 10
Joined: Mon Jan 27, 2025 8:55 am

Re: Error when initializing PDM RX mode: gdma_register_rx_event_callbacks(513): user context not in internal RAM

Postby JetForMe » Tue Mar 11, 2025 8:26 am

Looks like maybe of this: https://github.com/espressif/arduino-esp32/issues/11004, and the fix should be available in arduino-esp32 3.2.0-RC2 tomorrow. GDMA was set to be IRAM_SAFE, but not I2S, in the arduino-esp32 core, and thus the issues.

JetForMe
Posts: 10
Joined: Mon Jan 27, 2025 8:55 am

Re: Error when initializing PDM RX mode: gdma_register_rx_event_callbacks(513): user context not in internal RAM

Postby JetForMe » Mon Mar 17, 2025 1:34 am

Yep, 3.2.0-RC2 fixed it!

Who is online

Users browsing this forum: Bing [Bot], ChatGPT-User, PetalBot and 2 guests