C++ on NXP P2041RDB-PC DEV BRD

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

C++ on NXP P2041RDB-PC DEV BRD

Jump to solution
1,242 Views
isaaclambert
Contributor II

I am trying to run a simple “Hello World!” program on the NXP P2041RDB-PC DEV BRD. I need to write this program in C++, but I am not sure what compiler to use so that it will run on the board. I am new to this type of environment so I am just trying to develop and run a program on the board for starters. Any help or pointers to any other resources would be greatly appreciated. Thank you!

1 Solution
991 Views
addiyi
NXP Employee
NXP Employee

Check if the file have executable permission.

Adrian

View solution in original post

10 Replies
991 Views
isaaclambert
Contributor II

Adrian,

I made a make file and it looks like this

-------------------------------------------------

####

SDKTARGETSYSROOT = /opt/fsl-networking/QorIQ-SDK-V1.4/sysroots/ppce500mc-fsl_networking-linux

CROSS_COMPILE = /opt/fsl-networking/QorIQ-SDK-V1.4/sysroots/x86_64-fsl_networking_sdk-linux/usr/bin/ppce500mc-fsl_networking-linux/powerpc-fsl_networking-linux-

CC = $(CROSS_COMPILE)gcc -m32 -msoft-float -mcpu=e500mc --sysroot=${SDKTARGETSYSROOT}

LD = $(CROSS_COMPILE)ld

SOURCES = main.o

BIN = test

all:

    $(CC) -o main.o -c main.c

    $(CC) -o $(BIN) $(SOURCES)

clean:

    rm -f $(BIN) ./$(BIN) ${SOURCES}

####

-------------------------------------------------

The make file works fine and produces the test executable file.

The issue still arises that the P2041RDB-PC DEV BOARD "can not execute the binary file"

I have checked the file size after moving it to check the integrity and it doesn't look like it is being changed any during the transfer using the USB device at all.

I am not sure what I should be doing to write a program and have the P2041RDB-PC DEV BOARD execute it.

I am trying to execute it with bash test on the board.

Is there something that I am doing wrong or missing? I have followed every example and test I can find and nothing seems to be working.

Thank you,

Isaac

0 Kudos
992 Views
addiyi
NXP Employee
NXP Employee

Check if the file have executable permission.

Adrian

991 Views
isaaclambert
Contributor II

I was finally able to have the p2041 execute a program Adrian! Thank you so much for your help! It looks like the type of file system being used by the USB to transfer was causing permission issues with the contents it contained when dealing with the p2041, relating to the most recent issue that we talked about above. Thanks again!

0 Kudos
991 Views
addiyi
NXP Employee
NXP Employee

Here is an example of makefile using sdk standalone toolchain. This is not for your toolchain, but you can use it as example. Also, note that SDK toolchain is a sysrooted toolchain. It means that toolchain will start to look for target fragments and libraries starting from the path specified by the sysroot option.

####

SDKTARGETSYSROOT = /opt/fsl-networking/QorIQ-SDK-V1.7-MPC832XMDS/sysroots/ppce300c2-fsl-linux

CROSS_COMPILE = /opt/fsl-networking/QorIQ-SDK-V1.7-MPC832XMDS/sysroots/x86_64-fslsdk-linux/usr/bin/powerpc-fsl-linux/powerpc-fsl-linux-

CC = $(CROSS_COMPILE)gcc -m32 -msoft-float -mcpu=e300c2 --sysroot=${SDKTARGETSYSROOT}

LD = $(CROSS_COMPILE)ld

SOURCES = main.o

BIN = test

all:

  $(CC) -o main.o -c main.c

  $(CC) -o $(BIN) $(SOURCES)

clean:

  rm -f $(BIN) ./$(BIN) ${SOURCES}

###

Adrian

991 Views
addiyi
NXP Employee
NXP Employee

Yes, program should run after is moved to the board. For C++ you should used powerpc-fsl-linux-cpp.

Adrian

991 Views
isaaclambert
Contributor II

Adrain,

I am having an issue with the board not executing the compiled a.out file.

Here is step by step what I did

-----------------------------------------------------------------------------------------------------------------

                                                                                 

cyber@cyber-Latitude-E6510:~$ cd /opt/fsl-networking/QorIQ-SDK-V1.4/sysroots/x86_64-fsl_networking_sdk-linux/usr/libexec/ppce500mc-fsl_networking-linux/gcc/powerpc-fsl_networking-linux/4.7.2

cyber@cyber-Latitude-E6510:/opt/fsl-networking/QorIQ-SDK-V1.4/sysroots/x86_64-fsl_networking_sdk-linux/usr/libexec/ppce500mc-fsl_networking-linux/gcc/powerpc-fsl_networking-linux/4.7.2$ ls

a.out  as   cc1plus   cpp  ld                liblto_plugin.so    liblto_plugin.so.0.0.0  lto-wrapper  objcopy  plugin  strip

ar     cc1  collect2  gcc  liblto_plugin.la  liblto_plugin.so.0  lto1                    nm           objdump  ranlib

cyber@cyber-Latitude-E6510:/opt/fsl-networking/QorIQ-SDK-V1.4/sysroots/x86_64-fsl_networking_sdk-linux/usr/libexec/ppce500mc-fsl_networking-linux/gcc/powerpc-fsl_networking-linux/4.7.2$ cat /home/cyber/Desktop/C_helloWorldProgram.c

//C hello world example

#include <stdio.h>

int main()

{

  printf("Hello world\n");

  return 0;

}

cyber@cyber-Latitude-E6510:/opt/fsl-networking/QorIQ-SDK-V1.4/sysroots/x86_64-fsl_networking_sdk-linux/usr/libexec/ppce500mc-fsl_networking-linux/gcc/powerpc-fsl_networking-linux/4.7.2$ sudo /opt/fsl-networking/QorIQ-SDK-V1.4/sysroots/x86_64-fsl_networking_sdk-linux/usr/libexec/ppce500mc-fsl_networking-linux/gcc/powerpc-fsl_networking-linux/4.7.2/gcc /home/cyber/Desktop/C_helloWorldProgram.c

[sudo] password for cyber:

cyber@cyber-Latitude-E6510:/opt/fsl-networking/QorIQ-SDK-V1.4/sysroots/x86_64-fsl_networking_sdk-linux/usr/libexec/ppce500mc-fsl_networking-linux/gcc/powerpc-fsl_networking-linux/4.7.2$ ls

a.out  as   cc1plus   cpp  ld                liblto_plugin.so    liblto_plugin.so.0.0.0  lto-wrapper  objcopy  plugin  strip

ar     cc1  collect2  gcc  liblto_plugin.la  liblto_plugin.so.0  lto1                    nm           objdump  ranlib

cyber@cyber-Latitude-E6510:/opt/fsl-networking/QorIQ-SDK-V1.4/sysroots/x86_64-fsl_networking_sdk-linux/usr/libexec/ppce500mc-fsl_networking-linux/gcc/powerpc-fsl_networking-linux/4.7.2$ file a.out

a.out: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, BuildID[sha1]=0x86aff26ce396f3dfc3665dd5311a997648fe03d6, not stripped

cyber@cyber-Latitude-E6510:/opt/fsl-networking/QorIQ-SDK-V1.4/sysroots/x86_64-fsl_networking_sdk-linux/usr/libexec/ppce500mc-fsl_networking-linux/gcc/powerpc-fsl_networking-linux/4.7.2$

THE A.OUT IS NOW DONE

powerpc-fsl_networking-linux/4.7.2

cyber@cyber-Latitude-E6510:/opt/fsl-networking/QorIQ-SDK-V1.4/sysroots/x86_64-fsl_networking_sdk-linux/usr/libexec/ppce500mc-fsl_networking-linux/gcc/powerpc-fsl_networking-linux/4.7.2$ ls

a.out  as   cc1plus   cpp  ld                liblto_plugin.so    liblto_plugin.so.0.0.0  lto-wrapper  objcopy  plugin  strip

ar     cc1  collect2  gcc  liblto_plugin.la  liblto_plugin.so.0  lto1                    nm           objdump  ranlib

cyber@cyber-Latitude-E6510:/opt/fsl-networking/QorIQ-SDK-V1.4/sysroots/x86_64-fsl_networking_sdk-linux/usr/libexec/ppce500mc-fsl_networking-linux/gcc/powerpc-fsl_networking-linux/4.7.2$ sudo mv a.out /media/NTFS_USB

cyber@cyber-Latitude-E6510:/opt/fsl-networking/QorIQ-SDK-V1.4/sysroots/x86_64-fsl_networking_sdk-linux/usr/libexec/ppce500mc-fsl_networking-linux/gcc/powerpc-fsl_networking-linux/4.7.2$ cd  /media/NTFS_USB

cyber@cyber-Latitude-E6510:/media/NTFS_USB$ ls

a.out

THE A.OUT IS ON A USB DRIVE

Welcome to minicom 2.5

OPTIONS: I18n

Compiled on May  2 2011, 10:05:24.

Port /dev/ttyUSB0

Press CTRL-A Z for help on special keys                                                          

                                                                                                 

                                                                                                 

Poky 9.0 (Yocto Project 1.4 Reference Distro) 1.4 p2041rdb ttyS0                                 

                                                                                                 

p2041rdb login: AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0

p2041rdb login: root

root@p2041rdb:~# ls

root@p2041rdb:~#

CONNECTED TO THE P2041RDB-PC

root@p2041rdb:~# cd /media

root@p2041rdb:/media# ls

card      hdd       net       realroot  sda3      union

cf        mmc1      ram       sda1      sdb1

root@p2041rdb:/media# cd sdb1

root@p2041rdb:/media/sdb1# ls

a.out

root@p2041rdb:/media/sdb1# bash ./a.out

./a.out: ./a.out: cannot execute binary file

root@p2041rdb:/media/sdb1# ./a.out

-sh: ./a.out: Permission denied

I TRY TO RUN THE PROGRAM FROM THE USB AND IT WILL NOT WORK

root@p2041rdb:/media/sdb1# mv a.out /home

mv: can't remove 'a.out': Read-only file system

root@p2041rdb:/media/sdb1# ls

a.out

I TRY TO MOVE IT AND THEN IT FAILS TO MOVE

root@p2041rdb:/media/sdb1# ls

a.out

root@p2041rdb:/media/sdb1# cd /home

root@p2041rdb:/home# ls

a.out  root

root@p2041rdb:/home# ./a.out

-sh: ./a.out: Permission denied

root@p2041rdb:/home# bash ./a.out                                                                                                                                        

./a.out: ./a.out: cannot execute binary file

BUT SOMEHOW THE MOVE DOES WORK, EVEN THOUGH IT GIVES A READ-ONLY FILE SYSTEM ERROR. IT FAILS TO RUN THOUGH STILL.

----------------------------------------------------------------------------------

I have no idea what I am doing wrong. Do you have any idea why I can not get the p2041rdb to execute any code at all?

Thank you for your time,

Isaac

0 Kudos
991 Views
addiyi
NXP Employee
NXP Employee

You could use CodeWarrior for PowerArchitecture which includes GCC EABI e500mc toolchain. Also, you can take standalone toolchain or the one provided by SDK, and give it a try.

Adrian

991 Views
isaaclambert
Contributor II

Hi Adrian, thanks for the response. Where would the toolchain provided by the SDK be located?

0 Kudos
991 Views
addiyi
NXP Employee
NXP Employee

Go to www.nxp.com/infocenter/ > Software and Tools > QorIQ > SDK > QorIQ SDK 1.9 Documentation > Getting Started with Yocto Project > Additional Instruction for Developers > Installing the Toolchain to find out how to install the the standalone toolchain.

Adrian

991 Views
isaaclambert
Contributor II

Hi Adrian,

I was able to install the

~/QorIQ-SDK-V1.4-20130625-yocto/build_p2041rdb_release

and also

/opt/fsl-networking/QorIQ-SDK-V1.4/sysroots/x86_64-fsl_networking_sdk-linux/usr/libexec/ppce500mc-fsl_networking-linux/gcc/powerpc-fsl_networking-linux/4.7.2

after the first part.

In the 4.7.2 directory there is a gcc program. If I compile a C program(not C++) with gcc, and move that program to an USB drive and move the program from the USB drive onto the drive on the pP2041, should the program run when executed?

Also, is cpp another C compiler and linker or would C++ work with the cpp program?

Thank you for the help,

Isaac

0 Kudos