Yet another Hello World: This time for ARM

Holidays are getting more and more frustrating.  I am about to OR already LOST and confused a lot!!!
Mann, I need a break…

Though recently I had a one and a half week break, still!!! So What,  I need another one, Afterall I am a fun loving guy..

Ummmm…, This post is for those people who want to see the simplest of the application for the ARM architecture.  Basically it is incredibly simple!
For ex- when we compile a program, a normal C program or (my fav.) assembly program, what we do?

We basically do nothing(out of the total work to be done)! We write a simple C code, the simplest part!, and compile it for our PC architecture using any of the preferred compiler (most of the time its GCC, I guess)

A Few of the Coders and App. developers rarely bother about this stuff(I dare not to say for the whole community…lolz).. How actually a C language code results in giving out the output? The most interesting part and the most difficult too is usually left over.

Lets take a simple example of hello world :

We actually open up (my fav.) VIM then type the following lines


int main()


printf(“hello world\n”);

return 0;


 then :wq it and compile it with gcc.  (:wq refers to write and quit)

$gcc -g -Wall hello.c -o hello

and voila! I get a hello binary (elf executable).. Now I can run the file and see the output as “hello world”

So, I don`t know what all happened during the process of compilation.. I just worte the gcc command and work was done!

Now, I would like to think a bit..So, I came up with a few questions…

  • how a program is actually compiled?

  • what kind of  executable is  produced?

  • Will the Executable binary run everywhere(platforms) and if not then why?

  I will be answering the first two questions in another post,<———–>,  and the third question is the question of my interest for the current post.
We usually have Embedded devices like tablets and SBCs running Linux/Android/Windows CE. So how will I run my program on them.

All of the magic is done  by the compiler or I should better say the toolchain which comprises linker,loader,compiler etc.
So, as we all know, (I assume you know this atleast..lolz) at the lowest level, the program is broken down to instructions for the processor and bla bla bla.  So, the process of breaking down the complex programs to such level and make a binary that is “RUN-ABLE BY OS AND EXECUTABLE BY PROCESSOR” (in very layman terms) is done by the Toolchain!!(guess, now you get it).

That means any program which is compiled is compiled for a specific processor/architecture.  OhK, the programs we compile at our PC(x86) are only for our PC not for any other hardware device(which may run some different architecture processor) and even the program we compiled is also dependent on the Operating System. The program I compile for linux is not going to run on Windows and vice-versa.(Yes, I am talking for the normal case, not with the fake environment case or with Emulators like Wine etc.)

So, we need to compile the code for a particular architecture and for a particular OS.  Here we will try to compile a hello world C program for ARM architecuture.  You must be able to compile the C code for x86 arch. normally as I mentioned it above already(iff needed).

As I mentioned the majority of the work is done by the toolchain, we simply write the code, Following the steps, we need to have the toolchain for the ARM architecture for the linux platform. (I really don`t know what It is for the windows case 😦 …

Getting the toolchain is easy task, download from the

or from the linaro, or Code Sourcery.. anywhere you feel like, just go for the arm-linux toolchain.

(I recommend the first time users to download the binaries directly , as I am pretty sure that You will NOT be able to compile the toolchain for the first time..You will be wasting days or weeks…actually it depends on your linux skills. I actually (sort of) wasted my three whole days when I compiled it for the first time)

So download the archieve, extract the folder and goto the bin section over there

As the picture explains it all, still I would like to write it down, to the directory of toolchain, there you will find arm-none-linux-gnueabi-gcc

2.compile using this cross compiler as:

$./arm-none-linux-gnueabi-gcc <myfile> -o <desired name>

and you are done!

Now to verify, I issued the file command,

$file hello

it says that it is an ARM executable file.

Congratulations, You just made your first application for ARM architecture!!
Porting it to real time embedded device and checking it on our PC itself, (if you dont have an ARM device) will be covered in my next post!


About Beyond

an electronics hobbyst, 8 bit microcontroller(8051/AVR/Arduino) programmer, Linux lover, in love with Embedded Linux systems ... TGL: just push it "BEYOND THE LIMITS"..

Posted on July 8, 2012, in Embedded Linux, Linux and tagged , , , , , , , , , , , , . Bookmark the permalink. 5 Comments.

  1. Woh I love your posts , bookmarked ! My wife and i take issue along with your last point. 253551

  2. What a lovely weblog page. I will surely be back once again. Please maintain writing!

  3. Hello! I would wish to supply a large thumbs up for your outstanding info you could have here about this post. I�ll be coming back to your blog website for further soon.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s