Reputation: 95
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).
Upvotes: 4
Views: 6930
Reputation: 564
Yes, you should to program against a particular cpu, as you say.
"-machine " - define a set of devices, accordance to board reference documents, without CPU.
"-cpu " - define a set of ISA features and register reset values that belongs to that particular CPU core, accordance to reference of that CPU core. (here is how qemu do it for aarch64)
Imagine qemu as an environment for software thread of target ISA. All interactions with peripheral devices are performed by load/stores and by interrupts delivery. To emulate peripheral device we need to know a MMIO base address, its interrupt number for GIC, and programming model of such device. "Board" in qemu terms is a set of such devices.
Qemu do not make any restrictions about usage of armv7 machines vs armv8 cpus, and vice versa. Here you could see how qemu place AArch64 bootloader to memory only if specified CPU supports this instruction set, else it will be Aarch32.
Also all "boards" available for qemu-system-arm is also available for qemu-system-aarch64: you could look at build configuration files at qemu sources.
Also all boards implemented at hw/arm/ dir. Their implementation is quite straightforward, all job concentrated at board_init functions: construction devices, assign interrupt lines, place bootloader & dtb at memory.
Upvotes: 3
Reputation: 11523
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:
Upvotes: 4