Difference between revisions of "HelloWorld"

From ArmadeusWiki
Jump to: navigation, search
m (Add chmod)
(Change header)
Line 1: Line 1:
 
On this page you will learn how to create your first C application for your Armadeus board
 
On this page you will learn how to create your first C application for your Armadeus board
  
===Source code===
+
==Source code==
 
First take your favorite editor/IDE and create the following program:
 
First take your favorite editor/IDE and create the following program:
  
Line 15: Line 15:
 
Save it as hello.c
 
Save it as hello.c
  
===Compilation===
+
==Compilation==
 
The C cross compiler is installed in ''armadeus/buildroot/build_arm_nofpu/staging_dir/bin/'' and is named ''arm-linux-gcc''
 
The C cross compiler is installed in ''armadeus/buildroot/build_arm_nofpu/staging_dir/bin/'' and is named ''arm-linux-gcc''
 
There are 2 possibilities to use it:
 
There are 2 possibilities to use it:
Line 24: Line 24:
 
  [host demos]$ ../../buildroot/build_arm_nofpu/staging_dir/bin/arm-linux-gcc -o hello hello.c
 
  [host demos]$ ../../buildroot/build_arm_nofpu/staging_dir/bin/arm-linux-gcc -o hello hello.c
  
===Running===
+
==Running==
 
Copy your ''hello'' executable on your board either through TFTP or NFS
 
Copy your ''hello'' executable on your board either through TFTP or NFS
====TFTP====
+
===TFTP===
 
Be sure to have TFTP server installed, [[Connection_with_U-Boot_on_Linux#TFTP_server| if not it's explained here]]<br>
 
Be sure to have TFTP server installed, [[Connection_with_U-Boot_on_Linux#TFTP_server| if not it's explained here]]<br>
 
Copy ''hello'' to TFTP directory:
 
Copy ''hello'' to TFTP directory:
Line 41: Line 41:
 
Now it's up to you ! ;-)
 
Now it's up to you ! ;-)
  
====NFS====
+
===NFS===
 
Be sure to have NFS server installed, [[Network_Configuration| if not it's explained here]]<br>
 
Be sure to have NFS server installed, [[Network_Configuration| if not it's explained here]]<br>
 
I assume that your NFS drive is accessible from ''/mnt/host''
 
I assume that your NFS drive is accessible from ''/mnt/host''
 
Launch your prog:
 
Launch your prog:
 
  [target]# /mnt/host/hello
 
  [target]# /mnt/host/hello
 +
 +
==Links==
 +
* [http://www.handhelds.org/minihowto/porting-software.html Things to know when porting x86 software to ARM]

Revision as of 20:25, 2 April 2007

On this page you will learn how to create your first C application for your Armadeus board

Source code

First take your favorite editor/IDE and create the following program:

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
    printf( "APF9328 says: Hello World ! ;-)\n" );
    exit(0);
}

Save it as hello.c

Compilation

The C cross compiler is installed in armadeus/buildroot/build_arm_nofpu/staging_dir/bin/ and is named arm-linux-gcc There are 2 possibilities to use it:

  • either add armadeus/buildroot/build_arm_nofpu/staging_dir/bin/ to your PATH environment variable and then call arm-linux-gcc instead of gcc
  • or call directly armadeus/buildroot/build_arm_nofpu/staging_dir/bin/arm-linux-gcc

So to compile your small program do (here hello.c was saved in armadeus/target/demos/ directory):

[host demos]$ ../../buildroot/build_arm_nofpu/staging_dir/bin/arm-linux-gcc -o hello hello.c

Running

Copy your hello executable on your board either through TFTP or NFS

TFTP

Be sure to have TFTP server installed, if not it's explained here
Copy hello to TFTP directory:

[host demos]$ cp hello /tftpboot/

Load your executable on the target (here my host IP is 192.168.0.2):

# tftp -g -r hello -l /usr/bin/hello 192.168.0.2

Give it executable rights, if lost during TFTP transfer:

# chmod a+x /usr/bin/hello

Launch it:

# /usr/bin/hello
APF9328 says: Hello World ! ;-)
#

Now it's up to you ! ;-)

NFS

Be sure to have NFS server installed, if not it's explained here
I assume that your NFS drive is accessible from /mnt/host Launch your prog:

[target]# /mnt/host/hello

Links