Page 1 of 1

CMSIS DSP Library

Posted: Mon Aug 04, 2014 8:28 pm
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.

Re: CMSIS DSP Library

Posted: Mon Aug 04, 2014 10:49 pm
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

Re: CMSIS DSP Library

Posted: Tue Aug 05, 2014 12:02 am
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

Re: CMSIS DSP Library

Posted: Tue Aug 05, 2014 8:20 am
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

Re: CMSIS DSP Library

Posted: Tue Aug 05, 2014 11:53 am
by mobyfab
Did you compile the lib yourself or use a binary ?

Re: CMSIS DSP Library

Posted: Tue Aug 05, 2014 12:03 pm
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.

Re: CMSIS DSP Library

Posted: Tue Aug 05, 2014 12:07 pm
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.

Re: CMSIS DSP Library

Posted: Tue Aug 05, 2014 12:20 pm
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

Re: CMSIS DSP Library

Posted: Wed Aug 06, 2014 11:44 am
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.

Re: CMSIS DSP Library

Posted: Wed Aug 06, 2014 2:06 pm
by dflogeras
Thanks Fabien, that helps a lot!