系列文章 : 資訊工程自學筆記
# 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=x86_64-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_x86_64_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 defconfig
# Compile both the vmlinux ELF (needed for debugging) and the Image (used as payload)
make CC="gcc -std=gnu11" HOSTCC="gcc -std=gnu11" -j$(nproc)
./qemu/build/qemu-system-x86_64 \
-M pc \
-kernel linux/arch/x86/boot/bzImage \
-drive file=buildroot/output/images/rootfs.ext2,if=virtio,format=raw \
-append "root=/dev/vda console=ttyS0" \
-net nic,model=virtio \
-net user \
-nographic
git clone git@github.com:TommyWu-fdgkhdkgh/qemu-boot-x86-64-linux.git
cd qemu-boot-x86-64-linux
make buildroot/build
make linux/build
make qemu/build
make qemu/run