From Fedora Project Wiki
(initial draft of the page (from existing notes elsewhere))
 
(No difference)

Revision as of 00:49, 15 November 2012

Using the ARM Foundation Model for ARMv8

Let us suppose that using an NFS root file system for ARMv8 work is not really an option for some reason. Let us also suppose that you can't get access to the ARM FAST model -- which is almost bound to be the case for most people. What we describe here is probably the most straightforward way to work with ARMv8 without a lot of sysadmin overhead once the initial setup has been completed.

The recipe has these ingredients:

  • A copy of the ARM Foundation Model (FM)
  • A copy of the items needed for booting -- a file called "linux-system.axf", used by the FM -- but containing the kernel, u-boot and other key bits.
  • A copy of a Fedora 17 root file system (rootfs) as a disk image

Instructions will also be provided for creating the rootfs disk image from scratch, should you need to.

Initial Setup

Create a handy place to keep everything. Some of the files are quite large, so assume you will need at least 20GB of free disk space. I'd recommend more, just to be safe. For simplicity's sake, stash everything in a single directory. For example:

$ mkdir ~/armv8
$ cd ~/armv8

Getting the ARM Foundation Model

The FM is licensed code and it is NOT redistributable. Each user must retrieve their own copy. And, to do that, each user must register with ARM. On the other hand, the process is straightforward. Go to http://www.arm.com/fvp and follow the instructions. In my case, I was then able to download a file called FM000-KT-00035-r0p8-44rel23.tgz and unpack it:

$ cd ~/armv8
$ tar xvzf FM000-KT-00035-r0p8-44rel23.tgz

This created a directory called Foundation_v8pkg with the FM in it. To make things easy to run, I also created a quick alias that we'll use later:

$ alias fv8="~/armv8/Foundation_v8pkg/Foundation_v8"

Getting the Boot Path

For now, one can retrieve a copy of the bits being provided by Linaro (http://www.linaro.org) that provide for a basic kernel and boot path in the format required by the FM (a .axf file). At some point in the future, a Fedora kernel will be made available. So, retrieve the file:

$ cd ~/armv8
$ wget http://releases.linaro.org/12.10/openembedded/aarch64/rc3/img-foundation.axf

That's all that's needed.

Getting the Rootfs Disk Image

If you just want to use what has been pre-built, you can retrieve a copy of the rootfs as a disk image and then decompress it:

$ cd ~/armv8
$ wget http://fedorapeople.org/groups/armv8/f17-stage2-rootfs.img.bz2
$ bunzip2 f17-stage2-rootfs.img.bz2

This is a large file (~10GB) and it will grow larger. It does however contain a copy of all of the stage2 bootstrap binaries and sources to date. Further, at any time, one can cd to /, and then do 'git pull --all' to get the most recent bits and update the rootfs.

Running the Foundation Model

Now that all the parts are in hand, running the FM is pretty straightforward; if you need to play with the network configuration, there is some documentation available in the tarball downloaded from ARM for the FM. In most cases, though, the following will be sufficient:

$ cd ~/armv8
$ fv8 --image img-foundation.axf --block-device f17-stage2-rootfs.img --network=nat

After a few moments, an xterm for the console will pop up and you'll have a running ARMv8 system.

Creating a Rootfs Disk Image

If you need to either re-create or substantively modify the rootfs disk image provided, it takes a little doing, but isn't too big a deal. The first step is to create a file that will contain the disk image:

$ dd if=/dev/zero of=rootfs.img bs=1M count=8192

This creates an image about 8GB in size; bump it up as needed, of course. Next, we need to put two partitions into the image using something like fdisk:

$ fdisk rootfs.img

Create two partitions -- a small, bootable FAT partition (~25-50MB), and the remainder an ext3 partition; I assume here I don't need to provide detailed steps for using fdisk. When you're done, it'll look something like this:

$ fdisk -l fedora17-stage2-armv8.img

Disk fedora17-stage2-armv8.img: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders, total 8388608 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: 0x093138f0
 
                    Device Boot      Start         End      Blocks   Id  System
fedora17-stage2-armv8.img1   *        2048      104447       51200    e  W95 FAT16 (LBA)
fedora17-stage2-armv8.img2          104448     8388607     4142080   83  Linux

We can use kpartx and some other tools to create block devices for the partitions, put file systems on them, and then mount them in /tmp:

$ sudo kpartx -a -v rootfs.img
add map loop0p1 (253:6): 0 106432 linear /dev/loop0 63
add map loop0p2 (253:7): 0 4087808 linear /dev/loop0 106496
$ mkfs.vfat /dev/mapper/loop0p1
...
$ mkfs.ext3 /dev/mapper/loop0p2
...
$ mkdir /tmp/vfat
$ mkdir /tmp/ext3
$ sudo mount /dev/mapper/loop0p1 /tmp/vfat
$ sudo mount /dev/mapper/loop0p2 /tmp/ext3

Only one file is needed in the FAT partition; retrieve it and copy it in, then release the partition from use:

$ cd ~/armv8
$ wget http://fedorapeople.org/groups/armv8/u-boot.bin
$ sudo cp u-boot.bin /tmp/vfat
$ sudo sync
$ sudo umount /tmp/vfat

The ext3 partition is where all the fun stuff is -- it's the actual rootfs with all the interesting ARMv8 executables (not that the kernel is boring, mind you...). To recreate the image that one could have fetched, we can pull it from git and then use cpio to copy it in properly:

$ cd ~/armv8
$ git clone -b stage2 git://fedorapeople.org/~ahs3/rootfs.git
$ cd rootfs
$ sudo sh -c "find . -print | cpio -pdumv /tmp/ext3"
$ sudo sync
$ sudo umount /tmp/ext3

And we're all done.

To use this file system image, it's simply a matter of replacing the value of the --block-image parameter when running the FM:

$ fv8 --image img-foundation.axf --block-device rootfs.img --network=nat