Jump to content

  •  

Photo

Anyone building CMSIS under Linux?

cmsis gcc

  • Please log in to reply
32 replies to this topic

#1 doragasu

doragasu

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts


Posted 12 November 2012 - 12:08 PM

I have recently received my Stellaris Launchpad and I'm building a toolchain to code for it using GNU+Linux.

So far I have the cross compiler+lm4tools+stellarisware running. I can build the stellaris examples and flash them without problems.

As I want to do some signal processing with my board, I'd like to build the CMSIS library. At least the DSPLib part (I don't need the RTOS right now). The library zip file has some scripts to build it using Keil, but as I'm a GNU+Linux user, I can't run Keil IDE.

Also unfortunately, I'm a total noob when talking about autotools, so...

Has anyone been able to build this library using GCC? Does anyone have a Makefile to automate building it?

Thanks in advance!
  • skaidaif likes this

#2 bluehash

bluehash

    Administrator

  • Administrators
  • 863 posts
  • LocationWaltham, MA

Posted 12 November 2012 - 01:06 PM

I have recently received my Stellaris Launchpad and I'm building a toolchain to code for it using GNU+Linux.

So far I have the cross compiler+lm4tools+stellarisware running. I can build the stellaris examples and flash them without problems.

As I want to do some signal processing with my board, I'd like to build the CMSIS library. At least the DSPLib part (I don't need the RTOS right now). The library zip file has some scripts to build it using Keil, but as I'm a GNU+Linux user, I can't run Keil IDE.

Also unfortunately, I'm a total noob when talking about autotools, so...

Has anyone been able to build this library using GCC? Does anyone have a Makefile to automate building it?

Thanks in advance!

You should be able to once you add the appropriate .c and .h includes into the stellaris makefile, unless you are tryiing to make a cmsis library.
C2KCentral - C2000 News, Projects and Forums | 43oh - MSP430 Discussion, News and Projects. | Stellarisiti - Stellaris ARM Forums, Projects and News.

#3 doragasu

doragasu

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts


Posted 12 November 2012 - 02:09 PM

I'd like to build it as a separate library. I can try building the Makefile, but I'm pretty busy right now, and I was asking just in case anyone has already done it and can save me some time.

#4 bluehash

bluehash

    Administrator

  • Administrators
  • 863 posts
  • LocationWaltham, MA

Posted 12 November 2012 - 05:07 PM

This TI pdf tell you how to build one in CCS.
Using the CMSIS DSP Library in CCS for Stellaris
C2KCentral - C2000 News, Projects and Forums | 43oh - MSP430 Discussion, News and Projects. | Stellarisiti - Stellaris ARM Forums, Projects and News.

#5 doragasu

doragasu

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts


Posted 13 November 2012 - 08:15 AM

Thanks again for help. I already knew that PDF, and had a look at it, but the procedure is full of TI compiler related stuff that I suspect is not necessary when building with GCC.

Past weekend I tried compiling a single DSPLib file and it worked flawlessly. I suspect writing a dirty Makefile that does the work will not be very painful even for an autotools noob like me. I just need to get some spare time, sit down and write it ¬_¬

#6 bluehash

bluehash

    Administrator

  • Administrators
  • 863 posts
  • LocationWaltham, MA

Posted 13 November 2012 - 01:09 PM

Thanks again for help. I already knew that PDF, and had a look at it, but the procedure is full of TI compiler related stuff that I suspect is not necessary when building with GCC.

Past weekend I tried compiling a single DSPLib file and it worked flawlessly. I suspect writing a dirty Makefile that does the work will not be very painful even for an autotools noob like me. I just need to get some spare time, sit down and write it ¬_¬

Its a learning experience. I'm sure you will learn alot doing it. Ask for help if you run into problems. Also, make sure you document your work here in a thread or you could also use the blog section in your account.
C2KCentral - C2000 News, Projects and Forums | 43oh - MSP430 Discussion, News and Projects. | Stellarisiti - Stellaris ARM Forums, Projects and News.

#7 doragasu

doragasu

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts


Posted 13 November 2012 - 09:43 PM

I had some time and started writing a test makefile, that builds all .c files inside a DSPLib subdirectory and creates a library with them:

PART=LM4F120H5QR
PREFIX=arm-none-eabi-
CC=gcc
AR=ar
RM=rm
TEST_PATH=DSP_Lib/Source/BasicMathFunctions/

CFLAGS = -mthumb             \
         -mcpu=cortex-m4     \
         -mfpu=fpv4-sp-d16   \
         -mfloat-abi=softfp  \
         -Os                 \
         -ffunction-sections \
         -fdata-sections     \
         -std=c99            \
         -Wall               \
         -DPART_${PART}      \
         -DARM_MATH_CM4      \
         -D__FPU_PRESENT     \
         -IInclude

objects := $(patsubst $(TEST_PATH)%.c,obj/%.o,$(wildcard $(TEST_PATH)*.c))

testlib: test
        $(PREFIX)$(AR) rcs testlib.a $(objects)

test: $(objects)

obj/%.o: $(TEST_PATH)%.c
        $(PREFIX)$(CC) $(CFLAGS) -c $< -o $@

clean:
        @$(RM) -f $(objects) 
        @$(RM) -f testlib.a

It worked as expected. The build process throws a lot of warnings like this:
Include/arm_math.h: In function 'arm_pid_q15':
Include/arm_math.h:4828:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

But I suppose I can ignore them. When I get some more time, I'll try to add all the directories to the process and build the entire library. I hope it works :)
  • bluehash likes this

#8 bluehash

bluehash

    Administrator

  • Administrators
  • 863 posts
  • LocationWaltham, MA

Posted 13 November 2012 - 10:19 PM

Awesome! Thanks.
C2KCentral - C2000 News, Projects and Forums | 43oh - MSP430 Discussion, News and Projects. | Stellarisiti - Stellaris ARM Forums, Projects and News.

#9 doragasu

doragasu

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts


Posted 17 November 2012 - 07:20 PM

I have built two makefiles. The first is the top-level one, and the second must be copied in each dsplib subfolder. Both share another file with constants:

Makefile.inc
Top level Makefile
Bottom level Makefile

Calling "make dsplib" builds the library. But unfortunately I have not been able to build the examples against it. This is what happens when I try to build arm_class_marks_example_f32.c:

$ arm-none-eabi-gcc -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -Os -ffunction-sections -fdata-sections -std=c99 -Wall -DPART_LM4F120H5QR -DARM_MATH_CM4 -D__FPU_PRESENT -I../../../Include -L../../../Lib -ldsplib_lm4f arm_class_marks_example_f32.c -o arm_class_marks_example_f32
In file included from arm_class_marks_example_f32.c:67:0:
../../../Include/arm_math.h: In function 'arm_pid_q15':
../../../Include/arm_math.h:4828:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
arm_class_marks_example_f32.c: At top level:
arm_class_marks_example_f32.c:139:9: warning: return type of 'main' is not 'int' [-Wmain]
/tmp/ccAAxx9S.o: In function `main':
arm_class_marks_example_f32.c:(.text.startup.main+0x2e): undefined reference to `arm_mat_mult_f32'
arm_class_marks_example_f32.c:(.text.startup.main+0x3a): undefined reference to `arm_max_f32'
arm_class_marks_example_f32.c:(.text.startup.main+0x46): undefined reference to `arm_min_f32'
arm_class_marks_example_f32.c:(.text.startup.main+0x50): undefined reference to `arm_mean_f32'
arm_class_marks_example_f32.c:(.text.startup.main+0x5a): undefined reference to `arm_std_f32'
arm_class_marks_example_f32.c:(.text.startup.main+0x64): undefined reference to `arm_var_f32'
/home/jalon/sat/lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): In function `exit':
/home/jalon/src/stellaris/summon-arm-toolchain/build/arm-none-eabi/newlib/libc/stdlib/../../../../../gcc-linaro-4.6-2011.10/newlib/libc/stdlib/exit.c:65: undefined reference to `_exit'
collect2: ld returned 1 exit status

I could understand the error about the linker not finding _exit symbol, but I can't really understand why the linker is not finding arm_* functions. I'm linking against the library, and if I browse the symbols inside the library using nm command, I can see the problematic functions. For example:

$ arm-none-eabi-nm ../../../Lib/libdsplib_lm4f.a | grep arm_mat_mult_f32
arm_mat_mult_f32.o:
00000000 T arm_mat_mult_f32

What am I doing wrong???

#10 doragasu

doragasu

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts


Posted 17 November 2012 - 08:25 PM

I got the first example to build. I have built the .o file separately and then linked it using ld. Also had to add "--gc-sections -Thello.ld" options. The first one to eliminate the errors about ld not being able to find symbols in dsplib, and the second one to fix a warning about _start symbol not being found. hello.ld is a linker file copied from stellarisware files. The resulting ld invocation:

$ arm-none-eabi-ld --gc-sections -L ../../../Lib -ldsplib_lm4f -Thello.ld arm_class_marks_example_f32.o -o arm_class_marks_example_f32

Unfortunately these examples are made to be tested using a simulator or a debugger. I have yet to set up my debugger. Is there a tutorial anywhere?

#11 bluehash

bluehash

    Administrator

  • Administrators
  • 863 posts
  • LocationWaltham, MA

Posted 18 November 2012 - 06:29 AM

ntfreak has openocd running with the Stellaris launchpad's ICDI:
http://forum.stellar...enocd/#entry549
C2KCentral - C2000 News, Projects and Forums | 43oh - MSP430 Discussion, News and Projects. | Stellarisiti - Stellaris ARM Forums, Projects and News.

#12 doragasu

doragasu

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts


Posted 19 November 2012 - 07:47 PM

New makefile for building cmsis examples. It uses startup code and linker script from scompo.

#13 Bingo600

Bingo600

    Advanced Member

  • Members
  • PipPipPip
  • 46 posts

Posted 21 November 2012 - 07:23 PM

@doragasu

Arm is moving CMSIS from http://onarm.com to http://arm.com/cmsis , including the CMSIS forum to http://forums.arm.com/

There is a CMSIS v3.01 (CMSIS-SP-00300-r3p1-00rel0.zip) on arm.com.

Ohh if anyone want to share their Stellarisware Makefiles (for arm-gcc) , that would be nice


/Bingo
  • bluehash likes this

#14 doragasu

doragasu

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts


Posted 22 November 2012 - 08:21 AM

Thanks for the info. You can already find my makefiles shared in this post. Using them I have successfully built CMSIS3.0 DSPLib. I have to test if it also works for 3.01 version.

Yesterday I also started writing some tutorials for Stellaris Launchpad development under Linux. Eventually I'll write one about building CMSIS, so stay tuned!
  • bluehash and xpg like this

#15 doragasu

doragasu

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts


Posted 28 November 2012 - 02:10 PM

I have built the FIR filtering example, but there's a weird problem with it. When I call the arm_fir_init_f32 function, a hard fault exception (NVIC3) is raised. I have debugged the CMSIS function, and this exception is raised when it cals memset function. The parameters passed to memset function are OK. What can be causing this exception? I really have no clue :(

#16 bluehash

bluehash

    Administrator

  • Administrators
  • 863 posts
  • LocationWaltham, MA

Posted 28 November 2012 - 05:12 PM

Try increasing your stack a little.
C2KCentral - C2000 News, Projects and Forums | 43oh - MSP430 Discussion, News and Projects. | Stellarisiti - Stellaris ARM Forums, Projects and News.

#17 doragasu

doragasu

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts


Posted 29 November 2012 - 10:38 AM

I don't think that's the problem, but sure it's worth a try. Thanks for the suggestion, I'll try it ASAP.

This is what the datasheet says about hard faults:

Hard Fault. A hard fault is an exception that occurs because of an error during exception
processing, or because an exception cannot be managed by any other exception mechanism.
Hard faults have a fixed priority of -1, meaning they have higher priority than any exception with
configurable priority.


No other exception is triggered before the hard fault (I have an empty handler with a while(1); to catch all unused exceptions), and memset is not called while processing other exception, so for me it doesn't make sense that a hard fault exception is raised.

Reading a bit more, chapter 2.6.1 states that a hard fault can be caused also by a "Bus error on a vector read". I don't really know what that means exactly ¿?.

I'll also have to try reading HFAULTSTAT register to see if it sheds some light...

#18 scompo

scompo

    Member

  • Members
  • PipPip
  • 16 posts


Posted 02 December 2012 - 06:17 PM

I don't know if you already saw this but here this guy used CMSIS dsp library to build an audio analyzer.

The code it's available here. Maybe you'll find this useful.



#19 doragasu

doragasu

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts


Posted 02 December 2012 - 08:32 PM

I already saw that, but that project is built using CCS. Building CMSIS with CCS is an entirely different process, but thanks for the tip anyway!



#20 jimk3038

jimk3038

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 02 January 2013 - 12:30 PM

Was any solution ever found for this problem? 

 

I hit the same issue while trying to get FreRTOS up and running.  Everything works great until memset is called - which seem to generate a hard fault.

 

Even TI's stock example "/stellarisware/boards/ek-lm4f120xl/freertos_demo/gcc/freertos_demo.bin" locks up.







Also tagged with one or more of these keywords: cmsis, gcc

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users