CMSIS DSP Library

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
dflogeras
Posts: 232
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 8 times
Been thanked: 22 times

CMSIS DSP Library

Post by dflogeras »

Hi

I'm playing around with a C++ project based on the STM32F4-DISCOVERY-G++ example.

I want to integrate the CMSIS DSP Library to play around with realtime processing of some sort. I've downloaded it from arm.com (Version 3.01) and am attempting to use it. I have added CMSIS/Include to my UINCDIR and CMSIS/Lib/GCC to ULIBDIR. I've linked with -larm_cortexM4lf_math (although I've also tried the one in CMSIS/Lib/G++ with no luck).

The project at the moment is not much more than a glorified blinky (single blinker thread flashing LED4).

What seems to happen, even if I do not call any functions from the library, is after flashing (I use the texane stlink utilities), the program runs; sometimes flashing the LED, sometimes crashes. When I attempt to hook gdb up, it's usually off in la-la land:

Code: Select all

#0  0x00000000 in ?? ()
#1  <signal handler called>
#2  0x00000000 in ?? ()
#3  0x00000000 in ?? ()


Oddly, I cannot even reset the board, it usually requires re-flashing it. Sometimes I can re-flash and get it to stop on a break point, but it usually ends up in a weird state after single-stepping a few times. I've also seen it end up in unhandled_exception() handler, and also __gnu_unwind_execute() with no returning.

I've enabled all DBG options in chconf.h to no avail. I've tried increasing the stack (I noticed several large global static arrays[] in the CMSIS code, but un-sure if that requires stack space?)

What else can I try? I find it odd that the board cannot even be reset by gdb.

All goes away if I do not link to CMSIS library.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: CMSIS DSP Library

Post by Giovanni »

Does the library call C runtime functions like allocation or similar? if so you have to provide the syscall module for newlib.

Giovanni
dflogeras
Posts: 232
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 8 times
Been thanked: 22 times

Re: CMSIS DSP Library

Post by dflogeras »

Is there a command to programmatically grab all of the syscalls from a .a archive?

On first glance, I can see the CMSIS library calls memset, and sqrtf at least. How does one provide the syscall module?

Thanks
Dave
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: CMSIS DSP Library

Post by Giovanni »

There is one syscall module under ./os/various but it could not be compatible with your compiler/library setup. You need to read the newlib documentation.

Anyway, it is not sure that is the problem unless there is memory allocation involved.

Giovanni
mobyfab
Posts: 484
Joined: Sat Nov 19, 2011 6:47 pm
Has thanked: 21 times
Been thanked: 31 times

Re: CMSIS DSP Library

Post by mobyfab »

Did you compile the lib yourself or use a binary ?
dflogeras
Posts: 232
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 8 times
Been thanked: 22 times

Re: CMSIS DSP Library

Post by dflogeras »

Giovanni wrote:There is one syscall module under ./os/various but it could not be compatible with your compiler/library setup. You need to read the newlib documentation.

Anyway, it is not sure that is the problem unless there is memory allocation involved.

Giovanni


Hmm, the only outside functions I see after invoking nm are:
    __aeabi_d2f
    __aeabi_d2iz
    __aeabi_dadd
    __aeabi_ddiv
    __aeabi_dmul
    __aeabi_f2d
    __aeabi_f2lz
    __aeabi_ldivmod
    __aeabi_ui2d
    memset
    sqrtf

How can I proceed debugging this? I can attempt to boil it down to the simplest main.cpp and Makefile.
dflogeras
Posts: 232
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 8 times
Been thanked: 22 times

Re: CMSIS DSP Library

Post by dflogeras »

mobyfab wrote:Did you compile the lib yourself or use a binary ?


I have tried linking to both these libraries from CMSIS 3.01:
    CMSIS/Lib/GCC/libarm_cortexM4lf_math.a
    CMSIS/Lib/G++/libarm_cortexM4lf_math.a

I have also attempted to add the relevant .c sources to my project and compiling them in. Finally, I found this project https://github.com/fpoussin/ChibiOS-Examples/tree/master/STM32F4-LCD-DSP and used the static library that it ships with. None of the above worked.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: CMSIS DSP Library

Post by Giovanni »

Isn't there somewhere a dedicated forum? apparently this is not related to integration with ChibiOS, it is a more general problem.

Giovanni
mobyfab
Posts: 484
Joined: Sat Nov 19, 2011 6:47 pm
Has thanked: 21 times
Been thanked: 31 times

Re: CMSIS DSP Library

Post by mobyfab »

dflogeras wrote:
mobyfab wrote:Did you compile the lib yourself or use a binary ?


I have tried linking to both these libraries from CMSIS 3.01:
    CMSIS/Lib/GCC/libarm_cortexM4lf_math.a
    CMSIS/Lib/G++/libarm_cortexM4lf_math.a

I have also attempted to add the relevant .c sources to my project and compiling them in. Finally, I found this project https://github.com/fpoussin/ChibiOS-Examples/tree/master/STM32F4-LCD-DSP and used the static library that it ships with. None of the above worked.


This is one of my "old" projects.

Give this one a try:
https://github.com/fpoussin/MotoLink/tr ... pp/dsp_lib

You should try to build it yourself as you might use a different compiler from mine. (just run make distclean, then make)
It solves some of the conflicts with ChibiOS's arm math headers.
dflogeras
Posts: 232
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 8 times
Been thanked: 22 times

Re: CMSIS DSP Library

Post by dflogeras »

Thanks Fabien, that helps a lot!
Post Reply