Unable to use the FFT functions defined in arm_math.h. Undefined reference to arm_rfft_q15()

Hello everyone,
I am trying to use the function arm_rfft_q15() which is defined in line 2208 [here][1]. My code is as follows:

 #define ARM_MATH_CR3
 #undef A0
 #undef A1
 #undef A2
 #include "arm_math.h"

const arm_rfft_instance_q15 *fft;

void runFFT(const arm_rfft_instance_q15 *fft, int16_t *p, int16_t *q);

int16_t random_array[1024], outputbuf[1024];

void loop()
{
    runFFT(fft, random_array, outputbuf);
    delay(1000);
}

void runFFT(const arm_rfft_instance_q15 *fft, int16_t *p, int16_t *q)
{
   /*for(int a=0; a<1024; a++){
     Serial.print(p[a]); Serial.print(" ");
   }*/
   arm_rfft_q15(fft, p, q);
   for(int a=0; a<1024; a++){
     Serial.print(q[a]); Serial.print(" ");
   }
}

Warnings and Errors:

UNDEFINED REFERENCE TO THE FUNCTION. I am using particle flash devicename test.ino to flashing the device. I think I am not linking the required library file. I tried to add -lm at the end but it didn’t work. Any help would be appreciated. Thanks.
[1]: https://github.com/spark/firmware/blob/develop/platform/MCU/STM32F2xx/CMSIS/Include/arm_math.h

Hello,
[Update] - I went through the github repository and found that the transform function .c files are missing. So I added them to my project from the ARM repository here. After adding all the relavant files, I get undefined reference to arm_bitreversal_16.

This function is defined in this assembly file. How do I link this during compilation using the CLI? I am using
particle compile photon dir to build my project

Thanks

1 Like

Hi
I am trying to do the same (use CMSIS real fft functions for my application targetted for Photon). I am stuck at the same. I was blindly copying header/ source files from the CMSIS code tree into my application, however I have hit the dependency on the assembly files.
@dheerajdake Hi, I just wanted to know if you were able to do the integration or did you use any other FFT library.

Hello Susom,
I used monolithic build and removed the code causing this in the assembly file to make it work.

Thanks
Dheeraj

It’s not possible to include .S assembly files in a Particle CLI (or Particle Build or Particle Dev) build.

You either have to convert the assembly file into inline assembly in a .cpp file, or use the gcc-arm local build with a minor Makefile change to build the .S files.

1 Like

Hi
Thanks @dheerajdake and @rickkas7. Yeah I have been trying quite a couple of things but am stuck at the assembly code assembly in the flow of the fft code in CMSIS and cannot seem to get around it. The problem of inlining this code is it is in Intel syntax because of which it is not a straight forward inline and I cannot understand the complete assembly code as to rewrite it since it’s doing some pretty low level stuffs.

CMSIS comes with some prebuilt static libraries I tried compiling my Photon app linking it to the static library (CMSIS/Lib/GCC/libarm_cortexM3l_math.a, in the CMSIS archive) however I am getting a lot of errors from the library.

Has any 1 ever tried this. Would sincerely appreciate some advise.

Thanks
Subhojit