Merge pull request #21 from sifive/qemu

Add QEMU support
This commit is contained in:
Palmer Dabbelt 2018-01-05 20:17:03 -08:00 committed by GitHub
commit b84ef550a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 198 additions and 64 deletions

3
.gitmodules vendored
View File

@ -16,3 +16,6 @@
[submodule "riscv-fesvr"]
path = riscv-fesvr
url = https://github.com/riscv/riscv-fesvr.git
[submodule "riscv-qemu"]
path = riscv-qemu
url = git://github.com/riscv/riscv-qemu.git

View File

@ -13,11 +13,14 @@ toolchain_wrkdir := $(wrkdir)/riscv-gnu-toolchain
toolchain_dest := $(CURDIR)/toolchain
buildroot_srcdir := $(srcdir)/buildroot
buildroot_wrkdir := $(wrkdir)/buildroot
buildroot_tar := $(buildroot_wrkdir)/images/rootfs.tar
sysroot_stamp := $(wrkdir)/.sysroot
sysroot := $(wrkdir)/sysroot
buildroot_initramfs_wrkdir := $(wrkdir)/buildroot_initramfs
buildroot_initramfs_tar := $(buildroot_initramfs_wrkdir)/images/rootfs.tar
buildroot_initramfs_config := $(confdir)/buildroot_initramfs_config
buildroot_initramfs_sysroot_stamp := $(wrkdir)/.buildroot_initramfs_sysroot
buildroot_initramfs_sysroot := $(wrkdir)/buildroot_initramfs_sysroot
buildroot_rootfs_wrkdir := $(wrkdir)/buildroot_rootfs
buildroot_rootfs_ext := $(buildroot_rootfs_wrkdir)/images/rootfs.ext4
buildroot_rootfs_config := $(confdir)/buildroot_rootfs_config
linux_srcdir := $(srcdir)/linux
linux_wrkdir := $(wrkdir)/linux
@ -40,6 +43,12 @@ spike_srcdir := $(srcdir)/riscv-isa-sim
spike_wrkdir := $(wrkdir)/riscv-isa-sim
spike := $(spike_wrkdir)/prefix/bin/spike
qemu_srcdir := $(srcdir)/riscv-qemu
qemu_wrkdir := $(wrkdir)/riscv-qemu
qemu := $(qemu_wrkdir)/prefix/bin/qemu-system-riscv64
rootfs := $(wrkdir)/rootfs.bin
target := riscv64-unknown-linux-gnu
.PHONY: all
@ -52,6 +61,7 @@ all: $(hex)
$(toolchain_dest)/bin/$(target)-gcc: $(toolchain_srcdir)
mkdir -p $(toolchain_wrkdir)
$(MAKE) -C $(linux_srcdir) O=$(dir $<) ARCH=riscv INSTALL_HDR_PATH=$(abspath $(toolchain_srcdir)/linux-headers) headers_install
cd $(toolchain_wrkdir); $(toolchain_srcdir)/configure \
--prefix=$(toolchain_dest) \
--with-arch=$(ISA) \
@ -60,17 +70,39 @@ $(toolchain_dest)/bin/$(target)-gcc: $(toolchain_srcdir)
$(MAKE) -C $(toolchain_wrkdir)
sed 's/^#define LINUX_VERSION_CODE.*/#define LINUX_VERSION_CODE 263682/' -i $(toolchain_dest)/sysroot/usr/include/linux/version.h
$(buildroot_tar): $(buildroot_srcdir) $(RISCV)/bin/$(target)-gcc
$(MAKE) -C $< RISCV=$(RISCV) PATH=$(PATH) O=$(buildroot_wrkdir) riscv64_defconfig
$(MAKE) -C $< RISCV=$(RISCV) PATH=$(PATH) O=$(buildroot_wrkdir)
$(buildroot_initramfs_wrkdir)/.config: $(buildroot_srcdir)
rm -rf $(dir $@)
mkdir -p $(dir $@)
cp $(buildroot_initramfs_config) $@
$(MAKE) -C $< RISCV=$(RISCV) PATH=$(PATH) O=$(buildroot_initramfs_wrkdir) olddefconfig
.PHONY: buildroot-menuconfig
buildroot-menuconfig: $(buildroot_srcdir)
$(MAKE) -C $< O=$(buildroot_wrkdir) menuconfig
$(buildroot_initramfs_tar): $(buildroot_srcdir) $(buildroot_initramfs_wrkdir)/.config $(RISCV)/bin/$(target)-gcc $(buildroot_initramfs_config)
$(MAKE) -C $< RISCV=$(RISCV) PATH=$(PATH) O=$(buildroot_initramfs_wrkdir)
$(sysroot_stamp): $(buildroot_tar)
mkdir -p $(sysroot)
tar -xpf $< -C $(sysroot) --exclude ./dev --exclude ./usr/share/locale
.PHONY: buildroot_initramfs-menuconfig
buildroot_initramfs-menuconfig: $(buildroot_initramfs_wrkdir)/.config $(buildroot_srcdir)
$(MAKE) -C $(dir $<) O=$(buildroot_initramfs_wrkdir) menuconfig
$(MAKE) -C $(dir $<) O=$(buildroot_initramfs_wrkdir) savedefconfig
cp $(dir $<)/defconfig conf/buildroot_initramfs_config
$(buildroot_rootfs_wrkdir)/.config: $(buildroot_srcdir)
rm -rf $(dir $@)
mkdir -p $(dir $@)
cp $(buildroot_rootfs_config) $@
$(MAKE) -C $< RISCV=$(RISCV) PATH=$(PATH) O=$(buildroot_rootfs_wrkdir) olddefconfig
$(buildroot_rootfs_ext): $(buildroot_srcdir) $(buildroot_rootfs_wrkdir)/.config $(RISCV)/bin/$(target)-gcc $(buildroot_rootfs_config)
$(MAKE) -C $< RISCV=$(RISCV) PATH=$(PATH) O=$(buildroot_rootfs_wrkdir)
.PHONY: buildroot_rootfs-menuconfig
buildroot_rootfs-menuconfig: $(buildroot_rootfs_wrkdir)/.config $(buildroot_srcdir)
$(MAKE) -C $(dir $<) O=$(buildroot_rootfs_wrkdir) menuconfig
$(MAKE) -C $(dir $<) O=$(buildroot_rootfs_wrkdir) savedefconfig
cp $(dir $<)/defconfig conf/buildroot_rootfs_config
$(buildroot_initramfs_sysroot_stamp): $(buildroot_initramfs_tar)
mkdir -p $(buildroot_initramfs_sysroot)
tar -xpf $< -C $(buildroot_initramfs_sysroot) --exclude ./dev --exclude ./usr/share/locale
touch $@
$(linux_wrkdir)/.config: $(linux_defconfig) $(linux_srcdir)
@ -89,9 +121,9 @@ ifeq ($(ISA),$(filter rv32%,$(ISA)))
$(MAKE) -C $(linux_srcdir) O=$(linux_wrkdir) ARCH=riscv olddefconfig
endif
$(vmlinux): $(linux_srcdir) $(linux_wrkdir)/.config $(sysroot_stamp)
$(vmlinux): $(linux_srcdir) $(linux_wrkdir)/.config $(buildroot_initramfs_sysroot_stamp)
$(MAKE) -C $< O=$(linux_wrkdir) \
CONFIG_INITRAMFS_SOURCE="$(confdir)/initramfs.txt $(sysroot)" \
CONFIG_INITRAMFS_SOURCE="$(confdir)/initramfs.txt $(buildroot_initramfs_sysroot)" \
CONFIG_INITRAMFS_ROOT_UID=$(shell id -u) \
CONFIG_INITRAMFS_ROOT_GID=$(shell id -g) \
ARCH=riscv \
@ -102,7 +134,9 @@ $(vmlinux_stripped): $(vmlinux)
.PHONY: linux-menuconfig
linux-menuconfig: $(linux_wrkdir)/.config
$(MAKE) -C $(linux_srcdir) O=$(dir $<) ARCH=riscv menuconfig savedefconfig
$(MAKE) -C $(linux_srcdir) O=$(dir $<) ARCH=riscv menuconfig
$(MAKE) -C $(linux_srcdir) O=$(dir $<) ARCH=riscv savedefconfig
cp $(dir $<)/defconfig conf/linux_defconfig
$(bbl): $(pk_srcdir) $(vmlinux_stripped)
rm -rf $(pk_wrkdir)
@ -110,7 +144,7 @@ $(bbl): $(pk_srcdir) $(vmlinux_stripped)
cd $(pk_wrkdir) && $</configure \
--host=$(target) \
--with-payload=$(vmlinux_stripped) \
--enable-logo \
--enable-logo --enable-print-device-tree \
--with-logo=$(abspath conf/sifive_logo.txt)
CFLAGS="-mabi=$(ABI) -march=$(ISA)" $(MAKE) -C $(pk_wrkdir)
@ -141,8 +175,22 @@ $(spike): $(spike_srcdir) $(libfesvr)
$(MAKE) -C $(spike_wrkdir) install
touch -c $@
.PHONY: sysroot vmlinux bbl
sysroot: $(sysroot)
$(qemu): $(qemu_srcdir)
rm -rf $(qemu_wrkdir)
mkdir -p $(qemu_wrkdir)
mkdir -p $(dir $@)
cd $(qemu_wrkdir) && $</configure \
--prefix=$(dir $(abspath $(dir $@))) \
--target-list=riscv64-softmmu
$(MAKE) -C $(qemu_wrkdir)
$(MAKE) -C $(qemu_wrkdir) install
touch -c $@
$(rootfs): $(buildroot_rootfs_ext)
cp $< $@
.PHONY: buildroot_initramfs_sysroot vmlinux bbl
buildroot_initramfs_sysroot: $(buildroot_initramfs_sysroot)
vmlinux: $(vmlinux)
bbl: $(bbl)
@ -153,3 +201,9 @@ clean:
.PHONY: sim
sim: $(spike) $(bbl)
$(spike) --isa=$(ISA) -p4 $(bbl)
.PHONY: qemu
qemu: $(qemu) $(bbl) $(rootfs)
$(qemu) -nographic -machine virt -kernel $(bbl) \
-drive file=$(rootfs),format=raw,id=hd0 -device virtio-blk-device,drive=hd0 \
-netdev user,id=net0 -device virtio-net-device,netdev=net0

@ -1 +1 @@
Subproject commit 672f627ce0fe9720b4a193fb9bd583518a990882
Subproject commit dfc15319532373fb8cea6b67edfd7f16c366d188

View File

@ -0,0 +1,14 @@
BR2_riscv64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_PATH="$(RISCV)"
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="$(ARCH)-unknown-linux-gnu"
BR2_TOOLCHAIN_EXTERNAL_GCC_7=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_6=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
# BR2_TOOLCHAIN_EXTERNAL_INET_RPC is not set
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV=y
BR2_TARGET_GENERIC_ROOT_PASSWD="sifive"
BR2_SYSTEM_DHCP="eth0"
BR2_PACKAGE_PCIUTILS=y
BR2_PACKAGE_HOST_MKE2IMG=y

View File

@ -0,0 +1,78 @@
BR2_riscv64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_PATH="$(RISCV)"
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="$(ARCH)-unknown-linux-gnu"
BR2_TOOLCHAIN_EXTERNAL_GCC_7=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_6=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
# BR2_TOOLCHAIN_EXTERNAL_INET_RPC is not set
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV=y
BR2_TARGET_GENERIC_ROOT_PASSWD="sifive"
B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E_UTIL_LINUX_MOUNTPOINT=y
BR2_PACKAGE_UTIL_LINUX_NEWGRP=y
BR2_PACKAGE_UTIL_LINUX_NOLOGIN=y
BR2_PACKAGE_UTIL_LINUX_NSENTER=y
BR2_PACKAGE_UTIL_LINUX_PARTX=y
BR2_PACKAGE_UTIL_LINUX_PIVOT_ROOT=y
BR2_PACKAGE_UTIL_LINUX_RAW=y
BR2_PACKAGE_UTIL_LINUX_RENAME=y
BR2_PACKAGE_UTIL_LINUX_RESET=y
BR2_PACKAGE_UTIL_LINUX_SCHEDUTILS=y
BR2_PACKAGE_UTIL_LINUX_SETPRIV=y
BR2_PACKAGE_UTIL_LINUX_SETTERM=y
BR2_PACKAGE_UTIL_LINUX_SWITCH_ROOT=y
BR2_PACKAGE_UTIL_LINUX_TUNELP=y
BR2_PACKAGE_UTIL_LINUX_UL=y
BR2_PACKAGE_UTIL_LINUX_UNSHARE=y
BR2_PACKAGE_UTIL_LINUX_UTMPDUMP=y
BR2_PACKAGE_UTIL_LINUX_UUIDD=y
BR2_PACKAGE_UTIL_LINUX_VIPW=y
BR2_PACKAGE_UTIL_LINUX_WALL=y
BR2_PACKAGE_UTIL_LINUX_WDCTL=y
BR2_PACKAGE_UTIL_LINUX_WRITE=y
BR2_PACKAGE_UTIL_LINUX_ZRAMCTL=y
BR2_TARGET_ROOTFS_EXT2=y
BR2_TARGET_ROOTFS_EXT2_4=y
BR2_TARGET_ROOTFS_EXT2_EXTRA_BLOCKS=10240
# BR2_TARGET_ROOTFS_TAR is not set

View File

@ -1,6 +1,9 @@
CONFIG_SMP=y
# CONFIG_COMPACTION is not set
CONFIG_HZ_100=y
CONFIG_PCI=y
CONFIG_PCI_DEBUG=y
CONFIG_PCIE_XILINX=y
CONFIG_CROSS_COMPILE="riscv64-unknown-linux-gnu-"
CONFIG_DEFAULT_HOSTNAME="ucbvax"
# CONFIG_CROSS_MEMORY_ATTACH is not set
@ -14,72 +17,53 @@ CONFIG_BLK_DEV_INITRD=y
CONFIG_EMBEDDED=y
# CONFIG_BLK_DEV_BSG is not set
CONFIG_PARTITION_ADVANCED=y
# CONFIG_EFI_PARTITION is not set
# CONFIG_IOSCHED_DEADLINE is not set
CONFIG_NET=y
CONFIG_PACKET=y
CONFIG_UNIX=y
CONFIG_INET=y
# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
# CONFIG_INET_XFRM_MODE_TUNNEL is not set
# CONFIG_INET_XFRM_MODE_BEET is not set
# CONFIG_INET_LRO is not set
# CONFIG_INET_DIAG is not set
# CONFIG_IPV6 is not set
# CONFIG_WIRELESS is not set
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
# CONFIG_FIRMWARE_IN_KERNEL is not set
# CONFIG_BLK_DEV is not set
# CONFIG_INPUT_MOUSEDEV is not set
CONFIG_VIRTIO_BLK=y
CONFIG_BLK_DEV_SD=y
CONFIG_ATA=y
CONFIG_SATA_AHCI=y
CONFIG_SATA_SIL24=y
CONFIG_NETDEVICES=y
CONFIG_VIRTIO_NET=y
CONFIG_E1000E=y
CONFIG_R8169=y
# CONFIG_INPUT_KEYBOARD is not set
# CONFIG_INPUT_MOUSE is not set
# CONFIG_VT is not set
CONFIG_SERIAL_8250=y
CONFIG_SERIAL_8250_CONSOLE=y
# CONFIG_SERIAL_8250_PCI is not set
CONFIG_SERIAL_OF_PLATFORM=y
CONFIG_VIRTIO_CONSOLE=y
# CONFIG_HW_RANDOM is not set
# CONFIG_HWMON is not set
# CONFIG_USB_SUPPORT is not set
CONFIG_USB=y
CONFIG_USB_XHCI_HCD=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
CONFIG_VIRTIO_MMIO=y
# CONFIG_IOMMU_SUPPORT is not set
CONFIG_EXT3_FS=y
# CONFIG_FILE_LOCKING is not set
# CONFIG_DNOTIFY is not set
# CONFIG_INOTIFY_USER is not set
# CONFIG_PROC_PAGE_MONITOR is not set
CONFIG_TMPFS=y
# CONFIG_MISC_FILESYSTEMS is not set
# CONFIG_NETWORK_FILESYSTEMS is not set
CONFIG_EARLY_PRINTK=y
CONFIG_CMDLINE_BOOL=y
CONFIG_CMDLINE="earlyprintk"
CONFIG_PRINTK_TIME=y
CONFIG_STRIP_ASM_SYMS=y
CONFIG_DEBUG_SECTION_MISMATCH=y
CONFIG_CMDLINE_BOOL=y
CONFIG_CMDLINE="earlyprintk"
CONFIG_FRAME_POINTER=y
CONFIG_STACKTRACE=y
# CONFIG_CRYPTO_ANSI_CPRNG is not set
# CONFIG_CRYPTO_HW is not set
CONFIG_PCI=y
CONFIG_PCI_DEBUG=y
CONFIG_USB_HID=y
CONFIG_USB_SUPPORT=y
CONFIG_USB_COMMON=y
CONFIG_USB=y
CONFIG_USB_XHCI_HCD=y
CONFIG_USB_XHCI_PCI=y
CONFIG_USB_EHCI_HCD=y
CONFIG_PACKET=y
CONFIG_NETDEVICES=y
CONFIG_NET_CORE=y
CONFIG_ETHERNET=y
CONFIG_NET_VENDOR_INTEL=y
CONFIG_E1000E=y
CONFIG_PCIE_XILINX=y
CONFIG_R8169=y
CONFIG_SCSI=y
CONFIG_SCSI_DMA=y
CONFIG_SCSI_PROC_FS=y
CONFIG_USB_STORAGE=y
CONFIG_BLK_DEV=y
CONFIG_BLK_DEV_SD=y
CONFIG_EFI_PARTITION=y
CONFIG_ATA=y
CONFIG_SATA_AHCI=y
CONFIG_SATA_SIL24=y

2
linux

@ -1 +1 @@
Subproject commit c2d852cb2f3d1875389ed23ad41fbab541b9533b
Subproject commit 87cb3b7930572ac03ffefeb4b5c473b899c9f875

@ -1 +1 @@
Subproject commit 57740d97cdec928c372d8e752c04a691418cbfa1
Subproject commit 0ff33906ff8fe4252613e5735ba6e886fd27d9c1

1
riscv-qemu Submodule

@ -0,0 +1 @@
Subproject commit cd2c21d70361f6887e265860c4f0dbb49ad323ca