板子资源比较紧张,用qemu开发比较好,节约时间,也不用把文件拷来拷去,把这个过程在这里做一下记录。
./configure --target-list=riscv64-softmmu --disable-werror
make all
编译完成后我们可以在qemu source下的build下面找到qemu-system-riscv64
,这个是我们的目标文件。
Repository | Type | Content | Compile Command |
---|---|---|---|
opensbi | opensbi | RISC-V Open Source Supervisor Binary Interface | make clean ARCH=“riscv” CROSS_COMPILE=“riscv64-linux-gnu-” make PLATFORM=generic |
uboot | U-Boot | Das U-Boot | make clean make sifive_unmatched_defconfig ARCH=“riscv” CROSS_COMPILE=“riscv64-linux-gnu-” make all |
linux | Linux Kernel | Linux Kernel | make clean && make distclean ARCH=“riscv” CROSS_COMPILE=“riscv64-linux-gnu-” make defconfig ARCH=“riscv” CROSS_COMPILE=“riscv64-linux-gnu-” make all |
在这里,我们选择用一个ubuntu image作为我们的rootfs。
./build/qemu-system-riscv64 \ -machine virt -nographic -m 2048 -smp 4 \ -bios $OPENSBI_SRC_DIR/build/platform/generic/firmware/fw_jump.elf \ -kernel $UBOOT_SRC_DIR/uboot.elf \ -device virtio-net-device,netdev=eth0 -netdev user,id=eth0 \ -drive file=focal-preinstalled-server-riscv64.img,format=raw,if=virtio