diff --git a/.gitmodules b/.gitmodules index 18bff4eaa0302d6b5f54265c059570f7b98f17d8..47c8805e00ec56a459a6bc2ecd16af63a101bedf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "qemu"] path = src/qemu - url = https://gitee.com/mirrors/qemu.git + url = https://gitlab.com/qemu-project/qemu.git ignore = all [submodule "buildroot"] path = src/buildroot @@ -12,7 +12,7 @@ ignore = all [submodule "u-boot"] path = src/u-boot - url = https://gitee.com/mirrors/u-boot.git + url = https://gitlab.com/qemu-project/u-boot.git ignore = all [submodule "boards/aarch64/raspi3/bsp"] ignore = all diff --git a/Makefile b/Makefile index 1c2bd383601da801006a4f6be07d915792480c58..453f7346a77ac85e6097369f76c82399b19a1a75 100644 --- a/Makefile +++ b/Makefile @@ -206,13 +206,15 @@ PREBUILT_BIOS := $(PREBUILT_DIR)/bios # Core source: remote and local #QEMU_GIT ?= https://github.com/qemu/qemu.git -QEMU_GIT ?= https://gitee.com/mirrors/qemu.git +#QEMU_GIT ?= https://gitee.com/mirrors/qemu.git +QEMU_GIT ?= https://gitlab.com/qemu-project/qemu.git _QEMU_GIT := $(QEMU_GIT) _QEMU_SRC ?= $(if $(QEMU_FORK),$(call _lc,$(QEMU_FORK)-qemu),qemu) QEMU_SRC ?= $(_QEMU_SRC) #UBOOT_GIT ?= https://github.com/u-boot/u-boot.git -UBOOT_GIT ?= https://gitee.com/mirrors/u-boot.git +#UBOOT_GIT ?= https://gitee.com/mirrors/u-boot.git +UBOOT_GIT ?= https://gitlab.com/qemu-project/u-boot.git _UBOOT_GIT := $(UBOOT_GIT) _UBOOT_SRC ?= $(if $(UBOOT_FORK),$(call _lc,$(UBOOT_FORK)-uboot),u-boot) UBOOT_SRC ?= $(_UBOOT_SRC) @@ -2171,11 +2173,16 @@ _qemu_update_submodules: _qemu: _qemu_update_submodules $(call make_qemu,$(QT)) - $(Q)if [ ! -L $(QEMU_BUILD)/etc/qemu-ifup ]; then \ + $(Q)if [ ! -L $(QEMU_BUILD)/../etc/qemu-ifup ]; then \ mkdir -p $(QEMU_BUILD)/../etc/; \ ln -sf /etc/qemu-ifup $(QEMU_BUILD)/../etc/qemu-ifup; \ ln -sf /etc/qemu-ifdown $(QEMU_BUILD)/../etc/qemu-ifdown; \ fi + $(Q)if [ ! -L $(QEMU_BUILD)/qemu-bundle$(PREBUILT_QEMU_DIR)/etc/qemu-ifup ]; then \ + mkdir -p $(QEMU_BUILD)/qemu-bundle$(PREBUILT_QEMU_DIR)/etc/; \ + ln -sf /etc/qemu-ifup $(QEMU_BUILD)/qemu-bundle$(PREBUILT_QEMU_DIR)/etc/qemu-ifup; \ + ln -sf /etc/qemu-ifdown $(QEMU_BUILD)/qemu-bundle$(PREBUILT_QEMU_DIR)/etc/qemu-ifdown; \ + fi endif # Qemu targets @@ -2910,7 +2917,7 @@ IMAGE := $(notdir $(ORIIMG)) # aarch64 not add uboot header for kernel image ifeq ($(U),1) - ifeq ($(ARCH),arm64) + ifeq ($(UKIMAGE),$(KIMAGE)) IMAGE := Image else IMAGE := uImage @@ -3155,7 +3162,9 @@ ifeq ($(findstring /dev/ram,$(ROOTDEV)),) RDK_ADDR := - endif ifeq ($(DTS),) - DTB_ADDR := - + ifneq ($(DTB_ADDR),$$fdtcontroladdr) + DTB_ADDR := - + endif endif export U_BOOT_CMD IP ROUTE ROOTDEV BOOTDEV ROOTDIR PFLASH_BASE KRN_ADDR KRN_SIZE RDK_ADDR RDK_SIZE DTB_ADDR DTB_SIZE @@ -3204,7 +3213,8 @@ root-ud-clean: PHONY += root-ud root-ud-rebuild root-ud-clean -# aarch64 not add uboot header for kernel image +# aarch64 and riscv don't add uboot header for kernel image +ifneq ($(UKIMAGE), $(KIMAGE)) $(UKIMAGE): $(KIMAGE) $(Q)if [ "$(PBK)" = "0" ]; then \ if [ "$(notdir $(UKIMAGE))" = "uImage" ]; then \ @@ -3213,6 +3223,9 @@ $(UKIMAGE): $(KIMAGE) cp -v $(KIMAGE) $(UKIMAGE); \ fi; \ fi +else +$(UKIMAGE): +endif ifneq ($(INVALID_ROOTFS),1) U_ROOT_IMAGE := $(UROOTFS) @@ -3224,7 +3237,11 @@ ifneq ($(wildcard $(DTB)),) U_DTB_IMAGE := $(DTB) endif -BOOTX := $(if $(UBOOT_BIOS),booti,bootm) +ifeq ($(UKIMAGE),$(KIMAGE)) + BOOTX := booti +else + BOOTX := bootm +endif export CMDLINE PFLASH_IMG PFLASH_SIZE PFLASH_BS ENV_ADDR ENV_OFFSET ENV_SIZE BOOTX BOOTDEV_LIST SD_IMG U_ROOT_IMAGE RDK_SIZE U_DTB_IMAGE DTB_SIZE U_KERNEL_IMAGE KRN_SIZE TFTPBOOT BIMAGE ROUTE BOOTDEV @@ -3625,7 +3642,14 @@ else endif endif -EMULATOR_OPTS ?= -M $(MACH) $(if $(CPU),-cpu $(CPU)) -m $(call _v,MEM,LINUX) $(NET) -smp $(call _v,SMP,LINUX) $(KERNEL_OPT) $(EXIT_ACTION) +ifeq ($(DUMPDTB), 1) + QEMU_DTB ?= $(BSP_KERNEL)/$(LINUX)/qemu-$(XARCH)-$(MACH).dtb + QEMU_DTS := $(QEMU_DTB:.dtb=.dts) + DUMPDTB_OPT ?= ,dumpdtb=$(QEMU_DTB) + DUMPDTB_CMD ?= $(Q)[ -f $(QEMU_DTB) ] && dtc -o $(QEMU_DTS) -O dts -I dtb $(QEMU_DTB) +endif + +EMULATOR_OPTS ?= -M $(MACH)$(DUMPDTB_OPT) $(if $(CPU),-cpu $(CPU)) -m $(call _v,MEM,LINUX) $(NET) -smp $(call _v,SMP,LINUX) $(KERNEL_OPT) $(EXIT_ACTION) EMULATOR_OPTS += $(SHARE_OPT) D ?= 0 @@ -3640,15 +3664,19 @@ ifeq ($(U),1) endif ifeq ($(RAM_BOOT),1) BOOT_CMD += -device loader,file=$(UKIMAGE),addr=$(KRN_ADDR) - BOOT_CMD += -device loader,file=$(DTB),addr=$(DTB_ADDR) + ifneq ($(DTB_ADDR),-) + ifneq ($(DTB_ADDR),$$fdtcontroladdr) + BOOT_CMD += -device loader,file=$(DTB),addr=$(DTB_ADDR) + endif + endif ifneq ($(findstring /dev/ram,$(ROOTDEV)),) - BOOT_CMD += -device loader,file=$(UROOTFS),addr=$(RDK_ADDR) + ifneq ($(RDK_ADDR),-) + BOOT_CMD += -device loader,file=$(UROOTFS),addr=$(RDK_ADDR) + endif endif endif - ifeq ($(UBOOT_BIOS),1) - ifneq ($(ENV_DEV), flash) - BOOT_CMD += -device loader,file=$(ENV_IMG),addr=$(ENV_ADDR) - endif + ifeq ($(ENV_DEV),ram) + BOOT_CMD += -device loader,file=$(ENV_IMG),addr=$(ENV_ADDR) endif ifneq ($(PFLASH_SIZE),0) @@ -4060,6 +4088,7 @@ endif _boot: $(_BOOT_DEPS) $(RUN_BOOT_CMD) + $(DUMPDTB_CMD) PHONY += boot-test _boot diff --git a/README.md b/README.md index 0df9ce5578967fe534fc254ee593f55fc7551842..0df2009d9974719e57e2d4732a5f9d896211570a 100644 --- a/README.md +++ b/README.md @@ -978,7 +978,7 @@ Boot without Uboot (only `versatilepb` and `vexpress-a9` boards tested): Boot with different rootfs (depends on board, check `/dev/` after boot): - $ make boot ROOTDEV=ram // support by all boards, basic boot method + $ make boot ROOTDEV=ram0 // support by all boards, basic boot method $ make boot ROOTDEV=nfs // depends on network driver, only raspi3 not work $ make boot ROOTDEV=sda $ make boot ROOTDEV=mmcblk0 diff --git a/README_zh.md b/README_zh.md index 31626013057b9525a6e2917496865cd5885d7481..52dd68fbce0e9e5b433c31f1fda7d044342ac7c1 100644 --- a/README_zh.md +++ b/README_zh.md @@ -1173,7 +1173,7 @@ v0.3 以及之后的版本默认增加了目标依赖支持,所以,如果想 使用不同的 rootfs 启动(依赖于开发板的支持,启动后检查 `/dev/`) - $ make boot ROOTDEV=ram // support by all boards, basic boot method + $ make boot ROOTDEV=ram0 // support by all boards, basic boot method $ make boot ROOTDEV=nfs // depends on network driver, only raspi3 not work $ make boot ROOTDEV=sda $ make boot ROOTDEV=mmcblk0 diff --git a/boards/aarch64/virt/Makefile b/boards/aarch64/virt/Makefile index 1f8e1478f07f50450fcf6b25cf90ac7634e7e5df..22824a514f4a73460952b830638b4230c8404aff 100644 --- a/boards/aarch64/virt/Makefile +++ b/boards/aarch64/virt/Makefile @@ -72,7 +72,9 @@ PFLASH_BS ?= 512 # Environment Offset, see CONFIG_ENV_OFFSET in $UCONFIG ENV_OFFSET ?= 0 ENV_SIZE ?= 1 -ENVDEV ?= flash +# ram, flash +ENV_DEV_LIST := ram flash +ENV_DEV ?= flash ifeq ($(ENV_DEV), flash) ENV_ADDR ?= 0x4000000 else diff --git a/boards/riscv64/virt/Makefile b/boards/riscv64/virt/Makefile index 0eb19e73262761fe3c8126a2ed395ccd3ff09215..ab03b464906ea40a9ed5230c57a368ed845ac595 100644 --- a/boards/riscv64/virt/Makefile +++ b/boards/riscv64/virt/Makefile @@ -5,7 +5,7 @@ XARCH := riscv64 # Use the default setting CPU ?= SMP ?= 4 -MEM ?= 128M +MEM ?= 256M QEMU ?= v6.0.0 # Enable QEMU_US=1 for qemu-user-static QEMU_US ?= 0 @@ -15,6 +15,22 @@ NETDEV_LIST := virtio NETDEV ?= virtio SERIAL ?= ttyS0 +UBOOT ?= v2022.04 + +KRN_ADDR?= 0x84000000 +DTB_ADDR?= $$fdtcontroladdr +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 := 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/) @@ -34,10 +50,19 @@ FSTYPE ?= ext2 # fw_jump.elf is from https://github.com/riscv/opensbi BIOS ?= $(BSP_BIOS)/opensbi/generic/fw_jump.elf -KRN_ADDR ?= 0x80200000 ORIIMG ?= arch/$(ARCH)/boot/Image KIMAGE ?= $(BSP_KERNEL)/$(LINUX)/Image +DTS ?= $(BSP_KERNEL)/$(LINUX)/qemu-$(XARCH)-$(MACH).dts +UORIIMG ?= arch/$(ARCH)/boot/Image +BIMAGE ?= $(BSP_UBOOT)/$(UBOOT)/u-boot +UKIMAGE ?= $(BSP_KERNEL)/$(LINUX)/Image +DTB ?= $(BSP_KERNEL)/$(LINUX)/qemu-$(XARCH)-$(MACH).dtb + +ifneq ($(wildcard $(DTB)),) + DTB_ADDR := 0x87000000 +endif + ROOTFS ?= $(BSP_ROOT)/$(BUILDROOT)/rootfs.cpio.gz HROOTFS ?= $(BSP_ROOT)/$(BUILDROOT)/rootfs.$(FSTYPE) diff --git a/boards/riscv64/virt/README.md b/boards/riscv64/virt/README.md index cc52e0f7451865e680e8e029776dfebc4510a5a9..79d858a4a00816d69de143a4d4b99c0a26b212ee 100644 --- a/boards/riscv64/virt/README.md +++ b/boards/riscv64/virt/README.md @@ -34,6 +34,21 @@ We can build one in Linux Lab with these commands: $ 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: + + $ make boot DUMPDTB=1 + ## References * [Qemu RISCV Documentation](https://wiki.qemu.org/Documentation/Platforms/RISCV) diff --git a/tools/build/uncache b/tools/build/uncache index 3e5a8220900c2baa3fa79620ab714efab56070e2..38bc67ad149f8d85c76f61c6647bec7f81d0f069 100755 Binary files a/tools/build/uncache and b/tools/build/uncache differ