系列文章 : 資訊工程自學筆記
這一篇是希望,可以在 QEMU 上運行 arm64 的 linux kernel。
# Clone the QEMU repository
git clone git@github.com:qemu/qemu.git
cd qemu
git checkout v10.0.0
python -m venv ./my-venv
source ./my-venv/bin/activate
pip install --upgrade setuptools
pip install --upgrade distlib
# Configure and build QEMU for riscv64
./configure --target-list=aarch64-softmmu
make -j$(nproc)
deactivate
cd ..
git clone git@github.com:buildroot/buildroot.git
cd buildroot
git checkout 56c6862bc81ef41c0fe012677eafa24381b1f76c
# use default configuration for RISC-V 64-bit virt QEMU/gem5
make qemu_aarch64_virt_defconfig
sed -i 's/^BR2_TARGET_ROOTFS_EXT2_2=y/# BR2_TARGET_ROOTFS_EXT2_2 is not set/' .config
sed -i 's/.*BR2_TARGET_ROOTFS_EXT2_4.*/BR2_TARGET_ROOTFS_EXT2_4=y/' .config
make olddefconfig
make -j$(nproc)
git clone --depth 1 -b v6.8 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
cd linux
# generate default RISC-V configuration
make ARCH=arm64 CROSS_COMPILE=$(realpath ../buildroot/output/host/bin)/aarch64-linux- defconfig
# Compile both the vmlinux ELF (needed for debugging) and the Image (used as payload)
make ARCH=arm64 CROSS_COMPILE=$(realpath ../buildroot/output/host/bin)/aarch64-linux- vmlinux Image -j$(nproc)
./qemu/build/qemu-system-aarch64 \
-M virt \
-cpu cortex-a53 \
-nographic \
-smp 2 \
-m 1024 \
-kernel ./linux/arch/arm64/boot/Image \
-append "root=/dev/vda rw console=ttyAMA0" \
-drive if=none,file=./buildroot/output/images/rootfs.ext4,format=raw,id=hd0 \
-device virtio-blk-device,drive=hd0
git clone git@github.com:TommyWu-fdgkhdkgh/qemu-boot-arm-linux.git
cd qemu-boot-arm-linux
make buildroot/build
make linux/build
make qemu/build
make qemu/run