This page explains how to build and cross-build a simple "Hello World!" program for AArch64.

Pre-requisites

This assumes you have followed e.g. http://www.linaro.org/engineering/armv8/ and that you're now running an ARMv8 model such as the Foundation model.

To cross-build, you'll need a GNU/Linux cross-toolchain which you may download from http://www.linaro.org/engineering/armv8/ or http://releases.linaro.org/latest/components/toolchain/binaries/.

Unpack the toolchain (Linaro GCC 4.8-2013.07 at the time of the writing) to a location of your choice and add the bin/ subdirectory to your PATH; for instance:

   1 mkdir ~/aarch64-toolchain
   2 cd ~/aarch64-toolchain
   3 wget http://releases.linaro.org/13.07/components/toolchain/binaries/gcc-linaro-aarch64-linux-gnu-4.8-2013.07-1_linux.tar.xz
   4 tar Jxf gcc-linaro-aarch64-linux-gnu-4.7+svn191987-20120925+bzr2498_linux.tar.xz
   5 export PATH=$PATH:$PWD/gcc-linaro-aarch64-linux-gnu-4.7+svn191987-20120925+bzr2498_linux/bin
   6 

You should be able to run aarch64-linux-gnu-gcc -v or aarch64-none-elf-gcc -v depending on whether you're running a GNU/Linux or a bare-metal toolchain:

   1 aarch64-linux-gnu-gcc -v
   2 [...]
   3 

To build natively (non-cross), you will need gcc in your OpenEmbedded rootfs; this is typically in the "LAMP" rootfs ("SDK" has been merged into LAMP).

Native

To build hello world natively run the following under Fast Models:

   1 % cat >hello.c <<EOF
   2 #include <stdio.h>
   3 
   4 int main(void) {
   5     printf("Hello ARMv8 world!\n");
   6 }
   7 EOF
   8 
   9 gcc -o hello hello.c
  10 ./hello
  11 Hello ARMv8 world!
  12 
  13 ldd hello
  14 linux-vdso.so.1 (0x0000007fb2e68000)
  15 libc.so.6 => /lib/libc.so.6 (0x0000007fb2d00000)
  16 /lib/ld-linux-aarch64.so.1 (0x0000007fb2e40000)
  17 

Cross

To cross-build a hello world run this on your host computer:

   1 cat >hello.c <<EOF
   2 #include <stdio.h>
   3 
   4 int main(void) {
   5     printf("Hello ARMv8 world!\n");
   6 }
   7 EOF
   8 
   9 aarch64-linux-gnu-gcc -o hello hello.c
  10 file hello
  11 hello: ELF 64-bit LSB executable, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.39, BuildID[sha1]=0x75a79b3d3ad4d335be48eab8dd5129fc3db76143, not stripped
  12 

Then download/upload the file to your Fast Models (or insert it in the rootfs) and run it.

HowTo/HelloAarch64 (last modified 2013-07-31 05:12:10)