Skip to main content
Associate II
August 8, 2025
Solved

Problems using fftw3 with STM32MP157f-dk2

  • August 8, 2025
  • 2 replies
  • 338 views

Hello, I need to do FFT transforms of long signal traces, so  using CMSIS DSP doesn't look possible because of the 4096 points limit. I tried to use fftw3 library (3.3.10). I built it using OpenSTLinux SDK from the Github source without problem. Here is configuration I used: 

configure --host=arm-ostl-linux-gnueabi --enable-neon --enable-single --with-slow-timer

Library libfftw3f.a  was built successfully and test app was also successfully linked with it. Here is relevant part of the test app code:

int fft_points = 131072;

fftwf_plan pr2c, pc2r;
fftwf_complex* fft_cbuf = 0;
float* fft_buf = 0;
fft_cbuf = (fftwf_complex *)fftwf_malloc(sizeof(fftwf_complex)*(fft_pts/2 + 1));
memset(fft_cbuf, 0, sizeof(fftwf_complex)*(fft_pts/2 + 1));
fft_buf = (float *)fftwf_malloc((fft_pts + 2) * sizeof(float)); 
memset(fft_buf, 0, (fft_pts + 2) * sizeof(float));
printf("allocated buffers: %p, %p\n", fft_cbuf, fft_buf);
pr2c = fftwf_plan_dft_r2c_1d(fft_pts, fft_buf, fft_cbuf, FFTW_ESTIMATE);    // Segmentaion fault crash here
printf("created pr2c\n");
pc2r = fftwf_plan_dft_c2r_1d(fft_pts, fft_cbuf, fft_buf, FFTW_ESTIMATE);
printf("created pc2r\n");

When program runs, it crashes with "Segmentation fault (core dumped)" while trying to create first fft plan.
Is there something I missed, some compilation flag maybe? Any advice is appreciated.
Thanks in advance.
 
 
This topic has been closed for replies.
Best answer by DevESG

No, it's actually real FFT, so it's like 64K complex. Turned out I didn't need to build fftw3 library myself. I'm new to STM32 development and didn't realize that Developer Package comes with shared libfftw3 libraries. When I used provided 3.6.10 library I didn't have any problem to build and run my app. Test app ran fine even with double type FFT transform.

2 replies

AScha.3
Super User
August 9, 2025

Hi,

So you want to do a 128K FFT complex in float, 

that's needing a lot of memory - sure, that enough RAM is free, for input and output arrays?

Malloc...is okay ?

 

If you feel a post has answered your question, please click on " Best Answer ".
DevESGAuthorBest answer
Associate II
August 9, 2025

No, it's actually real FFT, so it's like 64K complex. Turned out I didn't need to build fftw3 library myself. I'm new to STM32 development and didn't realize that Developer Package comes with shared libfftw3 libraries. When I used provided 3.6.10 library I didn't have any problem to build and run my app. Test app ran fine even with double type FFT transform.