qemuarm64device-emulation

Qemu Aarch64 supported Boards


A few years back I got into learning Arm architecture. I found Qemu and I used its realview a8 emulated board to program against based on Armv7. The board had a LCD controller, an interrupt controller, etc. I could find all their specs and ended up doing a very very basic scheduler, programming everything in Arm assembly and it was cool. Then I stopped and got busy with my job.

Now I am trying to get back to it, this time with Armv8 and AArch64. But I can't find what boards are supported for the AArch64. Querying Qemu shows the same board list for qemu-system-arm and qemu-system-aarch64. Even Armv7 based a8,a9 and A15 boards show up in qemu-system-aarch64 list. Does this mean there's no board emulation and I should program against a particular cpu like A53 (As I have seen in some examples online).


Solution

  • The "how do I choose a board" question is quite a common one and we document the usual answer on the project's wiki: http://wiki.qemu.org/Documentation/Platforms/ARM

    The short answer for AArch64 is that you want to use the "virt" board, unless you specifically know that you want to emulate one of the 64-bit Xilinx boards (which it sounds like you don't). You'll also need to specify the CPU type with -cpu cortex-a53, since the "virt" board's default is cortex-a15 (a 32-bit CPU).

    The qemu-system-aarch64 binary supports all the 32-bit CPUs and boards, in the same way that qemu-system-x86_64 lets you run a 32-bit x86 CPU guest, which is why the list is so long and full of 32-bit boards. You cannot just try to use a 32-bit board with a -cpu cortex-a53, though -- this is like trying to plug a Core2Duo into an old i386 motherboard and will not function correctly even if QEMU doesn't print an error message about the combination.

    For the virt board, since this is not modelling a real piece of hardware, its details are only specified in the QEMU source code and in the device tree blob we pass to the guest. For a bare metal guest OS, you need to know:

    1. there is boot flash at address 0x0 (which you can fill using the -bios or -pflash QEMU command line option)
    2. the UART is a pl011 at 0x0900000
    3. RAM starts at 0x40000000
    4. All other information about which devices are present and where they are in memory should be obtained from the device tree blob, which can be found at the bottom of RAM, assuming you are a bare metal blob loading via -bios or -pflash. (If you said you were a Linux kernel loading via -kernel then we pass the DTB in the way the kernel booting ABI specifies. Bare metal images usually shouldn't use -kernel, though.)