Deploy Edge-Impulse model to ESP-IDF ESP32s3

Question/Issue:
[Describe the question or issue in detail]
The build fails when trying to deploy Edge-impulse model to ESP32s3 based custom PCB.
Project ID:
[793647]

Context/Use case:
Use case is using Microphone to sample and train data and then deploy the model

Summary:
[Provide a concise summary of the bug]
I have copied the standalone application template for esp32 idf environment. The issue that I am running into is during the build process of the application.
The project fails to build
C:/Users/ujjwa/try_mic_espc6/edge-impulse-sdk/dsp/numpy_types.h:693:5: error: expected specifier-qualifier-list before β€˜std’
693 | std::function<int(size_t offset, size_t length, float *out_ptr)> get_data;
| ^~~
In file included from C:/Users/ujjwa/try_mic_espc6/edge-impulse-sdk/classifier/ei_model_types.h:41:
C:/Users/ujjwa/try_mic_espc6/edge-impulse-sdk/dsp/ei_dsp_handle.h:38:1: error: unknown type name β€˜class’
38 | class DspHandle {
| ^~~~~
C:/Users/ujjwa/try_mic_espc6/edge-impulse-sdk/dsp/ei_dsp_handle.h:38:17: error: expected β€˜=’, β€˜,’, β€˜;’, β€˜asm’ or β€˜attribute’ before β€˜{’ token
38 | class DspHandle {
| ^
In file included from C:/Users/ujjwa/try_mic_espc6/edge-impulse-sdk/classifier/ei_model_types.h:42:
C:/Users/ujjwa/try_mic_espc6/edge-impulse-sdk/dsp/numpy.hpp:54:10: fatal error: cfloat: No such file or directory
54 | #include
| ^~~~~~~~
compilation terminated.
[1066/1342] Building CXX object esp-idf/main/CMakeFiles/idf_main.dir//edge-impulse-sdk/dsp/memory.cpp.obj
ninja: build stopped: subcommand failed.
Steps to Reproduce:

  1. [Step 1]
    Create a model on Edge impulse and train it. Download the keyword spotting model.
  2. [Step 2]
    Download the standalone app for ESP-IDF dev. Enviromint.
  3. [Step 3]
    Build the application code along with main() application.

Expected Results:
[Describe what you expected to happen]
Build normally
Actual Results:
[Describe what actually happened]

Reproducibility:

  • [ *] Always
  • [ ] Sometimes
  • [ ] Rarely

Environment:

  • Platform: [ESP32s3-ESP-IDF.]

  • Build Environment Details: [ ESP-IDF]

  • OS Version: [ Windows 11]

  • Edge Impulse Version (Firmware): [e.g., 1.2.3]
    To find out Edge Impulse Version:

  • Edge Impulse CLI Version: [e.g., 1.5.0]

  • Project Version: [e.g., 1.0.0]

  • Custom Blocks / Impulse Configuration: [Describe custom blocks used or impulse configuration]
    Logs/Attachments:
    [Include any logs or screenshots that may help in diagnosing the issue]

Logs/Attachments:

Additional Information:
I have a model trained on the studio. The model is keyword detection model using Microphone.

1 Like

Hi, @ujjwalrathod007 !
Please let us know more details about your environment. Use the template for that, thank you.

Environment:

  • Platform: [ESP32s3-ESP-IDF.]
  • Build Environment Details: [ ESP-IDF]
  • OS Version: [ Windows 11]
  • Edge Impulse Version (Firmware): [e.g., 1.2.3]
    To find out Edge Impulse Version:
  • Edge Impulse CLI Version: [e.g., 1.5.0]
  • Project Version: [e.g., 1.0.0]
  • Custom Blocks / Impulse Configuration: [Describe custom blocks used or impulse configuration]
    Logs/Attachments:
    [Include any logs or screenshots that may help in diagnosing the issue]
2 Likes

Hi @AIWintermuteAI

Environment:

  • Platform: [ESP32s3-ESP-IDF.]
    I am using a custom board with ESP32s3 chip. I am using ESP-IDF as build environment.
  • Build Environment Details: [ ESP-IDF]
    I am using ESP-IDF version 5.5.0
  • OS Version: [ Windows 11]
    I am using Windows-11 64-bits
  • Edge Impulse Version (Firmware): [e.g., 1.2.3]
    To find out Edge Impulse Version:
  • Edge Impulse CLI Version: [e.g., 1.5.0]
    I am not using CLI at all
  • Project Version: [e.g., 1.0.0]
  • Custom Blocks / Impulse Configuration: [Describe custom blocks used or impulse configuration]
    I am not using any custom blocks or anything similar to that. I have created an impulse online. The following image shows the configurations.
    image

Logs/Attachments:

I get the following error message when trying to build the project. The error is when trying to include the following file. It seems that the #include<functional> is not included as the file might not be treated as C++ file.

#include "edge-impulse-sdk/classifier/ei_run_classifier.h"

                 from C:/Users/ujjwa/try_mic_espc6/edge-impulse-sdk/classifier/ei_model_types.h:40,
                 from C:/Users/ujjwa/try_mic_espc6/edge-impulse-sdk/classifier/ei_run_classifier.h:38,
                 from C:/Users/ujjwa/try_mic_espc6/main/hello_world_main.c:31:
C:/Users/ujjwa/try_mic_espc6/edge-impulse-sdk/dsp/numpy_types.h:699:5: error: expected specifier-qualifier-list before 'std'
  699 |     std::function<int(size_t offset, size_t length, float *out_ptr)> get_data;
      |     ^~~
In file included from C:/Users/ujjwa/try_mic_espc6/edge-impulse-sdk/classifier/ei_model_types.h:41:
C:/Users/ujjwa/try_mic_espc6/edge-impulse-sdk/dsp/ei_dsp_handle.h:42:1: error: unknown type name 'class'
   42 | class DspHandle {
      | ^~~~~
C:/Users/ujjwa/try_mic_espc6/edge-impulse-sdk/dsp/ei_dsp_handle.h:42:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   42 | class DspHandle {
      |                 ^
In file included from C:/Users/ujjwa/try_mic_espc6/edge-impulse-sdk/classifier/ei_model_types.h:42:
C:/Users/ujjwa/try_mic_espc6/edge-impulse-sdk/dsp/numpy.hpp:54:10: fatal error: cfloat: No such file or directory
   54 | #include <cfloat>
      |          ^~~~~~~~

If you have any idea about what might be wrong, let me know. I will try to correct the errors

1 Like

Thanks for the information, @ujjwalrathod007 !
Two thoughts:

  1. You are using ESP IDF 5.5.0, while we created the example and tested with 5.1.0 (see here GitHub - edgeimpulse/example-standalone-inferencing-espressif-esp32: Builds and runs an exported impulse locally (ESP IDF)). Probably not the source of the current issue, but something to keep in mind!
  2. More importantly you are using Windows… We test building on MacOS / Linux, since compiling C/C++ applications on Windows is … not as convenient as in MacOS / Linux. In my experience there is a lot of intricacies with setting up the right toolchain on Win - and the issue in your example is clearly with your C/C++ setup, as we have it tested every day in CI
    My advice would be to install WSL and work with ESP IDF there:
    Using WSL in Windows - - β€” ESP-IDF Extension for VSCode latest documentation

Ok, I have another PC with Linux and esp-idf. I will try that and let you know.

Hello,

I have tried this sample on Linux PC and I am getting some linking errors as follows. At first, I got some errors including files such as dsp_err.h but after copy paste those files I got the following errors.!

/home/ujjval/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/main/libmain.a(main.cpp.obj):(.literal._ZN2ei3fftL10hw_r2c_fftEPKfPNS_13fft_complex_tEj+0x1c): undefined reference to `dsps_fft_w_table_fc32'
/home/ujjval/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/main/libmain.a(main.cpp.obj):(.literal._ZN2ei3fftL10hw_r2c_fftEPKfPNS_13fft_complex_tEj+0x24): undefined reference to `dsps_fft2r_init_fc32'
/home/ujjval/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/main/libmain.a(main.cpp.obj):(.literal._ZN2ei3fftL10hw_r2c_fftEPKfPNS_13fft_complex_tEj+0x28): undefined reference to `dsps_fft2r_fc32_ansi_'
/home/ujjval/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/main/libmain.a(main.cpp.obj):(.literal._ZN2ei3fftL10hw_r2c_fftEPKfPNS_13fft_complex_tEj+0x2c): undefined reference to `dsps_bit_rev_fc32_ansi'
/home/ujjval/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: esp-idf/main/libmain.a(main.cpp.obj): in function `_ZN2ei3fftL10hw_r2c_fftEPKfPNS_13fft_complex_tEj':
/home/ujjval/esp/esp-idf/example-standalone-inferencing-espressif-esp32/edge-impulse-sdk/dsp/dsp_engines/ei_esp_dsp.h:37:(.text._ZN2ei3fftL10hw_r2c_fftEPKfPNS_13fft_complex_tEj+0x2c): undefined reference to `dsps_fft2r_init_fc32'
/home/ujjval/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: /home/ujjval/esp/esp-idf/example-standalone-inferencing-espressif-esp32/edge-impulse-sdk/dsp/dsp_engines/ei_esp_dsp.h:67:(.text._ZN2ei3fftL10hw_r2c_fftEPKfPNS_13fft_complex_tEj+0xcd): undefined reference to `dsps_fft2r_fc32_ansi_'
/home/ujjval/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: /home/ujjval/esp/esp-idf/example-standalone-inferencing-espressif-esp32/edge-impulse-sdk/dsp/dsp_engines/ei_esp_dsp.h:73:(.text._ZN2ei3fftL10hw_r2c_fftEPKfPNS_13fft_complex_tEj+0xf0): undefined reference to `dsps_bit_rev_fc32_ansi'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
ninja failed with exit code 1, output of the command is in the /home/ujjval/esp/esp-idf/example-standalone-inferencing-espressif-esp32/build/log/idf_py_stderr_output_21400 and /home/ujjval/esp/esp-idf/example-standalone-inferencing-espressif-esp32/build/log/idf_py_stdout_output_21400
1 Like