CMSIS-DSP support for the Adafruit NRF52 Arduino Boards

I was able to get big improvement on a siren detector by increasing the FFT size to 512 and the Filters to 64. Unfortunately, the DSP now takes 6sec for 2sec of audio. The Adafruit NRF52 board defs do not seem to support CMSIS for the DSP. It only takes about a 1sec of DSP on the Arduino Nano, which is built on MBed and supports CMSIS. I tried to force CMSIS for the DSP using EIDSP_USE_CMSIS_DSP & EIDSP_LOAD_CMSIS_DSP_SOURCES but I get the following error:

/src/edge-impulse-sdk/dsp/spectral/../numpy.hpp:1133: undefined reference to `arm_rfft_fast_f32'
/src/edge-impulse-sdk/dsp/spectral/../numpy.hpp:1141: undefined reference to `arm_rms_f32'

I am in way over my head, but it looks like support for CMSIS v5 has been included:

Is there a way to enable CMSIS-DSP support for CMSIS capable boards not based on MBed?

Hi @Robotastic, I’m not sure how the Adafruit boards do their include chain, and apparently declaring the macro early in the sketch does not work on these boards. But if you add the following lines to src/edge-impulse-sdk/dsp/config.hpp (in the libary folder) on line 26 it compiles for me:

#define EIDSP_USE_CMSIS_DSP		        1
#define EIDSP_LOAD_CMSIS_DSP_SOURCES    1

I don’t have the board so cannot verify how fast it runs, but would be great if you could report back.

Ah - of course! I added that to config.hpp instead of the Arduino sketch and it worked perfectly. It brought the DSP time down from 6000ms to 1300ms for 2s of audio!

It doesn’t look like Adafruit is defining __TARGET_CPU_CORTEX_M4 or something like that. I looked through their code, but didn’t see any similar macros being defined.

1 Like

Yeah this is the pain with Arduino. Very loosely defined spec for the HAL and no default macros for mcu family or capabilities… and no way to set macros from the IDE unfortunately either.

Just wanted to report back that making a similar change also enables CMSIS for inference.

Add #define EI_CLASSIFIER_TFLITE_ENABLE_CMSIS_NN 1 to line 26 of edge-impulse-sdk/classifier/ei_classifier_config.h

1 Like