Skip to content

QEMU ARM Quick Reference

A quick reference for QEMU ARM system emulation, designed to be used alongside the scripts/qemu-run.sh script.


Common Commands

List Supported Platforms

bash
# ARM64
qemu-system-aarch64 -M help

# ARM32
qemu-system-arm -M help

List Supported CPU Types

bash
qemu-system-aarch64 -cpu help
qemu-system-arm -cpu help

List Supported Devices

bash
qemu-system-aarch64 -device help

Launch QEMU Directly (Without the Script)

bash
# ARM64 virt
qemu-system-aarch64 \
  -M virt \
  -cpu cortex-a72 \
  -m 1G \
  -smp 2 \
  -kernel Image \
  -nographic \
  -serial mon:stdio

# ARM32 vexpress
qemu-system-arm \
  -M vexpress-a9 \
  -cpu cortex-a9 \
  -m 512M \
  -kernel zImage \
  -dtb vexpress-v2p-ca9.dtb \
  -nographic \
  -serial mon:stdio

QEMU virt Machine Hardware Specs

ARM64 virt

DeviceTypeKernel DriverDevice Node / Notes
UARTPL011amba-pl011ttyAMA0
RTCPL031arm-pl031
NICVirtIO-netvirtio_net
StorageVirtIO-blkvirtio_blk
GPIOVirtIO-gpiovirtio_gpio
PCIPCIe hostpcie-port
InterruptGIC v3/v4irq-gic-*
TimerARMv8 Arch Timerarch_timer

ARM32 vexpress

DeviceTypeKernel DriverDevice Node
UARTPL011amba-pl011ttyAMA0
EthernetLAN9118smsc911xeth0
DisplayPL111 CLCDpl111fb0
RTCPL031pl031
InterruptGICirq-gic

Kernel Configuration

ARM64 defconfig

bash
# Base config (includes VirtIO support)
make ARCH=aarch64 defconfig

# Ensure CONFIG_VIRTIO=y
CONFIG_VIRTIO=y
CONFIG_VIRTIO_PCI=y
CONFIG_VIRTIO_BLK=y
CONFIG_VIRTIO_NET=y
CONFIG_SERIAL_AMBA_PL011=y
CONFIG_SERIAL_AMBA_PL011_CONSOLE=y

ARM32 vexpress_defconfig

bash
make ARCH=arm vexpress_defconfig

Serial Console

QEMU Serial Shortcuts

KeyFunction
Ctrl+A, XQuit QEMU
Ctrl+A, CSwitch to QEMU monitor
Ctrl+A, ZShow help

QEMU Monitor Commands

(qemu) info version      # QEMU version
(qemu) info status       # Run state
(qemu) info cpus         # CPU info
(qemu) info mem          # Memory info
(qemu) info qtree        # Device tree
(qemu) quit              # Quit

Network Configuration

User-mode Networking (Default)

Simplest option, no extra configuration needed. Guest can access host, but not the other way around.

bash
# Enable user-mode networking
QEMU_NET=on ./scripts/qemu-run.sh run

# Default port forwarding: 2222 → 22
# Inside guest: ssh -p 2222 user@10.0.2.2

TAP Networking (Advanced)

Requires TAP device and bridge setup for full bidirectional networking.

bash
# Create TAP device (requires root)
sudo ip tuntap add dev tap0 mode tap
sudo ip link set tap0 up

# Add to bridge
sudo ip link add br0 type bridge
sudo ip link set br0 up
sudo ip link set tap0 master br0

# Use TAP networking
QEMU_NET=on QEMU_NET_TAP=on QEMU_TAP_IF=tap0 ./scripts/qemu-run.sh run

GDB Debugging

Launch QEMU Waiting for GDB Connection

bash
qemu-system-aarch64 -M virt -cpu cortex-a72 -kernel Image -s -S
# -s: shorthand for -gdb tcp::1234
# -S: freeze CPU at startup

Connect GDB

bash
aarch64-linux-gnu-gdb vmlinux
(gdb) target remote :1234
(gdb) break start_kernel
(gdb) continue

Common GDB Commands

(gdb) info registers        # Show registers
(gdb) bt                    # Backtrace
(gdb) thread apply all bt   # Backtrace for all threads
(gdb) x/10i $pc             # Disassemble current instructions
(gdb) disassemble           # Disassemble current function

Kernel Boot Parameters

Common Parameters

ParameterPurpose
console=ttyAMA0,115200Serial console
earlyprintk=serial,ttyAMA0Early serial output
root=/dev/vdaRoot device
rootfstype=ext4Root filesystem type
roMount root read-only
rwMount root read-write
debugEnable kernel debug output
quietReduce boot messages
ignore_loglevelIgnore log level limits

How to Set

bash
# Via environment variable
QEMU_KERNEL_CMDLINE="console=ttyAMA0 debug" ./scripts/qemu-run.sh run

# Or modify the default in the script

Troubleshooting

QEMU Fails to Start

  1. Check QEMU installation

    bash
    qemu-system-aarch64 --version
    qemu-system-arm --version
  2. Check kernel image exists

    bash
    ls -lh out/build_latest/arch/arm64/boot/Image
  3. Increase debug output

    bash
    qemu-system-aarch64 -d int,cpu_reset  # Show execution log

Kernel Hangs at Boot

  1. Check last log message — determine where it's stuck
  2. Check CONFIG_SERIAL_AMBA_PL011_CONSOLE — is it enabled?
  3. Try a simpler cmdline — remove potentially problematic parameters

Device Not Working

  1. Check device tree

    bash
    # In QEMU monitor
    (qemu) info qtree
  2. Check kernel config

    bash
    # Ensure relevant drivers are compiled
    grep VIRTIO .config

QEMU virt vs. Rockchip Hardware

FeatureQEMU virtRockchip RK3399Migration Notes
CPUcortex-a722×A72 + 4×A53Use SMP config to simulate multi-core
SerialttyAMA0ttyS0~4Modify cmdline
NICvirtio-netr8169/fecDifferent driver interface
Storagevirtio-blkdw-mmc/SDNeeds real hardware testing
GPIOvirtio-gpiopinctrl-gpioSimilar code structure
I2Cvirtio-i2crk-i2cSame driver framework
Power(none)rk-pmNeeds real hardware

Learning recommendation:

  • Use QEMU to learn kernel frameworks and subsystems
  • Use real hardware to test hardware-specific drivers and BSP code

References

基于 VitePress 构建