Yesterday: Daily Update 8/30: Daily Update for 7 Days Will
Recently, I have been reviewing knowledge about the ARM architecture and testing with qemu. Today, I will share some thoughts on how to explore ARM without a development board. For specific methods, please refer to links 1-4.
In the absence of a development board, you can use a simulator/emulator to replace actual hardware. There is commercial software like ARM’s FVP (which has a free trial version) (see link 5), and open-source software like qemu and gem5 (see link 6). The qemu ecosystem outperforms the other two options. So today, I will focus on qemu.
Which mode of QEMU to choose?
Qemu is an emulator that can be used to test software, but its behavior may not fully match that of the hardware (for example, it does not support cache). It supports multiple architectures, including arm (32-bit) and arm64. It has two modes: one is system mode, and the other is user mode.
System mode is used to simulate an entire system (as shown in the image below), allowing you to run software like Linux, kvm, and TEE. Qemu’s support for virtualization is provided by Linaro, see reference link 9. User mode simulates user-space programs, effectively converting ARM system calls into host system calls, allowing it to run software in the Normal world that is independent of the hardware outside the CPU.
The image is from the ARM® Cortex® -A Series Version: 1.0 Programmer’s Guide for ARMv8-A
How to use QEMU
The intuitive way to use it is to look at the help, for example, qemu-system-aarch64 –help, and for more details, refer to the qemu user manual (see link 7), which can be accessed from link 8 for the latest user manual.
However, it is not recommended to use it this way when encountering issues. The parameters for qemu are quite complex, and manual configuration can be inconvenient. It is recommended to generate the qemu configuration file using libvirt, or to use qemu directly through libvirt. The relationship between libvirt and qemu is shown in the image below.
Using libvirt to call qemu-system-arm and qemu-system-aarch64 is much more convenient. For specific hypervisors, blocks, etc. supported by libvirt, you can refer to the libvirt documentation or the src directory of the code (see link 10). Libvirt has a command line tool called virsh that is very convenient to use. If you want to start qemu with a graphical interface, you can use virt-manager.
The performance of qemu
Qemu user mode can directly utilize the host’s multi-core capabilities. However, due to the aforementioned conversions, there is some performance loss. Before 2016, qemu system mode could only run on one CPU of the host. With the efforts of Linaro’s Alex Bennée, qemu system arm/aarch64 running on x86_64 can now use multiple CPUs of the host, significantly improving performance, see reference link 9.
Reference Links
• Quickly Build Linux Kernel Experimental Environment Based on Docker/Qemu
tinylab.org/docker-qemu-linux-lab/
• Code Guide: How to Use QEMU for Step-by-Step Debugging of head.S
mp.weixin.qq.com/s/KKintRZEScHktOdY5mJdtA
• Uncle Ben’s QEMU Experiments
mp.weixin.qq.com/s/rn9ILrP0DYehlI3g0GiFjQ
• Using QEMU chroot for Local Firmware Debugging
mp.weixin.qq.com/s/DDZv2TH9O1lIhFzO14CPxQ
• Software Development Without a Hardware Target:
https://developer.arm.com/products/system-design/fixed-virtual-platforms
• gem5: http://gem5.org/Main_Page
• QEMU version 3.1.0 User Documentation
https://qemu.weilnetz.de/doc/qemu-doc.html
• QEMU documentation:
https://www.qemu.org/documentation/
• What’s new in QEMU 2.9 – Linaro:
https://www.linaro.org/blog/whats-new-qemu-2-9/
• libvirt src directory:
https://github.com/libvirt/libvirt/tree/master/src
You may be interested in articles
Half-Watt’s WeChat public account enjoys sharing personal experiences, including technical accumulation and life insights:
• Movie Reviews and Reading Notes
• Reading Notes on “Energy Management”
• Finding Yourself, Loving Yourself)
• Everyone Has a “Venom” in Their Heart
• “Mr. Hiccup”, Acceptance and Growth
• Child Rearing
• “Understanding Children’s Drawings” – Growing Together with Children
• Because of Belief, We See | Child’s First Grade Experience
• My Experience at a Montessori Kindergarten Parent Meeting
• Technology. Including sharing on blockchain and data storage, Linux kernel, and other infrastructure. For example
• What Has SUSE Brought Me?
• Filecoin Official FAQ Compilation and Interpretation
• 2018 Turing Award Lecture: Another Golden Age of Computer Architecture: Co-design of Hardware and Software for Specific Domains, Enhanced Security, Agile Development of Open Instruction Sets and Chips
• Among the sharing on blockchain and data storage, priority will be given to Half-Watt’s Knowledge Planet “Blockchain and Data Storage” for sharing in this field. Welcome to join fellow enthusiasts in this area.