PlatformIO Community

Project using arm_math.h on nRF52 results in Linker Error


#1

I have created a Project for nRF52_dk using Arduino Framework. I’m try to use FFT supported by the CM4 on this device.
Every time i’m got a linker error: undefined reference to `arm_cfft_radix4_init_f32’

What I’m missing ? or how i do it correctly? Please Help

nRF52 V3.4
PlatformIO IDE for VsCode


#2

In what file is that function implemented?


#3

It should be a part of the sdk im think. Im including the arm_math.h. The Funktion is declared in this header file.
After some research. This are parts of the arm dsp package. I dont found the Implementation.


#4

Can you upload your project on github for reproduction?


#5

is uploded on https://github.com/enny1170/Nrf52DspTest


#6

For some reason unknown to me, https://github.com/sandeepmistry/arduino-nRF5/tree/master/cores/nRF5/SDK/components/toolchain/CMSIS/Include gives you the arm_math.h and related header files, but doesn’t actually include the library file where the functions are implemented…

You can either:

  • compile the CMSIS-DSP library from the source files (here)
  • tell the linker to link against the statically compiled library

I’ll do the latter because it’s easier. The libraries are compiler per Cortex flavour, so you have the Cortex-M3, M4, M4F (M4 + FPU) etc. Your nrf52_dk board has a nRF52832 which is in turn a "The ARM® Cortex®-M4 processor with floating-point unit (FPU) " (here, here), i.e. an M4F. However, PlatformIO compiles the firmware using soft-float instead of hard-float (-mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16, here), which means we actually have to use the link-compatible M4 type. See here for an explanation on float-ABIs.

To make the project compile, do:

  • download libarm_cortexM4l_math.a from here
  • place the file in your project folder
  • add the line build_flags = -l arm_cortexM4l_math to the the build environment of the [env:nrf52_dk]
  • observe [SUCCESS] Took 10.10 seconds at the end of the compilation :slight_smile:

#7

Thank you verry much. Works perfekt . Im use the build flag. Perfect and fast solution.


#8

Hello Maxgerhard, sorry that i’m comback to this issue.
But after successfully compiling the Project, i run into another issue.
After copy the elf over to the nrf52_dk, this is not running.
I have try to do some Serial.print and digital write for toggle the OnBoard led in the Setup method. but Nothing happens. So i guess that something is wrong with the linked Code.
I have updated the Project on GitHub to Show you what i have done. Do you have any idea ?


#9

Did you do the negative test? I.e., remove all references to arm_math.h and don’t link against the library, just do a basic Serial.begin() and print. Does that show up?


#10

Yes i do it, and ist works as expected.