Esp32 crash on nvs_set_blob (memcpy in ROM)

MicroController
Posts: 1954
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Esp32 crash on nvs_set_blob (memcpy in ROM)

Postby MicroController » Sun Dec 15, 2024 1:23 am

brebisson wrote:
Sat Dec 14, 2024 9:47 pm

Code: Select all

...
        esp_err_t ret = adc_continuous_read(handle, p, sampleSize, &ret_num, 0); if (ret!=ESP_OK || ret_num!=sampleSize) return;
...
You may want to try a bigger buffer to get as many samples as possible from each call to adc_continuous_read().
And you probably don't want a timeout of 0.

Btw, the 'doc' says:
If the generated results fill up the internal pool, newly generated results will be lost. Next time when adc_continuous_read() is called, this function will return ESP_ERR_INVALID_STATE to indicate this situation.
Does this match what you observe?

brebisson
Posts: 31
Joined: Fri Dec 22, 2023 9:44 am

Re: Esp32 crash on nvs_set_blob (memcpy in ROM)

Postby brebisson » Sun Dec 15, 2024 7:33 am

Hello,

Ok, message for others looking for the same problem.
I think that I found the issue...

I needed to add this line:

CONFIG_ADC_CONTINUOUS_ISR_IRAM_SAFE=y

In the sdkconfig file in visual studio code / ESP-IDF...
To make the whole ISR IRAM safe...

Cyrille

User avatar
CseaTec
Posts: 8
Joined: Thu Jul 07, 2022 12:21 pm

Re: Esp32 crash on nvs_set_blob (memcpy in ROM)

Postby CseaTec » Thu Jan 23, 2025 1:10 am

brebisson wrote:
Sun Dec 15, 2024 7:33 am
Hello,

Ok, message for others looking for the same problem.
I think that I found the issue...

I needed to add this line:

CONFIG_ADC_CONTINUOUS_ISR_IRAM_SAFE=y

In the sdkconfig file in visual studio code / ESP-IDF...
To make the whole ISR IRAM safe...

Cyrille

OMG. Cyrille, I'm going to have to send you a box of chocolates, a case of beer, and a Christmas card later this year. I have been fighting the exact same problem all day today since I was changing my ADC architecture from one-shot to continuous. After about 10 straight hours of adding scope signals, debug printf statements, and dozens of code modifications to narrow in on what was going on, I was able to determine it was the nvs_set_blob commands colliding with the adc_continuous DMA updates. That finally led me to do a more appropriate Google search which ultimately revealed your post topic here.

I made the change you suggested here to the sdkconfig and all is now working as hoped. No more crashes. The ADC continuous was needed for my application and has made a *huge* difference in reducing the overhead of individual one-shot ADC conversions.

THANK YOU again for sharing your success. I have done this before in this forum, so I will continue to do so since it might help someone else like you helped me.
Matteo Giovanetti
Electrical Engineer
CseaTec LLC
Pompano Beach, FL USA

Who is online

Users browsing this forum: No registered users and 66 guests