iT邦幫忙

0

[QEMU][x86-64] 在 QEMU 上開啟 x86-64 的 linux kernel ( 使用 buildroot )

  • 分享至 

  • xImage
  •  

系列文章 : 資訊工程自學筆記

Build QEMU

# 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 ..

Build buildroot

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)

Build linux kernel

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)

Run Simulation

 ./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

整理成 Makefile

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

圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言