<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Another attempt at blogging</title>
    <link>http://longhouse.vikings.scot/uefi/qemu-aarch64-jessie.html</link>
    <description>ARM, open source and stuff...</description>
    <language>en</language>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <generator>blosxom/2.1.2</generator>

  <item>
    <title>Installing Debian Jessie on QEMU AArch64</title>
    <pubDate>Tue, 27 Jan 2015 13:06:00 +0000</pubDate>
    <link>http://longhouse.vikings.scot/2015/01/27#qemu-aarch64-jessie</link>
    <category>/uefi</category>
    <guid isPermaLink="false">http://longhouse.vikings.scot/uefi/qemu-aarch64-jessie</guid>
    <description>
&lt;p/&gt;I previously wrote about how to &lt;a href=&quot;http://blog.eciton.net/uefi/qemu-arm-uefi.html&quot;&gt;run AArch64 UEFI on QEMU&lt;/a&gt;, but it did not really cover how to do anything useful with it. So here is a follow-up, showing how you can install and run a full &lt;a href=&quot;http://www.debian.org/&quot;&gt;Debian&lt;/a&gt; installation. The steps below &lt;i&gt;require&lt;/i&gt; at least version 2015.01 of linaro-edk2.

&lt;h3&gt;Building QEMU&lt;/h3&gt;
&lt;p/&gt;Full support for AArch64 (the 64-bit ARM architecture) was only added into QEMU version 2.2.0, so will probably not yet be in any distribution-provided QEMU. So for now, let&apos;s build our own:

&lt;p/&gt;&lt;pre&gt;$ git clone git://git.qemu-project.org/qemu.git
$ cd qemu
$ git checkout -b 2.2.0-stable v2.2.0
$ ./configure --prefix=/usr/local --target-list=aarch64-softmmu
$ make -j`getconf _NPROCESSORS_ONLN`
$ sudo make install&lt;/pre&gt;

&lt;h3&gt;Create ROM Images&lt;/h3&gt;
&lt;p/&gt;The aarch64 &lt;i&gt;virt&lt;/i&gt; machine sports two emulated 64MB NOR flash devices, holding the platform firmware and its persistent environment. We use the IntelBds flavour of the UEFI images, which is what the x86 Ovmf QEMU port does.

&lt;p/&gt;&lt;pre&gt;$ mkdir ~/arm64-qemu &amp;&amp; cd ~/arm64-qemu
$ dd if=/dev/zero of=flash0.img bs=1M count=64
$ LINARO_EDK2_URL=http://releases.linaro.org/15.01/components/kernel/uefi-linaro/
$ wget $LINARO_EDK2_URL/release/qemu64-intelbds/QEMU_EFI.fd
$ dd if=QEMU_EFI.fd of=flash0.img conv=notrunc
$ dd if=/dev/zero of=flash1.img bs=1M count=64
&lt;/pre&gt;

&lt;h3&gt;Block devices&lt;/h3&gt;
&lt;p/&gt;We need to prepare image files for the emulated HDD as well as the installation CDROM. The CDROM image, we just download - until Debian Jessie has actually been released, from &lt;a href=&quot;http://cdimage.debian.org/cdimage/weekly-builds/arm64/&quot;&gt;the weekly snapshots&lt;/a&gt;. I would recommend the &lt;a href=&quot;http://cdimage.debian.org/cdimage/weekly-builds/arm64/iso-cd/debian-testing-arm64-netinst.iso&quot;&gt;netinst iso&lt;/a&gt;, which is 150MB in size and grabs all packages from the network. If you need to do an installation somewhere with no networking, go for the 4.4GB &lt;a href=&quot;http://cdimage.debian.org/cdimage/weekly-builds/arm64/iso-dvd/debian-testing-arm64-DVD-1.iso&quot;&gt;single DVD image&lt;/a&gt; instead.

&lt;p/&gt;For the HDD image, we just need to create an empty file of sufficient size to hold our system - I would say 8GB, but if you&apos;re doing something very limited you could get away with less.
&lt;p/&gt;&lt;pre&gt;$ dd if=/dev/zero of=hda.img bs=1M count=8192&lt;/pre&gt;

&lt;h3&gt;Creating a launch script&lt;/h3&gt;
&lt;p/&gt;Since we do not yet have PCI emulation on AArch64 in QEMU (underway) or EDK2 (to be commenced in the next month or so), we cannot simply use -hda and -cdrom so find ourselves in &quot;magic rune&quot; territory. For now, the below script is a simple enough way to launch the emulator.

&lt;pre&gt;#!/bin/sh

CDROM_IMG=debian-testing-arm64-netinst.iso
HDA_IMG=hda.img

make_cdrom_arg()
{
        echo &quot;-drive file=$1,id=cdrom,if=none,media=cdrom&quot; \
             &quot;-device virtio-scsi-device -device scsi-cd,drive=cdrom&quot;
}

make_hda_arg()
{
        echo &quot;-drive if=none,file=$1,id=hd0&quot; \
             &quot;-device virtio-blk-device,drive=hd0&quot;
}

HDA_ARGS=`make_hda_arg $HDA_IMG`
if [ $# -eq 1 ]; then
        case $1 in
            install)
                CDROM_ARGS=`make_cdrom_arg $CDROM_IMG`
            ;;
            *)
                CDROM_ARGS=&quot;&quot;
            ;;
        esac
fi

qemu-system-aarch64 -m 1024 -cpu cortex-a57 -M virt -nographic \
                    -pflash flash0.img -pflash flash1.img \
                    $CDROM_ARGS $HDA_ARGS -netdev user,id=eth0 \
                    -device virtio-net-device,netdev=eth0 &lt;/pre&gt;

&lt;h3&gt;Launching the model&lt;/h3&gt;
&lt;p/&gt;Save the above script as &lt;code&gt;launch.sh&lt;/code&gt;, make it executable with &lt;code&gt;chmod +x launch.sh&lt;/code&gt; and launch the emulator with &lt;code&gt;./launch.sh install&lt;/code&gt;. You should end up with something looking a bit like this in your terminal:
&lt;img src=&quot;/static/img/jessie-arm64-qemu.png&quot;/&gt;
&lt;p/&gt;From here on, you have a standard Debian installer, which I&apos;m not going to help you with, since there are many other resources available (and the installer is generally quite straightforward).</description>
  </item>
  </channel>
</rss>
