This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/PROCESSOR-SDK-AM335X: Add cross compiling flag with

Part Number: PROCESSOR-SDK-AM335X


Tool/software: Code Composer Studio

Goodmorning,

I'm using a Beaglebone black and currently I can cross compile and directly execute an application, which uses Xenomai, using CCS and creating the project type "Makefile project with Existing Code". I used the following Makefile where the application name is: cyclic_test.

MAIN_SRC    = cyclic_test
TARGET        = cyclic_test

SKIN         := alchemy
CFLAGS         := $(shell /usr/xenomai/bin/xeno-config --skin=$(SKIN) --cflags)
LDFLAGS     := $(shell /usr/xenomai/bin/xeno-config --skin=$(SKIN) --ldflags)
#CC             := $(shell /usr/xenomai/bin/xeno-config --cc)
CC            := /home/davide/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc

all: $(TARGET)

$(TARGET):$(MAIN_SRC).c
        $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)

clean:
        @rm $(MAIN_SRC)

Now I would like to use in CCS, the standard project type "C Project". As you can see, the Makefile use a script "xeno-config" to generate the several settings and flags. Is it possible to do this kind of settings here?

Thank you.

Best Regards,

Davide Brunelli

  • Davide,

    The screenshot did not go through, but you can use the Pre and Post build steps to execute scripts that may fulfill part of this functionality. Keep in mind that the managed project in Eclipse/CCS comes with its own build flags set via the interface, therefore you need to be careful in verifying any potential clashes. 

    Check section 6.1.3.4 of the CCS User's Guide at:

    https://software-dl.ti.com/ccs/esd/documents/users_guide/index.html 

    And the Eclipse help at:

    https://help.eclipse.org/photon/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Freference%2Fcdt_u_prop_build_settings_steps.htm 

    Hope this helps,

    Rafael

  • Hello desouza,

    thank you for your answer, I studied the documentation that you provided me. Actually before receiving your message, searching in the net for modifing the generated Makefile, I found that many people modify the compiling and linker settings.

    First I defined two Build Variables in C/C++ Build -> Build Variables:

    CFLAGS = $(shell /usr/xenomai/bin/xeno-config --skin=alchemy --cflags)

    LDFLAGS = $(shell /usr/xenomai/bin/xeno-config --skin=alchemy --ldflags)

    Then I modify the Command line pattern in C/C++ Build -> Settings -> Tool Settings -> Cross GCC Compiler as:

    ${COMMAND} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} ${CFLAGS} ${LDFLAGS}

    At last I modified the Command line pattern in C/C++ Build -> Settings -> Tool Settings ->Cross GCC Linker as:

    ${COMMAND} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} ${CFLAGS} ${LDFLAGS}

    As a result, I obtain the following:

    09:03:58 **** Build of configuration Release for project XenomaiTest ****
    make all 
    Building file: ../cyclic_test.c
    Invoking: Cross GCC Compiler
    arm-linux-gnueabihf-gcc -o "cyclic_test.o" "../cyclic_test.c" -I/usr/xenomai/include/cobalt -I/usr/xenomai/include -march=armv7-a -mfpu=vfp3 -D_GNU_SOURCE -D_REENTRANT -fasynchronous-unwind-tables -D__COBALT__ -I/usr/xenomai/include/alchemy -Wl,--no-as-needed -Wl,@/usr/xenomai/lib/modechk.wrappers -lalchemy -lcopperplate /usr/xenomai/lib/xenomai/bootstrap.o -Wl,--wrap=main -Wl,--dynamic-list=/usr/xenomai/lib/dynlist.ld -L/usr/xenomai/lib -lcobalt -lmodechk -lpthread -lrt -march=armv7-a -mfpu=vfp3  
    Finished building: ../cyclic_test.c
     
    Building target: XenomaiTest
    Invoking: Cross GCC Linker
    arm-linux-gnueabihf-gcc -o "XenomaiTest"  ./cyclic_test.o    -Wl,--no-as-needed -Wl,@/usr/xenomai/lib/modechk.wrappers -lalchemy -lcopperplate /usr/xenomai/lib/xenomai/bootstrap.o -Wl,--wrap=main -Wl,--dynamic-list=/usr/xenomai/lib/dynlist.ld -L/usr/xenomai/lib -lcobalt -lmodechk -lpthread -lrt -march=armv7-a -mfpu=vfp3  
    /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: ./cyclic_test.o: in function `_fini':
    /tmp/dgboter/bbs/rhev-vm8--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/src/glibc/csu/../sysdeps/arm/crti.S:97: multiple definition of `_fini'; /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/crti.o:/tmp/dgboter/bbs/rhev-vm8--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/src/glibc/csu/../sysdeps/arm/crti.S:97: first defined here
    /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: ./cyclic_test.o: in function `__data_start':
    :(.data+0x0): multiple definition of `__data_start'; /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/crt1.o:static-reloc.c:(.data+0x0): first defined here
    /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: ./cyclic_test.o: in function `__data_start':
    makefile:35: recipe for target 'XenomaiTest' failed
    :(.data+0x4): multiple definition of `__dso_handle'; /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/crtbegin.o:(.data+0x0): first defined here
    /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: ./cyclic_test.o:/tmp/dgboter/bbs/rhev-vm8--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/src/glibc/csu/init.c:23: multiple definition of `_IO_stdin_used'; /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/crt1.o:/tmp/dgboter/bbs/rhev-vm8--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/src/glibc/csu/init.c:23: first defined here
    /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: ./cyclic_test.o: in function `_start':
    /tmp/dgboter/bbs/rhev-vm8--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/src/glibc/csu/../sysdeps/arm/start.S:79: multiple definition of `_start'; /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/crt1.o:/tmp/dgboter/bbs/rhev-vm8--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/src/glibc/csu/../sysdeps/arm/start.S:79: first defined here
    /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: /usr/xenomai/lib/xenomai/bootstrap.o: in function `__wrap_main':
    bootstrap.c:(.text+0x0): multiple definition of `xenomai_main'; ./cyclic_test.o::(.text+0x358): first defined here
    /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: /usr/xenomai/lib/xenomai/bootstrap.o:(.rodata+0x0): multiple definition of `xenomai_auto_bootstrap'; ./cyclic_test.o:(.rodata+0x78): first defined here
    /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/crtend.o:(.tm_clone_table+0x0): multiple definition of `__TMC_END__'; ./cyclic_test.o::(.data+0x8): first defined here
    collect2: error: ld returned 1 exit status
    make: *** [XenomaiTest] Error 1

    As you can see, the compiling phase is correctly carried out nad generate the object files. The problem is with the linker phase. Have you got any ideas?

    Thank you.

    Regards,

    Davide Brunelli

  • I resolved the issue with the following:

    Replace "Cross GCC Compiler" with : ${COMMAND} ${FLAGS} ${CFLAGS} -c ${INPUTS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX} ${OUTPUT}

    and replace "Cross GCC Linker" with : ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX} ${OUTPUT} ${INPUTS} ${LDFLAGS},

    where CFLAGS and LDFLAGS are the same as the ones indicated above.

    The final result is:

    15:37:47 **** Clean-only build of configuration Release for project XenomaiTest2 ****
    make clean 
    rm -rf  ./cyclic_test.o  ./cyclic_test.d  XenomaiTest2
     
    
    15:37:47 Build Finished (took 565ms)
    
    15:37:47 **** Incremental Build of configuration Release for project XenomaiTest2 ****
    make all 
    Building file: ../cyclic_test.c
    Invoking: Cross GCC Compiler
    arm-linux-gnueabihf-gcc -O3 -g -Wall -MMD -MP -MF"cyclic_test.d" -MT"cyclic_test.o" -I/usr/xenomai/include/cobalt -I/usr/xenomai/include -march=armv7-a -mfpu=vfp3 -D_GNU_SOURCE -D_REENTRANT -fasynchronous-unwind-tables -D__COBALT__ -I/usr/xenomai/include/alchemy -c "../cyclic_test.c" -o  "cyclic_test.o"
    ../cyclic_test.c: In function ‘loop_task_proc’:
    ../cyclic_test.c:35:17: warning: unused variable ‘now’ [-Wunused-variable]
       RTIME tstart, now;
                     ^~~
    ../cyclic_test.c:33:7: warning: unused variable ‘iret’ [-Wunused-variable]
       int iret = 0;
           ^~~~
    Finished building: ../cyclic_test.c
     
    Building target: XenomaiTest2
    Invoking: Cross GCC Linker
    arm-linux-gnueabihf-gcc  -o  "XenomaiTest2"  ./cyclic_test.o    -Wl,--no-as-needed -Wl,@/usr/xenomai/lib/modechk.wrappers -lalchemy -lcopperplate /usr/xenomai/lib/xenomai/bootstrap.o -Wl,--wrap=main -Wl,--dynamic-list=/usr/xenomai/lib/dynlist.ld -L/usr/xenomai/lib -lcobalt -lmodechk -lpthread -lrt -march=armv7-a -mfpu=vfp3  
    Finished building target: XenomaiTest2
     
    
    15:37:48 Build Finished (took 663ms)

  • Davide, 

    Thanks for sharing your solution. That will surely help others in the future. 

    Regards,

    Rafael