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.

Compiler/AM3358: Compiling c code extended with assembler code

Part Number: AM3358

Tool/software: TI C/C++ Compiler

Hi, 

I am currently trying to compile some c code, which is extended with some globally declared assembler functions. (as can be seen in the files added)

To compile and link I took the following steps:

- compile every file separately using clpru with the following command (currently I tried it hardcoded, in the end it will be used in a generic makefile):

clpru SPH0641_Beaglebone_Black.c -fe SPH0641_Beaglebone_Black.o --include_path=/home/rens/Repository/PRUCookbook/docs/common --include_path=/home/rens/Repository/pru-software-support-package/include --include_path=/home/rens/Repository/pru-software-support-package/include/am335x --include_path=/home/rens/Repository/pru-software-support-package/ti-cgt-pru_2.1.5/include -DCHIP=am335x -DCHIP_IS_am335x -DPROC=pru -DPRUN=0 -v3 -O2 --printf_support=minimal --display_error_number --endian=little --hardware_mac=on -ppd -ppa --asm_listing --c_src_interlist

clpru Beaglebone_Black.c -fe Beaglebone_Black.o --include_path=/home/rens/Repository/PRUCookbook/docs/common --include_path=/home/rens/Repository/pru-software-support-package/include --include_path=/home/rens/Repository/pru-software-support-package/include/am335x --include_path=/home/rens/Repository/pru-software-support-package/ti-cgt-pru_2.1.5/include -DCHIP=am335x -DCHIP_IS_am335x -DPROC=pru -DPRUN=0 -v3 -O2 --printf_support=minimal --display_error_number --endian=little --hardware_mac=on -ppd -ppa --asm_listing --c_src_interlist

clpru Beaglebone_Black_asm.asm -fe Beaglebone_Black_asm.o --include_path=/home/rens/Repository/PRUCookbook/docs/common --include_path=/home/rens/Repository/pru-software-support-package/include --include_path=/home/rens/Repository/pru-software-support-package/include/am335x --include_path=/home/rens/Repository/pru-software-support-package/ti-cgt-pru_2.1.5/include -DCHIP=am335x -DCHIP_IS_am335x -DPROC=pru -DPRUN=0 -v3 -O2 --printf_support=minimal --display_error_number --endian=little --hardware_mac=on -ppd -ppa --asm_listing --c_src_interlist

-then I try to link the .o files together using the following command:

lnkpru SPH0641_Beaglebone_Black.o -shared SPH0641_Beaglebone_Black.o Beaglebone_Black.o Beaglebone_Black_asm.o --reread_libs --warn_sections --stack_size=0x100 --heap_size=0x100 -i/home/rens/Repository/pru-software-support-package/ti-cgt-pru_2.1.5/lib -i/home/rens/Repository/pru-software-support-package/ti-cgt-pru_2.1.5/include /home/rens/Repository/PRUCookbook/docs/common/am335x_pru.cmd --library=libc.a --library=/home/rens/Repository/pru-software-support-package/lib/rpmsg_lib.lib

The latter command gives the following error:

fatal error: combining options --absolute (-a) and --relocatable (-r) is not
supported when producing ELF output files

I don't really see why this error occurs, since I define neither absolute or relocatable as option and thus it should go for the default setting which is absolute?

Kind regards,
Rens

  • I guess this might make it easier to understand the question.. :)5305.code.zip

  • Please do not invoke the linker directly.  Invoke it through the compiler shell clpru.  For details, please search the PRU compiler manual for the sub-chapter titled Invoking the Linker Separately.  

    The problem is this option ...

    Rens Baeyens said:
    -shared

    This is the same as specifying -s -h -a -r -e -d.  There is no linker option with a name similar to shared.  So I do not know what to suggest instead.

    Thanks and regards,

    -George

  • Hi,

    I copied these commands from a cloud9 example with the Beaglebone, so that's why I invoked the linker separately. Not because there is a specific goal behind it.

    My goal is actually to compile the added code in a manner as simple as possible.

    I tried clpru with the --run-linker option set, however I haven't yet figured it out. 

    My actual question is: How would the clpru command look to get a functional program compiled?

  • Hello Rens,

    We are working on "getting started labs" that cover, among other things, mixed C and assembly development. The code is mostly up, but we are still working on the documentation.

    You can find the getting started labs in PRU Software Support Package 5.6 and later. (i.e., AM335x Processor SDK Linux 6.3 and later under example-applications/pru-icss-x.x.x or the PRU Software Support Package git repo). Take a look at the Linux makefile under labs/Getting_Started_Labs/c_and_assembly/solution/am335x/ .

    The getting started labs are a work in progress. Let me know if you have any feedback.

    Regards,

    Nick