ARMmbed / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
4.67k stars 2.98k forks source link

How to install CMSIS DSP functions such as FFT etc? #14163

Closed jerabaul29 closed 3 years ago

jerabaul29 commented 3 years ago

I am writing some code for the Sparkfun Artemis board, which has got an MBed-OS core (see here: https://github.com/sparkfun/Arduino_Apollo3 ).

I want to use FFTs as provided by CMSIS in their DFT package: https://github.com/ARM-software/CMSIS_5/tree/develop/CMSIS/DSP/Source/TransformFunctions

However, this does not work out-of-the-box. Trying to compile the following snippet:

#define ARM_MATH_CM4  // The apollo3 is a cortex M4

#include "mbed.h"
#include "arm_math.h"

/* FFT settings */
constexpr int SAMPLES  = 512;           /* 256 real party and 256 imaginary parts */
constexpr int FFT_SIZE = SAMPLES / 2;   /* FFT size is always the same size as we have samples, so 256 in our case */
constexpr uint8_t forward_fft = 0;
constexpr uint8_t backward_fft = 0;

// Global variables for taking FFT
float32_t fft_input[SAMPLES];
float32_t fft_output[FFT_SIZE];

void setup() {

  // compute a FFT
  arm_rfft_fast_instance_f32 crrt_arm_rfft_fast_instance_f32;
  arm_rfft_fast_init_f32(&crrt_arm_rfft_fast_instance_f32, FFT_SIZE);                         // get ready
  arm_rfft_fast_f32(&crrt_arm_rfft_fast_instance_f32, fft_input, fft_output, forward_fft);    // take the FFT
}

void loop() {
  // put your main code here, to run repeatedly:

}

results in:

/home/jrmet/Desktop/Git/Artemis_MbedOS_recipes/recipes/recipe_FFT/recipe_FFT.ino:23: undefined reference to `arm_rfft_fast_init_f32'
/home/jrmet/.arduino15/packages/SparkFun/tools/arm-none-eabi-gcc/8-2018-q4-major/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld: /home/jrmet/Desktop/Git/Artemis_MbedOS_recipes/recipes/recipe_FFT/recipe_FFT.ino:24: undefined reference to `arm_rfft_fast_f32'
collect2: error: ld returned 1 exit status
exit status 1

I understand that this means that only (some) headers are provided, but that the actual compiled binaries / FFT function sources are not available. Is this the right understanding?

Then my questions are:

I am still a bit unsure of where the problem lies / what should be fixed where. I have discussed this on CMSIS (https://github.com/ARM-software/CMSIS_5/issues/1097) but from the discussion there is seems that should be discussed here rather. I also tried to discuss this on the Artemis Arduino core but without much results at the moment (https://github.com/sparkfun/Arduino_Apollo3/issues/326).

ciarmcom commented 3 years ago

@jerabaul29 This issue has an incomplete or old issue template.For future reference please use an up to date clone of the repository before raising issues. Many thanks.

ciarmcom commented 3 years ago

Thank you for raising this detailed GitHub issue. I am now notifying our internal issue triagers. Internal Jira reference: https://jira.arm.com/browse/IOTOSM-3261

0xc0170 commented 3 years ago

where is arm_rfft_fast_f32 defined? I found it here https://github.com/ARM-software/CMSIS_5/blob/develop/CMSIS/DSP/Source/TransformFunctions/arm_rfft_fast_f32.c#L575 . Is it really visible to a linker ?

It should work to download dsp, add it to an application, configure it (I would assume it requires some symbols to be present, they either come from cmsis/mbed files or an application - I would start there to check if the configuration is done).

As this is rather a question, I'll close this (the predefined issue template was not used neither).