Previous: Set up the Fast Model.
This page deals with setting up the KVM host system: a kernel and filesystem which will run under the Fast Model.
Install a cross compiler
In trusty the packages you need should all be in the (universe) archive. Install these:
gcc-arm-linux-gnueabihf binutils-arm-linux-gnueabihf libc6-armhf-cross linux-libc-dev-armhf-cross libc6-dev-armhf-cross cpp-arm-linux-gnueabihf
Set up a guest filesystem
You'll need at least the qemu-user-static package installed for this.
$ cd /srv $ sudo mkdir arm-trusty-root $ sudo qemu-debootstrap --arch=armhf --include=libfdt1 trusty ./arm-trusty-root/
When it's done, you'll need to tweak some files in the chroot:
- add 'ttyAMA0' to etc/securetty
- copy etc/init/tty1.conf to etc/init/ttyAMA0.conf and edit it to change 'tty1' to 'ttyAMA0' everywhere
sudo chroot /srv/arm-trusty-root and run passwd to set root's password
- create an etc/apt/sources.list:
deb http://ports.ubuntu.com/ trusty main restricted universe deb-src http://ports.ubuntu.com/ trusty main restricted universe
Note that since this is a qemu-debootstrap-created directory tree you can run "sudo chroot /srv/arm-trusty-root" to chroot into it using qemu's linux-user emulation. This is particularly useful for installing random extra packages. (If you try to do anything too exciting in the chroot you may run into issues with QEMU. Sorry...)
Export the guest filesystem via NFS
You need to make sure that the guest filesystem is exported via NFS to the IP address of the host x86 system (not 127.0.0.1 but its public IP address). Install nfs-kernel-server if you don't have it already, and add a line like this to /etc/exports:
(using the correct IP address, of course). Then run /etc/init.d/nfs-kernel-server reload.
If your machine changes IP address you'll need to fix /etc/exports and reload.
Get and build the kernel
Grab any recent upstream kernel (v3.10 or later), for example like this
git clone https://github.com/torvalds/linux.git cd linux git checkout v3.17 # or some other version
and compile it using the following config options:
export ARCH=arm export CROSS_COMPILE=arm-linux-gnueabihf- make vexpress_defconfig ./scripts/config -e CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE ./scripts/config -e CONFIG_LBDAF ./scripts/config -e CONFIG_ARCH_VIRT ./scripts/config -e CONFIG_ARM_LPAE ./scripts/config -d CONFIG_MCPM ./scripts/config -e CONFIG_SYS_SUPPORTS_HUGETLBFS ./scripts/config -e CONFIG_MMU_NOTIFIER ./scripts/config -e CONFIG_TRANSPARENT_HUGEPAGE ./scripts/config -e CONFIG_BRIDGE ./scripts/config -e CONFIG_BLK_DEV_LOOP ./scripts/config -e CONFIG_BLK_DEV_LOOP_MIN_COUNT ./scripts/config -e CONFIG_TUN ./scripts/config -e CONFIG_VIRTUALIZATION ./scripts/config -e CONFIG_HAVE_KVM_IRQCHIP ./scripts/config -e CONFIG_KVM ./scripts/config -e CONFIG_KVM_ARM_HOST ./scripts/config -e CONFIG_KVM_ARM_MAX_VCPUS ./scripts/config -e CONFIG_KVM_ARM_VGIC ./scripts/config -e CONFIG_KVM_ARM_TIMER ./scripts/config -e CONFIG_VIRTIO_BLK ./scripts/config -e CONFIG_SCSI_VIRTIO ./scripts/config -e CONFIG_VIRTIO_NET ./scripts/config -e CONFIG_VIRTIO_CONSOLE ./scripts/config -e CONFIG_VIRTIO ./scripts/config -e CONFIG_VIRTIO_BALLOON ./scripts/config -e CONFIG_VIRTIO_MMIO yes '' | make oldconfig make -j <n>
This will build the zImage into arch/arm/boot/zImage. The kernel can be used as both the KVM host kernel and as the VM guest kernel.
Get the boot wrapper
$ cd .. $ git clone git://git.linaro.org/arm/models/boot-wrapper.git $ cd boot-wrapper
Previous versions of the boot-wrapper required you to bake a particular kernel uImage and command line arguments into it, so you would need to rebuild it every time you changed the kernel. That is no longer required, so these instructions document how to build a single linux-system-semi.axf which you can then use for any kernel (zImage or uImage) and command line. You can build this with:
$ make CROSS_COMPILE=arm-linux-gnueabihf- linux-system-semi.axf
Get a Device Tree
Recent ARM kernels require a device tree, which describes the devices in the system. You will need the device tree compiler, if you haven't already got it installed, either use the one included with the kernel sources (scripts/dtc/dtc) or install it using:
$ sudo apt-get install device-tree-compiler
Then you will need a device tree: these are kept in source form, and compiled into a "device tree blob" for the kernel to use:
$ cd .. $ git clone git://linux-arm.org/arm-dts.git $ dtc -O dtb arm-dts/fast_models/rtsm_ve-cortex_a15x2.dts > boot-wrapper/fastmodel-a15x2.dtb
Note, you may be able to use the device tree that's included in the upstream kernel instead, which should be build as part as building the upstream kernel and found in arch/arm/boot/dts/vexpress-v2p-ca15_a7.dtb.
Run the model
$ ~/ARM/FastModelsPortfolio_7.0/examples/RTSM_VE/Build_Cortex-A15x2/Linux64-Release-GCC-4.1/isim_system linux-system-semi.axf -C motherboard.smsc_91c111.enabled=1 -C motherboard.hostbridge.userNetworking=1 -C cluster.cpu0.semihosting-cmd_line="--kernel /path/to/zImage --dtb fastmodel-a15x2.dtb -- console=ttyAMA0 mem=2048M earlyprintk root=/dev/nfs nfsroot=172.31.252.70:/srv/arm-trusty-root,tcp rw ip=dhcp nfsrootdebug"
Substitute in the correct path to the kernel zImage (you can also use a uImage) and the NFS server's IP address. (We aren't using an initrd in this howto, but if you are then you can add '--initrd /path/to/initrd' after the '--kernel /path/to/zImage' argument.)
Note that this uses the "user networking" feature of Fast Models 7.0. Paths may differ slightly if you built a 32 bit model. If this fails to mount its root fs then you may have misconfigured your host /etc/exports.
You should confirm that you can boot the kernel under the model and get to a login prompt. Note that there will be a long (few minutes) pause between the kernel saying it is going to run init and the login prompt appearing. This is because the guest filesystem we have set up is not configured to print init's progress messages to the serial terminal.
Next: Build QEMU.
Core/Virtualization/HowTo/Kvm32HostSetup (last modified 2014-12-07 21:13:19)