ERR: MFCC failed (-1002)

I am trying to run microphone_continuous example ported from arduino example on faucet dataset at imxrt10xx.
I am getting error below:

ERR: MFCC failed (-1002)
ERR: Failed to run DSP process (-1002)
ERR: Failed to run classifier (-5)

By the way when I (debug) print the offset and length in the microphone_audio_signal_get_data function, it prints offset: 3999, length: 1 only once and then above error happens.

@naveen -1002 is EIDSP_OUT_OF_MEM (out of memory). This could be: 1) really out of memory (not sure what the RAM of your device is), 2) malloc not succeeding, either because the heap is too small, or because different memory allocation functions should be used - you can override ei_malloc / ei_calloc / ei_free for this (see edge-impulse-sdk/porting/ei_classifier_porting.h).

3 Likes

Thanks @janjongboom, it was a memory issue. The 128KB RAM is divided into multiple 32 KB banks and the default heap memory was only 4KB which was not enough. After increasing the heap size it worked!

3 Likes

Hello! I am having the same issue, how did you manage to increase the heap size?
Did you change a value in the /ei_classifier_porting.h file?

Which MCU/Development Board are you using?

1 Like

I am using the Arduino Nano BLE Sense 33 board

Hi @DW_FYP the Nano 33 BLE Sense is already fully using its memory, so your option here would be to tweak the parameters in the MFCC block to use less memory (see the ā€˜Performanceā€™ widget for an indication). E.g. by upping the frame length parameter.

3 Likes

Thank you guys so much! It works now that I changed some MFCC parameters. Thank you again, I really appreciate it :smiley:

2 Likes

Sorry but I am having the same issue, I want to try and solve it increasing the heap size as you did. Can you tell me how can I modify it? If it is in Arduino IDE or directly in the EI libraries or files?

I used MCUExpresso IDE to configure heap size for iMX.RT1010. Which development board are you using?

I am using ESP32-WROOM with Arduino IDE and the generated framework by Edge Impulse.

Did you made some modifications directly on the libraries from EI? Or do I have to add code to modifiy the heap size of the board through the IDE?

I think ESP32 has large RAM in comparison of imxrt1010. Maybe you need to check memory usage in your code first.

It has 4MB in Flash RAM. I am still trying to release memory with malloc in order to avoid heap memory to overflow, but itā€™s not working.

4MB is PSRAM not the main RAM in ESP32.

Sorry, 4MB is the Flash Memory, and the SRAM is 512kB. Now my problem is that iā€™m getting another error message ā€œStack canary watchpoint triggered (mytask)ā€ for the ESP32. Apparently the heap or stack size is being overflown, even when I increase or free with malloc.

I think you should create a FreeRTOS task in setup with xTaskCreate and assign larger stack size and move your code to that task function.

Helloā€¦ iā€™m using nano 33 ble sense. Iā€™m having the same issue. But i donā€™t understand since it has 256 KBS of RAM and the estimated peak RAM Usage from edge impulse is 104 KBs. Please can you helpā€¦

FIrstly i was having tf arena allocation issueā€¦ which got solved by declaring -DEI_CLASSIFIER_ALLOCATION_STATIC.

Hello @rida,

Can you share your project ID so I can have a look at your project please?

Best,

Louis

Letā€™s follow the discussion on the other thread you opened.

Best,

Louis