diff --git a/Makefile b/Makefile index 78ad182..dea116e 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,9 @@ endif # from it through the print-buildroot-version target, so a bump here is enough. BUILDROOT_VERSION := 2026.08 BUILDROOT_DIR := build/buildroot +# DEFAULT_DTB=nutshell or nutshell-* -> nutshell_defconfig; otherwise xiangshan_defconfig. +BUILDROOT_DEFCONFIG := $(if $(filter nutshell nutshell-%,$(DEFAULT_DTB)),nutshell_defconfig,xiangshan_defconfig) +BUILDROOT_CONFIG_STAMP := build/buildroot-config/$(BUILDROOT_DEFCONFIG) $(BUILDROOT_DIR)/Makefile: mkdir -p build wget https://buildroot.org/downloads/buildroot-$(BUILDROOT_VERSION).tar.gz -O build/buildroot.tar.gz @@ -56,17 +59,22 @@ $(BUILDROOT_DIR)/Makefile: print-buildroot-version: @echo $(BUILDROOT_VERSION) +$(BUILDROOT_CONFIG_STAMP): br2-external/configs/$(BUILDROOT_DEFCONFIG) $(BUILDROOT_DIR)/Makefile + mkdir -p "$(@D)" + rm -f build/buildroot-config/* + touch $@ + # Prepare buildroot SDK TOOLCHAIN_WRAPPER := $(BUILDROOT_DIR)/output/host/bin/toolchain-wrapper -$(TOOLCHAIN_WRAPPER): br2-external/configs/nemu_defconfig $(BUILDROOT_DIR)/Makefile - $(MAKE) -C $(BUILDROOT_DIR) BR2_EXTERNAL=$(abspath br2-external) nemu_defconfig +$(TOOLCHAIN_WRAPPER): $(BUILDROOT_CONFIG_STAMP) + $(MAKE) -C $(BUILDROOT_DIR) BR2_EXTERNAL=$(abspath br2-external) $(BUILDROOT_DEFCONFIG) $(MAKE) -C $(BUILDROOT_DIR) BR2_EXTERNAL=$(abspath br2-external) prepare-sdk touch $(TOOLCHAIN_WRAPPER) # Build Linux kernel LINUX_IMAGE := $(BUILDROOT_DIR)/output/images/Image -$(LINUX_IMAGE): $(TOOLCHAIN_WRAPPER) br2-external/configs/nemu_defconfig br2-external/board/openxiangshan/nemu/linux.config - $(MAKE) -C $(BUILDROOT_DIR) BR2_EXTERNAL=$(abspath br2-external) nemu_defconfig +$(LINUX_IMAGE): $(TOOLCHAIN_WRAPPER) $(BUILDROOT_CONFIG_STAMP) br2-external/board/openxiangshan/nemu/linux.config $(if $(filter nutshell_defconfig,$(BUILDROOT_DEFCONFIG)),br2-external/board/openxiangshan/nemu/linux-nutshell.fragment) + $(MAKE) -C $(BUILDROOT_DIR) BR2_EXTERNAL=$(abspath br2-external) $(BUILDROOT_DEFCONFIG) $(MAKE) -C $(BUILDROOT_DIR) BR2_EXTERNAL=$(abspath br2-external) # Build GCPT. Single-core firmware keeps LibCheckpointAlpha; LibCheckpoint is @@ -217,7 +225,7 @@ prepare-sdk: $(TOOLCHAIN_WRAPPER) # Download all source files needed by buildroot source: $(BUILDROOT_DIR)/Makefile - make -C $(BUILDROOT_DIR) BR2_EXTERNAL=$(abspath br2-external) nemu_defconfig + make -C $(BUILDROOT_DIR) BR2_EXTERNAL=$(abspath br2-external) $(BUILDROOT_DEFCONFIG) make -C $(BUILDROOT_DIR) BR2_EXTERNAL=$(abspath br2-external) source # Build all all-in-one firmware images diff --git a/README.md b/README.md index b2d9937..802b20a 100644 --- a/README.md +++ b/README.md @@ -114,13 +114,20 @@ builds default `GCPT_SERIAL_PORT` to the QEMU 16550A TX register at ## Workload Compatibility Not all workloads can run on all NEMU or QEMU configurations. QEMU support is -limited to `linux/coremark`, `linux/spec2006`, and `linux/spec2017`; the only workload supported by -`riscv64-nutshell_defconfig` is `linux/hello`, since all other workloads require -hardware floating point, which is not supported by nutshell. RVV related workloads -require the vector ISA extension, and hypervisor related workloads require the -hypervisor ISA extension. +limited to `linux/coremark`, `linux/spec2006`, and `linux/spec2017`. RVV related +workloads require the vector ISA extension, and hypervisor related workloads +require the hypervisor ISA extension. -NutShell uses the RV64IMAC/LP64 software stack. See the +`xiangshan_defconfig` is the XiangShan/NEMU Buildroot tree. NutShell is RV64IMAC; +Linux images use `nutshell_defconfig` (lp64) when `DEFAULT_DTB` is `nutshell`, +`nutshell-mem2g`, or `nutshell-fpga`: + +```sh +make linux/hello DEFAULT_DTB=nutshell +make linux/spec2006 BENCH=mcf DEFAULT_DTB=nutshell-mem2g SPEC2006_ISO=/path/to/cpu2006.iso +``` + +See the [SPEC2006 configuration](workloads/linux/spec2006/README.md#configuration) section for `riscv_gcc16_rv64imac_lp64.cfg`. diff --git a/br2-external/board/openxiangshan/nemu/linux-nutshell.fragment b/br2-external/board/openxiangshan/nemu/linux-nutshell.fragment new file mode 100644 index 0000000..2c5b3f0 --- /dev/null +++ b/br2-external/board/openxiangshan/nemu/linux-nutshell.fragment @@ -0,0 +1,6 @@ +# NutShell is RV64IMAC. Share linux.config with XiangShan; turn off ISA +# the core does not implement. linux.config enables KVM. +# CONFIG_FPU is not set +# CONFIG_RISCV_ISA_V is not set +# CONFIG_VIRTUALIZATION is not set +# CONFIG_KVM is not set diff --git a/br2-external/configs/nutshell_defconfig b/br2-external/configs/nutshell_defconfig new file mode 100644 index 0000000..0f8e22b --- /dev/null +++ b/br2-external/configs/nutshell_defconfig @@ -0,0 +1,22 @@ +# NutShell RV64IMAC/LP64. Bootlin only ships lp64d, so Buildroot builds gcc. +# Keep xiangshan_defconfig for XiangShan/NEMU. +BR2_riscv=y +BR2_riscv_custom=y +BR2_RISCV_ISA_RVM=y +BR2_RISCV_ISA_RVA=y +BR2_RISCV_ISA_RVC=y +BR2_RISCV_64=y +BR2_RISCV_ABI_LP64=y +BR2_TOOLCHAIN_BUILDROOT=y +BR2_TOOLCHAIN_BUILDROOT_GLIBC=y +BR2_TARGET_GENERIC_HOSTNAME="nutshell" +BR2_TARGET_GENERIC_ISSUE="NutShell rv64imac/lp64" +BR2_TARGET_GENERIC_ROOT_PASSWD="xiangshan" +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y +BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="${BR2_EXTERNAL}/board/openxiangshan/nemu/linux.config" +BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="${BR2_EXTERNAL}/board/openxiangshan/nemu/linux-nutshell.fragment" +BR2_TARGET_ROOTFS_INITRAMFS=y +BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES="${BR2_EXTERNAL}/board/openxiangshan/nemu/busybox-taskset.fragment" +BR2_PACKAGE_NEMU_TRAP=y +BR2_PACKAGE_NEMU_EXEC=y diff --git a/br2-external/configs/nemu_defconfig b/br2-external/configs/xiangshan_defconfig similarity index 88% rename from br2-external/configs/nemu_defconfig rename to br2-external/configs/xiangshan_defconfig index 158e58a..e707521 100644 --- a/br2-external/configs/nemu_defconfig +++ b/br2-external/configs/xiangshan_defconfig @@ -1,3 +1,4 @@ +# XiangShan/NEMU (Bootlin rv64gc). NutShell uses nutshell_defconfig. BR2_riscv=y BR2_RISCV_ISA_RVC=y BR2_TOOLCHAIN_EXTERNAL=y diff --git a/dts/README.md b/dts/README.md index 9e79e1c..e0c3cc2 100644 --- a/dts/README.md +++ b/dts/README.md @@ -41,6 +41,9 @@ profiles, FPGA noAIA names, and QEMU `nemu` names of the form custom template passed through `--custom-template-dir`; otherwise generation fails with an `unsupported DTS basename` error. +Linux images with `DEFAULT_DTB=nutshell` or `nutshell-*` use +`nutshell_defconfig` (RV64IMAC/LP64) instead of `xiangshan_defconfig`. + `nutshell` is the 128 MiB machine description used by NEMU's `riscv64-nutshell_defconfig`: uartlite at `0x40600000`, no PLIC. NutShell simulation uses the same map. `nutshell-mem2g` keeps that diff --git a/workloads/linux/spec2006/README.md b/workloads/linux/spec2006/README.md index b682f5f..fe096d7 100644 --- a/workloads/linux/spec2006/README.md +++ b/workloads/linux/spec2006/README.md @@ -220,12 +220,16 @@ For GCC 15, select: workloads/linux/spec2006/configs/riscv_gcc15_base.cfg ``` -For NutShell, select the RV64IMAC/lp64 configuration: +For NutShell (`DEFAULT_DTB=nutshell`, `nutshell-mem2g`, or `nutshell-fpga`), +the default is the RV64IMAC/lp64 configuration: ```text workloads/linux/spec2006/configs/riscv_gcc16_rv64imac_lp64.cfg ``` +That compiler must be an rv64imac/lp64 `riscv64-unknown-linux-gnu-gcc`, not +the XiangShan RVA23 toolchain that uses the same triple. + Override it with: ```sh diff --git a/workloads/linux/spec2006/rules.mk b/workloads/linux/spec2006/rules.mk index ff5ce69..a666839 100644 --- a/workloads/linux/spec2006/rules.mk +++ b/workloads/linux/spec2006/rules.mk @@ -7,7 +7,7 @@ SPEC2006_SCRIPTS_DIR := $(SPEC2006_REPO_ROOT)/scripts SPEC2006_DTS_DIR := $(SPEC2006_REPO_ROOT)/build/generated-dts SPEC2006_BUILD_DIR ?= $(SPEC2006_REPO_ROOT)/build/linux-workloads/spec2006 SPEC2006_CASE_CONFIG := $(SPEC2006_WORKLOAD_DIR)/spec06.json -SPEC2006_CFG ?= $(SPEC2006_WORKLOAD_DIR)/configs/gcc16-linux-riscv64-rva23u64_novec.cfg +SPEC2006_CFG ?= $(SPEC2006_WORKLOAD_DIR)/configs/$(if $(filter nutshell nutshell-%,$(DEFAULT_DTB)),riscv_gcc16_rv64imac_lp64.cfg,gcc16-linux-riscv64-rva23u64_novec.cfg) SPEC2006_HELPER := $(SPEC2006_WORKLOAD_DIR)/spec2006-package.py QEMU_DEFAULT_DTB ?= xiangshan-qemu-nemu-mem2g SPEC2006_SOURCE_SPEC_ISO := $(SPEC2006_ISO)