27/07/2011

Running a C HelloWorld on ARM BeagleBoard

In this simple tutorial I will show you howto prepare your linux distribution for compiling and running C code on a BeagleBoard (ARM architecture). In short, you will need to install the cross-compiler, connect the board with your computer, load the compiled binaries to the board and finally execute them. Here we go in more details:

0. Prerequisites
  • Linux OS distribution (Ubuntu or Fedora should do)
  • BeagleBoard-xm with ARM A7 processor (or higher)


1. Install the ARM compiler

You will need to install a compiler for ARMv7 / Linux. See for example ARM/GNU Linux.

Let's assume you have installed the compiler into the following location: /opt/CodeSourcery/Sourcery_G++_Lite.

Then add the location into your PATH:
$ export  PATH=$PATH:/opt/CodeSourcery/Sourcery_g++_Lite/bin

And test your compile by executing:
$ arm-none-linux-gnueabi-gcc  -o hello.arm hello.c

This should work, later on we will use the generated hello.arm to run it on the beagle-board.

2. Connecting the BeagleBoard

Here is a nice manual on setting up the BeagleBoard on a linux-server machine:
http://elinux.org/BeagleBoardBeginners

After going through the manul, your board should be sitting on your network at some IP address, it may be for example 192.168.0.2

To connect to the board:
$ shh root@192.168.90.2

Tip: If you reboot your linux desktop, you probably want to do the following to re-enable the connection with the board:
$ sudo ifconfig usb0 192.168.0.3

3. Running HelloWorld on BeagleBoard

First, we need to copy the executable to the BeagleBoard:
$ scp hello.arm root@192.168.0.3

And then just login to the board and run the executable:
$ shh root@192.168.90.2
$ ./hello.arm 
Hello World!

And that should be all.

[Note: This tutorial is based on my notes when working with the beagle-board, so it may omit some details. Hope it will help anyway.]

3 comments:

  1. This question is something different, but why SCJ is used and why not continue with RTSJ?

    Regards,

    ReplyDelete
  2.   Awesome tips. I’ll be passing this post on for sure

    ReplyDelete
  3. I have some question want to ask you, can I help me by email?Thank you!!!!!!!!!

    ReplyDelete