Cross compilation for P2020RDB-PCA.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cross compilation for P2020RDB-PCA.

581 Views
pradeepsysargus
Contributor II

Our test.c file is:

#include<sys/types.h>

#include<sys/stat.h>

#include<unistd.h>

#include<fcntl.h>

void main()

{

int fd;

fd=  open("file1.txt",O_CREAT | O_WRONLY,0600);

// fd= open("/dev/ttyS0",O_RDONLY);

close(fd);

}

gcc test.c --sysroot=/opt/fsl-networking/QorIQ-SDK-V1.7/sysroots/ppce500v2-fsl-linux-gnuspe/ -o test.c

We compiled the test.c file using the above command, and when trying to execute on the target we are getting the following error:

-sh: ./test: cannot execute binary file: Exec format error

When we run this binary on Linux host, it is working(it creates a new file "file1.txt"), does it mean it just compiled not cross-compile?

Thanks,

0 Kudos
2 Replies

376 Views
Pavel
NXP Employee
NXP Employee

Use the following command sequence:

sudo chmod 777 /opt/fsl-networking/QorIQ-SDK-V1.7/environment-setup-ppce500v2-fsl-linux-gnuspe

source /opt/fsl-networking/QorIQ-SDK-V1.7/environment-setup-ppce500v2-fsl-linux-gnuspe

powerpc-fsl-linux-gnuspe-gcc test.c --sysroot=/opt/fsl-networking/QorIQ-SDK-V1.7/sysroots/ppce500v2-fsl-linux-gnuspe/ -o test.elf

Look at setting in the "environment-setup-ppce500v2-fsl-linux-gnuspe" file.


Have a great day,
Pavel Chubakov

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

376 Views
pradeepsysargus
Contributor II

We got the cross-compilation working now.

The command that is used is : $CC test.c -o test

Here CC is the variable value that is available after sourcing environment setup file.

Thanks,

0 Kudos