diff --git a/.gitmodules b/.gitmodules index 419e437ac5cb82d32798f0661eec52b7dfa695d9..bb950b8af97239322f27c4c98d9752931a63a7f7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -49,7 +49,7 @@ [submodule "boards/riscv64/virt/bsp"] ignore = all path = boards/riscv64/virt/bsp - url = https://gitee.com/tinylab/qemu-riscv64-virt.git + url = https://gitee.com/gegewang/unikernel-bsp.git [submodule "boards/x86_64/pc/bsp"] ignore = all path = boards/x86_64/pc/bsp diff --git a/boards/riscv64/virt/Makefile b/boards/riscv64/virt/Makefile index 745339ade65e69b6629e3bb534846e805710fd09..2e4dc2225d8fd9e14bcc8f2b52447798274328be 100644 --- a/boards/riscv64/virt/Makefile +++ b/boards/riscv64/virt/Makefile @@ -1,60 +1,28 @@ -# Copyright (C) 2016-2021 Wu Zhangjin +# Copyright (C) 2020 Wu Zhangjin +# _BASE: 1, virt; 2, real; 3: virt+real _BASE := 1 ARCH := riscv XARCH := riscv64 -# Use the default setting +# Use default setting CPU ?= SMP ?= 4 -MEM ?= 256M -QEMU ?= v6.0.0 +MEM ?= 8G +QEMU ?= v4.1.1 # Enable QEMU_US=1 for qemu-user-static QEMU_US ?= 0 -LINUX ?= v6.2 - -# git repos for the other kernel forks -KERNEL_GIT[KERNEL_FORK_openeuler] := https://gitee.com/openeuler/kernel.git -LINUX[KERNEL_FORK_openeuler] ?= 5.10.0-132.0.0 +LINUX ?= v6.5.2 BUILDROOT?= 2019.05 NETDEV_LIST := virtio NETDEV ?= virtio SERIAL ?= ttyS0 -# use bochs as VGA graphic device -FBDEV ?= stdvga -# use virtio as keyboard device -KBDEV ?= virtio - -UBOOT ?= v2022.04 - -KRN_ADDR?= 0x84000000 -RDK_ADDR?= 0x87500000 - -# QEMU load env.img to ram and then U-boot import it from ram -ENV_DEV_LIST := ram -ENV_DEV ?= ram -ENV_OFFSET ?= 0 -ENV_ADDR ?= 0x87300000 - -UCONFIG ?= qemu-riscv.h -BOOTDEV_LIST := tftp ram -BOOTDEV ?= ram - -# ref: https://wiki.qemu.org/Documentation/9psetup -# 9pnet based network filesystem sharing, aarch64/virt board support both virtio-9p-pci/-virtfs and virtio-9p-device -# But virtio-9p-device requires less kernel options (no need the PCI related parts in features/linux/9pnet/) -# To eanble this function, please make sure the 9pnet feature is enabled: make feature f=9pnet && make kernel-olddefconfig -# -# TODO: add board specific 9pnet options. -# - -NET9PDEV ?= virtio-9p-device - # virtio vda: https://wiki.debian.org/Arm64Qemu ROOTDEV_LIST := /dev/vda /dev/ram0 /dev/nfs ROOTDEV ?= /dev/vda -FSTYPE ?= ext2 +FSTYPE ?= ext4 +ROOTFS ?=$(BSP_ROOT)/$(BUILDROOT)/rootfs.img # fw_jump.elf and fw_dynamic.elf are built from https://gitlab.com/qemu-project/opensbi BIOS ?= $(or $(wildcard $(BSP_BIOS)/opensbi/generic/fw_dynamic.elf),$(BSP_BIOS)/opensbi/generic/fw_jump.elf) @@ -73,26 +41,12 @@ BIMAGE ?= $(BSP_UBOOT)/$(UBOOT)/u-boot UKIMAGE ?= $(KIMAGE) #DTB ?= $(BSP_KERNEL)/$(LINUX)/qemu-$(XARCH)-$(MACH).dtb -ifneq ($(wildcard $(DTB)),) - DTB_ADDR := 0x87000000 -else - DTB_ADDR := $$fdtcontroladdr -endif - ifeq ($(NOMMU),1) override SMP := 1 override BIOS := none override U := 0 endif -ROOTFS ?= $(BSP_ROOT)/$(BUILDROOT)/rootfs.cpio.gz -HROOTFS ?= $(BSP_ROOT)/$(BUILDROOT)/rootfs.$(FSTYPE) - #XKCLI ?= earlycon=sbi QTOOL[OS_trusty] ?= $(BSP_QEMU)/$(QEMU)/bin/qemu-system-$(XARCH) QTOOL[OS_focal] ?= $(BSP_QEMU)/$(QEMU)/bin/qemu-system-$(XARCH) - -# external toolchain, please download it while: make toolchain -# Available CCORI: bootlin, gnu-mcu-eclipse -CCORI[OS_trusty] ?= gnu-mcu-eclipse -CCORI[OS_focal] ?= internal diff --git a/boards/riscv64/virt/Makefile_old b/boards/riscv64/virt/Makefile_old new file mode 100644 index 0000000000000000000000000000000000000000..745339ade65e69b6629e3bb534846e805710fd09 --- /dev/null +++ b/boards/riscv64/virt/Makefile_old @@ -0,0 +1,98 @@ +# Copyright (C) 2016-2021 Wu Zhangjin +_BASE := 1 +ARCH := riscv +XARCH := riscv64 +# Use the default setting +CPU ?= +SMP ?= 4 +MEM ?= 256M +QEMU ?= v6.0.0 +# Enable QEMU_US=1 for qemu-user-static +QEMU_US ?= 0 +LINUX ?= v6.2 + +# git repos for the other kernel forks +KERNEL_GIT[KERNEL_FORK_openeuler] := https://gitee.com/openeuler/kernel.git +LINUX[KERNEL_FORK_openeuler] ?= 5.10.0-132.0.0 + +BUILDROOT?= 2019.05 +NETDEV_LIST := virtio +NETDEV ?= virtio +SERIAL ?= ttyS0 + +# use bochs as VGA graphic device +FBDEV ?= stdvga +# use virtio as keyboard device +KBDEV ?= virtio + +UBOOT ?= v2022.04 + +KRN_ADDR?= 0x84000000 +RDK_ADDR?= 0x87500000 + +# QEMU load env.img to ram and then U-boot import it from ram +ENV_DEV_LIST := ram +ENV_DEV ?= ram +ENV_OFFSET ?= 0 +ENV_ADDR ?= 0x87300000 + +UCONFIG ?= qemu-riscv.h +BOOTDEV_LIST := tftp ram +BOOTDEV ?= ram + +# ref: https://wiki.qemu.org/Documentation/9psetup +# 9pnet based network filesystem sharing, aarch64/virt board support both virtio-9p-pci/-virtfs and virtio-9p-device +# But virtio-9p-device requires less kernel options (no need the PCI related parts in features/linux/9pnet/) +# To eanble this function, please make sure the 9pnet feature is enabled: make feature f=9pnet && make kernel-olddefconfig +# +# TODO: add board specific 9pnet options. +# + +NET9PDEV ?= virtio-9p-device + +# virtio vda: https://wiki.debian.org/Arm64Qemu +ROOTDEV_LIST := /dev/vda /dev/ram0 /dev/nfs +ROOTDEV ?= /dev/vda + +FSTYPE ?= ext2 + +# fw_jump.elf and fw_dynamic.elf are built from https://gitlab.com/qemu-project/opensbi +BIOS ?= $(or $(wildcard $(BSP_BIOS)/opensbi/generic/fw_dynamic.elf),$(BSP_BIOS)/opensbi/generic/fw_jump.elf) + +ifeq ($(vmlinuz),1) +ORIIMG ?= arch/$(ARCH)/boot/compressed/vmlinuz +KIMAGE ?= $(BSP_KERNEL)/$(LINUX)/vmlinuz +else +ORIIMG ?= arch/$(ARCH)/boot/Image +KIMAGE ?= $(BSP_KERNEL)/$(LINUX)/Image +endif + +#DTS ?= $(BSP_KERNEL)/$(LINUX)/qemu-$(XARCH)-$(MACH).dts +UORIIMG ?= $(ORIIMG) +BIMAGE ?= $(BSP_UBOOT)/$(UBOOT)/u-boot +UKIMAGE ?= $(KIMAGE) +#DTB ?= $(BSP_KERNEL)/$(LINUX)/qemu-$(XARCH)-$(MACH).dtb + +ifneq ($(wildcard $(DTB)),) + DTB_ADDR := 0x87000000 +else + DTB_ADDR := $$fdtcontroladdr +endif + +ifeq ($(NOMMU),1) + override SMP := 1 + override BIOS := none + override U := 0 +endif + +ROOTFS ?= $(BSP_ROOT)/$(BUILDROOT)/rootfs.cpio.gz +HROOTFS ?= $(BSP_ROOT)/$(BUILDROOT)/rootfs.$(FSTYPE) + +#XKCLI ?= earlycon=sbi +QTOOL[OS_trusty] ?= $(BSP_QEMU)/$(QEMU)/bin/qemu-system-$(XARCH) +QTOOL[OS_focal] ?= $(BSP_QEMU)/$(QEMU)/bin/qemu-system-$(XARCH) + +# external toolchain, please download it while: make toolchain +# Available CCORI: bootlin, gnu-mcu-eclipse +CCORI[OS_trusty] ?= gnu-mcu-eclipse +CCORI[OS_focal] ?= internal diff --git a/boards/riscv64/virt/README.md b/boards/riscv64/virt/README.md index 79d858a4a00816d69de143a4d4b99c0a26b212ee..c4524c7d356f8975b283f0aedcd271613f980ee7 100644 --- a/boards/riscv64/virt/README.md +++ b/boards/riscv64/virt/README.md @@ -1,64 +1,27 @@ - -# Risc64 Virt Usage +# Unikernel Riscv Usage ## Basic Usage -Works perfectly: - - $ make boot V=1 +Use the following command to compile Unikernel Riscv: - $ make boot SHARE=1 + $ make kernel - $ make boot ROOTDEV=/dev/nfs +Some work can be done automatically: -Buildroot provides rootfs config and toolchain, mainline linux provides the -official kernel config, everything goes well. Qemu v4.0.0 has the riscv64 board -support. +1. Build the cross compiler +2. Switch to the selected kernel version +3. Patch the kernel with patches in bsp/patch/linux/ +4. Use config in bsp/configs/ as kernel config +5. Compile the kernel +6. Compile the dts ## BIOS -The only difference is riscv64 requires a proxy kernel to do some prepare -before running the real linux kernel. and the proxy kernel currently is -replaced by the opensbi project. - -Newer qemu and kernel support works with the standard -bios option with opensbi. - -We can build one in Linux Lab with these commands: - - $ cd src/examples/ - $ git clone https://github.com/riscv/opensbi - $ cd opensbi - // for riscv32 - $ make all PLATFORM=generic LLVM=1 PLATFORM_RISCV_XLEN=32 - // for riscv64 - $ make all PLATFORM=generic LLVM=1 PLATFORM_RISCV_XLEN=64 - $ ls build/platform/generic/firmware/fw_jump.elf - -## DTS - -The cpu, memory and external devices configuration in dts must match the -setting from the QEMU options, otherwise, it may not boot. - -If want to change the QEMU options, please make sure update the dts -configurations too, or, simply reset `DTB` variable like this to use the -default dtb transferred by QEMU: - - $ make boot DTB= - -The default dtb is dumped out of QEMU: +Riscv64 requires a proxy kernel to do some prepare before running the real linux kernel. - $ make boot DUMPDTB=1 +And the proxy kernel currently is replaced by the OpenSBI project. -## References +# References -* [Qemu RISCV Documentation](https://wiki.qemu.org/Documentation/Platforms/RISCV) -* [RISCV Software Status](https://riscv.org/software-status) -* [RV8: RISC-V simulator for x86-64 (Another simulator)](https://github.com/rv8-io/rv8) -* [RISC-V Debian](https://wiki.debian.org/RISC-V) -* [Running 64- and 32-bit RISC-V Linux on QEMU](https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html) -* [RISC-V GNU Compiler Toolchain](https://github.com/riscv/riscv-gnu-toolchain) -* [Prebuilt GNU Toolchain](https://www.sifive.com/boards) -* [RISC-V Proxy Kernel and Boot Loader](https://github.com/riscv/riscv-pk) -* [RISC-V Open Source Supervisor Binary Interface](https://github.com/riscv/opensbi) -* buildroot/configs/qemu_riscv64_virt_defconfig -* buildroot/board/qemu/riscv64-virt/ +* [A unikernel based on Linux](https://next.redhat.com/2018/11/14/ukl-a-unikernel-based-on-linux/) +* [unikernelLinux](https://github.com/unikernelLinux/ukl) diff --git a/boards/riscv64/virt/bsp b/boards/riscv64/virt/bsp index e2963d29ec417e7df835c709d00bc3d511b2bc14..e5172360a4c473b2358b1df0e6340a6d573a8a00 160000 --- a/boards/riscv64/virt/bsp +++ b/boards/riscv64/virt/bsp @@ -1 +1 @@ -Subproject commit e2963d29ec417e7df835c709d00bc3d511b2bc14 +Subproject commit e5172360a4c473b2358b1df0e6340a6d573a8a00 diff --git a/src/feature/linux/unikernel/README.md b/src/feature/linux/unikernel/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f80c1e23effd8b6aafd429e3c368e2886c995977 --- /dev/null +++ b/src/feature/linux/unikernel/README.md @@ -0,0 +1,29 @@ +# Unikernel Riscv Usage + +## Basic Usage + +Use the following command to compile Unikernel Riscv: + + $ make kernel + +Some work can be done automatically: + +1. Build the cross compiler +2. Switch to the selected kernel version +3. Patch the kernel with patches in bsp/patch/linux/ +4. Use config in bsp/configs/ as kernel config +5. Compile the kernel +6. Compile the dts + +## BIOS + +Riscv64 requires a proxy kernel to do some prepare before running the real linux kernel. + +And the proxy kernel currently is replaced by the OpenSBI project. + +More detailed instruction is in bsp/bios/opensbi/README.md. + +# References + +* [A unikernel based on Linux](https://next.redhat.com/2018/11/14/ukl-a-unikernel-based-on-linux/) +* [unikernelLinux](https://github.com/unikernelLinux/ukl)