ARM Foundation Model - Free solution to make your first steps on ARM-64bit and ARM Software stack by Olivier on 24/12/2015 10:11

Get the ARM Foundation Model

Download ARM Foundation Model:

Try the model: ./models/Linux64_GCC-4.7/Foundation_Platform --image examples/hello.axf

ERROR: cpu0.gicv3_cpu_if: Virtual LPIs can not be supported in GICv2 only mode. Defaulting virtual lpi support to false.
terminal_0: Listening for serial connection on port 5000
terminal_1: Listening for serial connection on port 5001
terminal_2: Listening for serial connection on port 5002
terminal_3: Listening for serial connection on port 5003
Simulation is started
Hello, 64-bit world!

ARM Software Stack

ARM Architecture has two worlds / execution environment: Trusted World and Non-Trusted World. These two execution environments run at the same time.
Non-Trusted world cannot access Trusted World. It protects trusted information (such as payment details) to be accessed by malicious software running in Non-Trusted world - although risks exist if the Trusted World is not configured properly or the interface between both Worlds are not correctly designed.

Most ARM (and non-ARM) platforms have different types of memory:

The Open-Source ARM Software stack contains these following modules:

Run the full stack from pre-built binaries

  1. Download the archive that contains ARM Trusted Firmware, UEFI binaries, Linux Kernel and Device Tree at (5.9 MB)

  2. Download OpenEmbedded Minimal filesystem at (54.9M)

  3. Launch it!

    export MODEL=$PWD/Foundation_Platformpkg/models/Linux64_GCC-4.7/Foundation_Platform
    export DISK=$PWD/prebuilt/lt-vexpress64-openembedded_minimal-armv8-gcc-4.9_20150912-729.img
    ./prebuilt/ ./prebuilt/

Build and run the full stack

The initial step is to download the AArch64 toolchain archive
The location where you will unpack the archive will be defined as <your-toolchain-path> in the rest of the document.

Build the software stack in a couple of command lines

Use Google's repo tool. Let's build the software stack with the Linaro recommended instructions.
From this document, we have the choice between:

If we want to run Android later on without to have to switch the Linux kernel, we should go for LSK.

  1. Install repo:

  2. Get the source

    mkdir repo_src && cd repo_src
    repo init -u -b 15.11 -m pinned-lsk.xml
    repo sync -j8
  3. Build the sources

    export CROSS_COMPILE=<your-toolchain-path>/gcc-linaro-5.1-2015.08-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
    ./build-scripts/ fvp-oe
    ./build-scripts/ fvp-oe package
  4. Run the newly built binaries

    ./prebuilt/ src/output/fvp-oe/uefi

Build the software stack components by components

Create the directory that will contain all the ARM Software stack components:

mkdir src && cd src
export CROSS_COMPILE=<your-toolchain-path>/gcc-linaro-4.9-2014.11-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-

Build UEFI

  1. Clone the UEFI repository

    git clone
    cd edk2
  2. Edit the default Linux command line in ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc to remove the initrd (defined by the argument -f) as we want to boot the Open Embedded disk image and we do not use an initrd for our Linux kernel.

    diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
    index f82de7e..30e3cb5 100644
    --- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
    +++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
    @@ -167,7 +167,7 @@
       gArmPlatformTokenSpaceGuid.PcdDefaultBootDescription|L"Linux from SemiHosting"
    -  gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image -f VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/filesystem.cpio.gz -c \"console=ttyAMA0 earlycon=pl011,0x1c090000 debug user_debug=31 loglevel=9\""
    +  gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|L"VenHw(C5B9C74A-6D72-4719-99AB-C59F199091EB)/Image -c \"console=ttyAMA0 earlycon=pl011,0x1c090000 debug user_debug=31 loglevel=9 root=/dev/vda2\""
       # Use the serial console (ConIn & ConOut) and the Graphic driver (ConOut)
  3. Build UEFI

    make -f ArmPlatformPkg/Scripts/Makefile EDK2_TOOLCHAIN=GCC49 EDK2_ARCH=AARCH64 EDK2_DSC=ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc GCC49_AARCH64_PREFIX=${CROSS_COMPILE} EDK2_MACROS="-DUSE_ARM_BDS=1"

    USE_ARM_BDS should be used because the default BDS (UEFI Boot Manager) expects Linux kernel to be part of the EFI Boot partition which does not exist on the Linaro file system. The ARM BDS can load the Linux kernel and device tree from semihosting.

    Fd File Name:FVP_AARCH64_EFI_SEC
    Generate Region at Offset 0x0
       Region Size = 0x80000
       Region Name = FV
    Generating FVMAIN_SEC FV
    Generate Region at Offset 0x0
       Region Size = 0x80000
       Region Name = FV
    Fd File Name:FVP_AARCH64_EFI
    Generate Region at Offset 0x0
       Region Size = 0x280000
       Region Name = FV
    Generating FVMAIN_COMPACT FV
    Generating FVMAIN FV
    Generate Region at Offset 0x0
       Region Size = 0x280000
       Region Name = FV
    GUID cross reference file can be found at /home/olivier/src/edk2/Build/ArmVExpress-FVP-AArch64/DEBUG_GCC49/FV/Guid.xref
    FV Space Information
    FVMAIN_SEC [8%Full] 524288 total, 45056 used, 479232 free
    FVMAIN_COMPACT [27%Full] 2621440 total, 716984 used, 1904456 free
    FVMAIN [99%Full] 4963200 total, 4963168 used, 32 free
    - Done -
    Build end time: 10:18:55, Dec.10 2015
    Build total time: 00:02:11
    Warning: 'fip_create' tool is not in the PATH. The UEFI binary will not be added in the Firmware Image Package (FIP).

ARM Foundation Model - UEFI

Build ARM Trusted Firmware

  1. Clone the repository

    git clone
    cd arm-trusted-firmware
  2. Build ARM Trusted Firmware in DEBUG mode:

    $ make PLAT=fvp all fip BL33=/home/olivier/src/edk2/Build/ArmVExpress-FVP-AArch64/DEBUG_GCC49/FV/FVP_AARCH64_EFI.fd DEBUG=1
    Firmware Image Package ToC:
    - Trusted Boot Firmware BL2: offset=0xB0, size=0x6008
      file: './build/fvp/debug/bl2.bin'
    - EL3 Runtime Firmware BL3-1: offset=0x60B8, size=0x8010
      file: './build/fvp/debug/bl31.bin'
    - Non-Trusted Firmware BL3-3: offset=0xE0C8, size=0x280000
      file: '/home/olivier/src/edk2/Build/ArmVExpress-FVP-AArch64/DEBUG_GCC49/FV/FVP_AARCH64_EFI.fd'
    Creating "build/fvp/debug/fip.bin"
    Built build/fvp/debug/fip.bin successfully

ARM Foundation Model - ARM Trusted Firmware

Build Linux kernel

  1. Clone the repository and use the branch linux-linaro-lsk-v4.1

    git clone -b linux-linaro-lsk-v4.1
    cd linux-linaro-stable
  2. Build the Linux kernel

    $ make ARCH=arm64 defconfig
    $ make ARCH=arm64 -j8 Image
      LD      vmlinux
      SORTEX  vmlinux
      OBJCOPY arch/arm64/boot/Image

ARM Foundation Model - Linux

Run the newly built software stack

  1. Create symbolic link in the current directory to allow UEFI to find the Linux kernel and Device Tree.

    ln -s linux-linaro-stable/arch/arm64/boot/Image
    ln -s arm-trusted-firmware/fdts/fvp-foundation-gicv3-psci.dtb
  2. Launch the model

    ../Foundation_Platformpkg/models/Linux64_GCC-4.7/Foundation_Platform --cores=4 --secure-memory --visualization --gicv3 --data="$PWD/arm-trusted-firmware/build/fvp/debug/bl1.bin"@0x0 --data="$PWD/arm-trusted-firmware/build/fvp/debug/fip.bin"@0x08000000 --block-device="/home/olivier/prebuilt/lt-vexpress64-openembedded_minimal-armv8-gcc-4.9_20150912-729.img"

Some notes:

Linux NFS Boot on the ARM Foundation Model

NFS Boot allows to directly make changes to the file system from your host machine without the need to mount the disk image every time.

Ensure your Linux kernel support NFS

To enable NFS Boot you need to ensure your ARM Foundation Model Linux kernel has support for the Ethernet SMSC 91C111 controller. Check the configuration file of your Linux kernel source tree:

$ grep SMSC .config
# CONFIG_SMSC9420 is not set
# CONFIG_SMSC_PHY is not set
# CONFIG_FB_SMSCUFX is not set

CONFIG_SMSC911X is set so it means you can use the ARM Foundation Model network controller with your current kernel binaries. If it is not set then you need to enable it in your kernel configuration and rebuild the kernel.

Configure Network support on the ARM Foundation Model

Start the model with the bridge network:

sudo ../Foundation_Platformpkg/models/Linux64_GCC-4.7/Foundation_Platform --cores=4 --secure-memory --visualization --gicv3 --data="$PWD/arm-trusted-firmware/build/fvp/debug/bl1.bin"@0x0 --data="$PWD/arm-trusted-firmware/build/fvp/debug/fip.bin"@0x08000000 --block-device="/home/olivier/prebuilt/lt-vexpress64-openembedded_minimal-armv8-gcc-4.9_20150912-729.img" --network=bridged &
sleep 5
sudo ifconfig ARM0 netmask

On the target:

sudo ifconfig eth0 netmask

Note: NAT network with the option --network=nat instead of --network=bridged also works.

More information on the network configuration here.

Setting up the NFS server on your host machine

We will need to copy the file system of your disk image onto your local disk. Let's have a look at the partitions present on your disk image and their locations - fdisk will help us:

$ /sbin/fdisk -lu ../prebuilt/lt-vexpress64-openembedded_minimal-armv8-gcc-4.9_20150912-729.img
Disk ../prebuilt/lt-vexpress64-openembedded_minimal-armv8-gcc-4.9_20150912-729.img: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders, total 6291456 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

                      Device Boot      Start         End      Blocks   Id  System
../prebuilt/lt-vexpress64-openembedded_minimal-armv8-gcc-4.9_20150912-729.img1   *          63      155646       77792    e  W95 FAT16 (LBA)
../prebuilt/lt-vexpress64-openembedded_minimal-armv8-gcc-4.9_20150912-729.img2          155648     6291455     3067904   83  Linux

You can see the Linux partition starts at the sector number 155648. fidsk says the sector size is 512 bytes.

We use losetup to mount the disk image on /dev/loop0:

$ losetup /dev/loop0 ../prebuilt/lt-vexpress64-openembedded_minimal-armv8-gcc-4.9_20150912-729.img -o $((155648 * 512))

file -s /dev/loop0 confirms us the Linux partition is actually a ext4 partition:

/dev/loop0: Linux rev 1.0 ext4 filesystem data, UUID=a9c947eb-c956-4c39-af5d-1fe3509121a9, volume name "rootfs" (needs journal recovery) (extents) (large files) (huge files)

We finally can mount the device /dev/loop0 to access the partition as part of our file system:

mkdir /tmp/disk
mount /dev/loop0 /tmp/disk

Now the disk image is mounted, we can copy its content to the directory /srv/nfs/lt-vexpress64-openembedded_minimal-armv8:

sudo mkdir /srv/nfs
sudo mount -o loop,offset=$((155648 * 512)) ../prebuilt/lt-vexpress64-openembedded_minimal-armv8-gcc-4.9_20150912-729.img /tmp/disk
sudo cp -ax /tmp/disk /srv/nfs/lt-vexpress64-openembedded_minimal-armv8
umount /dev/loop0
losetup -d /dev/loop0

Setting up NFS server

Check your Linux distribution documentation. For instance a simple installation on the Ubuntu distribution can be found here.
After installing NFS server, make sure the NFS service is started. You can also test your NFS installation is correctly set up by mounting the NFS file system on your host machine:

$ mkdir /tmp/open-embedded
$ sudo mount localhost:/srv/nfs/lt-vexpress64-openembedded_minimal-armv8 /tmp/open-embedded
$ ls /tmp/open-embedded/
bin  boot  dev  EFI  etc  home  lib  lost+found  media  mnt  proc  run  sbin  sys  tmp  usr  var

Next stage is to check whether you can mount the filesystem from the ARM Foundation model.
If you have any issue you can get the NFS error by looking at /var/log/syslog on the host machine: tail -n 20 /var/log/syslog

Once you manage to access the NFS file system from the model, you can now change the Linux kernel command line in UEFI in the file ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc at the line gArmPlatformTokenSpaceGuid.PcdDefaultBootArgument|(..).

Replace root=/dev/vda2 by one of the following arguments:

ARM Foundation Model - NFS

Now, you know how to change and rebuild every components of the ARM Software stack!

Olivier on 24/12/2015 15:06
This blog is also available as a Github document: to be updated in the future.
Anonymous on 16/02/2016 03:27
Thanks for sharing this useful post. I am following your instructions to boot up UEFI and linux kernel. I am successful to boot up UEFI. However, i am unable to boot up linux kernel with the error message " Did not find Linux kernel". I did provide the path as below command:
./Foundation_Platform --cores=4 --no-secure-memory --visualization --gicv3 --data=bl1.bin@0x0 --data=fip.bin@0x8000000 --data=fvp-foundation-gicv2-psci.dtb@0x8300000 --data=Image@0x80080000
I am not sure where else did I miss.
I hope you can advise me on this problem.
Thanks a lot.

Anonymous on 16/02/2016 03:30
Sorry to mention, i am building all the software stack component by component. And if i used the prebuilt binary bl1 and fip then it works.

Login to comment Comment as anonymous