From 320e16528ea6a9eba54bac0161e2331093075647 Mon Sep 17 00:00:00 2001
From: Waldemar Brodkorb <wbx@openadk.org>
Date: Sat, 28 Dec 2013 17:30:22 +0100
Subject: convert microblaze to miniconfig kernel config generation, add
 support for squashfs and jffs2 rootfs for qemu-microblaze, add support for
 both machine emulations

---
 target/microblaze/Makefile | 38 +++++++++++++++++++++++++++++---------
 1 file changed, 29 insertions(+), 9 deletions(-)

(limited to 'target/microblaze/Makefile')

diff --git a/target/microblaze/Makefile b/target/microblaze/Makefile
index 3ff728627..e4c98ed6d 100644
--- a/target/microblaze/Makefile
+++ b/target/microblaze/Makefile
@@ -9,16 +9,36 @@ include $(TOPDIR)/mk/image.mk
 
 KERNEL:=$(LINUX_DIR)/arch/microblaze/boot/$(ADK_TARGET_KERNEL)
 
-ifeq ($(ADK_TARGET_FS),archive)
-imageinstall: $(BIN_DIR)/$(ROOTFSTARBALL)
-	@echo "The RootFS tarball is: $(BIN_DIR)/$(ROOTFSTARBALL)"
+tools-compile:
+	$(MAKE) -C ../tools/mtd-utils all
+	$(MAKE) -C ../tools/xz all
+	$(MAKE) -C ../tools/squashfs all
+
+ifeq ($(ADK_TARGET_QEMU_MICROBLAZE_MODEL_ML605),y)
+MODEL:=petalogix-ml605
+DTB:=-dtb target/microblaze/ml605.dtb
+endif
+ifeq ($(ADK_TARGET_QEMU_MICROBLAZE_MODEL_S3ADSP1800),y)
+MODEL:=petalogix-s3adsp1800
+DTB:=
+endif
+
+ifeq ($(ADK_TARGET_FS),squashfs)
+imageinstall: tools-compile $(BUILD_DIR)/root.squashfs
+	qemu-img create -f raw $(BIN_DIR)/$(ROOTFSSQUASHFS) $(ADK_TARGET_MTD_SIZE)
+	dd conv=notrunc if=$(BUILD_DIR)/root.squashfs of=$(BIN_DIR)/$(ROOTFSSQUASHFS)
+	@cp $(KERNEL) $(BIN_DIR)/$(TARGET_KERNEL)
 ifneq ($(ADK_HARDWARE_QEMU),)
+	@echo "Start qemu with following options:"
+	@echo 'qemu-system-${CPU_ARCH} $(DTB) -M $(MODEL) -nographic -kernel $(BIN_DIR)/$(TARGET_KERNEL) -pflash $(BIN_DIR)/$(ROOTFSSQUASHFS)'
+endif
+endif
+ifeq ($(ADK_TARGET_FS),jffs2)
+imageinstall: tools-compile $(BIN_DIR)/$(ROOTFSJFFS2)
 	@cp $(KERNEL) $(BIN_DIR)/$(TARGET_KERNEL)
-	@echo 'The kernel file is: $(BIN_DIR)/${TARGET_KERNEL}'
-	@echo "Use following command to create a QEMU Image:"
-	@echo "./scripts/create.sh +g qemu-${CPU_ARCH}.img $(BIN_DIR)/$(ROOTFSTARBALL)"
+ifneq ($(ADK_HARDWARE_QEMU),)
 	@echo "Start qemu with following options:"
-	@echo 'qemu-system-${CPU_ARCH} -nographic -kernel $(BIN_DIR)/$(TARGET_KERNEL) qemu-${CPU_ARCH}.img'
+	@echo 'qemu-system-${CPU_ARCH} $(DTB) -M $(MODEL) -nographic -kernel $(BIN_DIR)/$(TARGET_KERNEL) -pflash $(BIN_DIR)/$(ROOTFSJFFS2)'
 endif
 endif
 ifeq ($(ADK_TARGET_FS),initramfs)
@@ -28,7 +48,7 @@ imageinstall: $(BIN_DIR)/$(INITRAMFS)
 	@echo 'The initramfs image is: ${BIN_DIR}/${INITRAMFS}'
 ifneq ($(ADK_HARDWARE_QEMU),)
 	@echo "Start qemu with following command line:"
-	@echo 'qemu-system-${CPU_ARCH} -nographic -kernel $(BIN_DIR)/$(TARGET_KERNEL) -initrd ${BIN_DIR}/${INITRAMFS}'
+	@echo 'qemu-system-${CPU_ARCH} $(DTB) -M $(MODEL) -nographic -kernel $(BIN_DIR)/$(TARGET_KERNEL) -initrd ${BIN_DIR}/${INITRAMFS}'
 endif
 endif
 ifeq ($(ADK_TARGET_FS),initramfs-piggyback)
@@ -37,6 +57,6 @@ imageinstall: createinitramfs
 	@echo 'The kernel+initramfs file is: $(BIN_DIR)/${TARGET_KERNEL}'
 ifneq ($(ADK_HARDWARE_QEMU),)
 	@echo "Start qemu with following command line:"
-	@echo 'qemu-system-${CPU_ARCH} -nographic -kernel $(BIN_DIR)/$(TARGET_KERNEL)'
+	@echo 'qemu-system-${CPU_ARCH} $(DTB) -M $(MODEL) -nographic -kernel $(BIN_DIR)/$(TARGET_KERNEL)'
 endif
 endif
-- 
cgit v1.2.3