Bladeren bron

qemu-loongarch: allow to build a disk image

Waldemar Brodkorb 2 weken geleden
bovenliggende
commit
07cfe76a6c

+ 3 - 1
mk/image.mk

@@ -350,8 +350,10 @@ ${FW_DIR}/${GENIMAGE}: ${TARGET_DIR} kernel-package
 	$(CP) $(EXTLINUX) $(FW_DIR)/extlinux
 	mkdir -p $(TARGET_DIR)/boot/extlinux
 	$(CP) $(EXTLINUX) $(TARGET_DIR)/boot/extlinux
+ifeq ($(ADK_TARGET_LINUX_KERNEL_IN_VFAT),)
 	$(CP) $(FW_DIR)/kernel $(TARGET_DIR)/boot
 	-$(CP) $(FW_DIR)/*.dtb $(TARGET_DIR)/boot 2>/dev/null
+endif
 ifeq ($(ADK_RUNTIME_FIX_PERMISSION),y)
 	echo '#!/bin/sh' > $(ADK_TOPDIR)/scripts/fakeroot.sh
 	echo "chown -R 0:0 $(TARGET_DIR)" >> $(ADK_TOPDIR)/scripts/fakeroot.sh
@@ -386,7 +388,7 @@ else
 	PATH='${HOST_PATH}' $(FAKEROOT) mkfs.ext2 \
 		-d "$(TARGET_DIR)" \
 		-r 1 -N 0 -m 5 -L "rootfs" \
-		$(FW_DIR)/rootfs.ext "64M" $(MAKE_TRACE)
+		$(FW_DIR)/rootfs.ext "128M" $(MAKE_TRACE)
 	PATH='${HOST_PATH}' genimage \
 		--config "$(GENCFG)" \
 		--tmppath "${FW_DIR}/temp" \

+ 1 - 1
package/grub/files/grub-efi-serial.cfg

@@ -10,5 +10,5 @@ menuentry "OpenADK" {
   insmod ext2
   set root='hd0,gpt2'
   echo "Loading OpenADK"
-  linux /boot/kernel root=/dev/sda2 console=ttyS0,115200 rootfstype=ext4 rootwait panic=10
+  linux /boot/kernel root=/dev/@@ROOTDEV@@2 console=ttyS0,115200 rootfstype=ext4 rootwait panic=10
 }

+ 1 - 0
target/config/Config.in.rootfs

@@ -175,6 +175,7 @@ config ADK_TARGET_ROOTDEV
 	string "Root device name"
 	depends on ADK_TARGET_ROOTFS_GENIMAGE
 	default "mmcblk0" if ADK_TARGET_SYSTEM_ROCKPI4_PLUS
+	default "vda" if ADK_TARGET_SYSTEM_QEMU_LOONGARCH
 	default "sda"
 	help
 	  If you have a embedded device with multiple block devices and want to

+ 2 - 0
target/linux/Config.in.kernelcfg

@@ -84,3 +84,5 @@ config ADK_TARGET_LINUX_KERNEL_CUSTOMCONFIG_PATH
 	depends on ADK_TARGET_LINUX_KERNEL_USE_CUSTOMCONFIG
 	default ".kernelconfig"
 
+config ADK_TARGET_LINUX_KERNEL_IN_VFAT
+	bool

+ 18 - 3
target/loongarch/Makefile

@@ -7,9 +7,9 @@ include $(ADK_TOPDIR)/mk/image.mk
 
 KERNEL:=$(LINUX_DIR)/arch/loongarch/boot/vmlinux.efi
 
-QEMU_ARGS:=-M virt -bios target/loongarch/QEMU_EFI.fd -append "console=ttyS0,115200"
+QEMU_ARGS:=-M virt -m 512 -bios target/loongarch/QEMU_EFI.fd
 QEMU_ARGS+=-nographic
-#
+
 # target helper text
 ifeq ($(ADK_TARGET_FS),archive)
 targethelp:
@@ -44,11 +44,23 @@ ifeq ($(ADK_TARGET_QEMU),y)
 	@echo 'qemu-system-${ADK_TARGET_CPU_ARCH} ${QEMU_ARGS} -kernel $(FW_DIR)/$(TARGET_KERNEL)'
 endif
 endif
+ifeq ($(ADK_TARGET_FS),genimage)
+targethelp:
+	@echo "The disk image is: $(FW_DIR)/disk.img"
+ifeq ($(ADK_TARGET_QEMU),y)
+	@echo "Start qemu with following command line:"
+	@echo 'qemu-system-${ADK_TARGET_CPU_ARCH} ${QEMU_ARGS} $(FW_DIR)/disk.img'
+else
+	@echo "Use following command to install it on SD card:"
+	@echo 'sudo dd if=$(FW_DIR)/disk.img of=/dev/sdX bs=2048k'
+endif
+endif
 
 kernel-strip:
+	@cp $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
 
 kernel-install: kernel-strip
-	@cp $(KERNEL) $(FW_DIR)/$(TARGET_KERNEL)
+	@cp $(BUILD_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(TARGET_KERNEL)
 
 # filesystem specific targets
 ifeq ($(ADK_TARGET_FS),initramfs)
@@ -60,3 +72,6 @@ endif
 ifeq ($(ADK_TARGET_FS),initramfspiggyback)
 imageinstall: createinitramfs targethelp
 endif
+ifeq ($(ADK_TARGET_FS),genimage)
+imageinstall: kernel-install $(FW_DIR)/$(GENIMAGE) targethelp
+endif

BIN
target/loongarch/QEMU_EFI.fd


+ 36 - 0
target/loongarch/qemu-loongarch/genimage.cfg

@@ -0,0 +1,36 @@
+image efi-part.vfat {
+	vfat {
+		file EFI {
+			image = "efi-part/EFI"
+		}
+		file kernel {
+			image = "kernel"
+		}
+	}
+
+	size = 128M
+}
+
+image disk.img {
+	hdimage {
+		partition-table-type = "gpt"
+	}
+
+	partition boot {
+		image = "efi-part.vfat"
+		partition-type-uuid = U
+		offset = 32K
+		bootable = true
+	}
+
+	partition root {
+		partition-type-uuid = root-loongarch64
+		image = "rootfs.ext"
+	}
+
+	partition cfgfs {
+    		partition-type-uuid = 0FC63DAF-8483-4772-8E79-3D69D8477DE4
+    		image = "cfgfs.img"
+  	}
+
+}

+ 1 - 0
target/loongarch/systems/qemu-loongarch

@@ -3,6 +3,7 @@ config ADK_TARGET_SYSTEM_QEMU_LOONGARCH
 	select ADK_TARGET_QEMU
 	select ADK_TARGET_CPU_LOONGARCH
 	select ADK_TARGET_KERNEL_VMLINUX_EFI
+	select ADK_TARGET_LINUX_KERNEL_IN_VFAT
 	help
 	  Support for Qemu Emulator Loongarch architecture.