Jump to content
doragasu

Anyone building CMSIS under Linux?

Recommended Posts

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!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 ¬_¬

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites

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???

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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 :(

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×