Browse Source

Makefile: Fix issues to build and generate the large tf booting card

Signed-off-by: Andy Hu <andy.hu@starfivetech.com>
Andy Hu 1 year ago
parent
commit
69b3222344
2 changed files with 78 additions and 74 deletions
  1. 33 29
      Makefile
  2. 45 45
      conf/evb-fit-image.its

+ 33 - 29
Makefile

@@ -152,7 +152,6 @@ $(buildroot_rootfs_ext): $(buildroot_srcdir) $(buildroot_rootfs_wrkdir)/.config
 
 .PHONY: buildroot_rootfs
 buildroot_rootfs: $(buildroot_rootfs_ext)
-	cp $< $@
 
 .PHONY: buildroot_rootfs-menuconfig
 buildroot_rootfs-menuconfig: $(buildroot_rootfs_wrkdir)/.config $(buildroot_srcdir)
@@ -324,24 +323,28 @@ qemu-rootfs: $(qemu) $(sbi_bin) $(vmlinux) $(initramfs) $(rootfs)
 .PHONY: uboot
 uboot: $(uboot)
 
-# Relevant partition type codes
-SPL		= 2E54B353-1271-4842-806F-E436D6AF6985
-VFAT            = EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
-LINUX		= 0FC63DAF-8483-4772-8E79-3D69D8477DE4
-UBOOT		= 5B193300-FC78-40CD-8002-E86C45580B47
-UBOOTENV	= a09354ac-cd63-11e8-9aff-70b3d592f0fa
-UBOOTDTB	= 070dd1a8-cd64-11e8-aa3d-70b3d592f0fa
-UBOOTFIT	= 04ffcafa-cd65-11e8-b974-70b3d592f0fa
-
-SPL_START=2048
-SPL_END=6143
-UBOOT_START=6144
-UBOOT_END=16385
-UBOOT_SIZE=12288
-VFAT_START=16386
-VFAT_END=425985
-VFAT_SIZE=204800
-ROOT_START=425986
+# Relevant partition type codes with GUID
+SPL         = 2E54B353-1271-4842-806F-E436D6AF6985
+VFAT        = EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
+LINUX       = 0FC63DAF-8483-4772-8E79-3D69D8477DE4
+UBOOT       = 5B193300-FC78-40CD-8002-E86C45580B47
+UBOOTENV    = a09354ac-cd63-11e8-9aff-70b3d592f0fa
+UBOOTDTB    = 070dd1a8-cd64-11e8-aa3d-70b3d592f0fa
+UBOOTFIT    = 04ffcafa-cd65-11e8-b974-70b3d592f0fa
+
+# Note: The following are the sector number used to partition
+#   The default sector size is 512 Bytes
+#   The partition start should be align on 2048-sector boundaries
+# expand the vfat size to 300+M for the vpu/jpu or other debug
+SPL_START   = 2048
+SPL_END     = 6143
+UBOOT_START = 6144
+UBOOT_END   = 16383
+UBOOT_SIZE  = $(shell expr $(UBOOT_END) - $(UBOOT_START) + 1)
+VFAT_START  = 16384
+VFAT_END    = 614399
+VFAT_SIZE   = $(shell expr $(VFAT_END) - $(VFAT_START) + 1)
+ROOT_START  = 614400
 
 $(vfat_image): $(fit) $(confdir)/jh7110_uEnv.txt
 	@if [ `du --apparent-size --block-size=512 $(uboot) | cut -f 1` -ge $(UBOOT_SIZE) ]; then \
@@ -355,11 +358,11 @@ $(vfat_image): $(fit) $(confdir)/jh7110_uEnv.txt
 .PHONY: format-boot-loader
 format-boot-loader: $(sbi_bin) $(uboot) $(fit) $(vfat_image)
 	@test -b $(DISK) || (echo "$(DISK): is not a block device"; exit 1)
-	/sbin/sgdisk --clear  \
-		--new=1:$(SPL_START):$(SPL_END)  	--change-name=1:"spl"	--typecode=1:$(SPL)   \
-		--new=2:$(UBOOT_START):$(UBOOT_END)     --change-name=2:uboot	--typecode=2:$(UBOOT) \
-		--new=3:$(VFAT_START):$(VFAT_END)     --change-name=3:image	--typecode=2:$(VFAT) \
-		--new=4:$(ROOT_START):0 		--change-name=4:root	--typecode=4:$(LINUX) \
+	sudo /sbin/sgdisk --clear  \
+		--new=1:$(SPL_START):$(SPL_END)     --change-name=1:"spl"   --typecode=1:$(SPL)   \
+		--new=2:$(UBOOT_START):$(UBOOT_END) --change-name=2:"uboot" --typecode=2:$(UBOOT) \
+		--new=3:$(VFAT_START):$(VFAT_END)   --change-name=3:"image" --typecode=3:$(VFAT)  \
+		--new=4:$(ROOT_START):0             --change-name=4:"root"  --typecode=4:$(LINUX) \
 		$(DISK)
 	-/sbin/partprobe
 	@sleep 1
@@ -382,27 +385,28 @@ else
 	@echo Error: Could not find bootloader partition for $(DISK)
 	@exit 1
 endif
-	#dd if=$(spl_payload)   of=$(PART1) bs=4096
-	dd if=$(uboot_fit) of=$(PART2) bs=4096
-	dd if=$(vfat_image) of=$(PART3) bs=4096
+#	sudo dd if=$(spl_payload)   of=$(PART1) bs=4096
+	sudo dd if=$(uboot_fit)  of=$(PART2) bs=4096
+	sudo dd if=$(vfat_image) of=$(PART3) bs=4096
+	sync; sleep 1;
 
 #starfive image
 format-rootfs-image: format-boot-loader
 	@echo "Done setting up basic initramfs boot. We will now try to install"
 	@echo "a Debian snapshot to the Linux partition, which requires sudo"
 	@echo "you can safely cancel here"
-	/sbin/mke2fs -t ext4 $(PART4)
+	sudo /sbin/mke2fs -t ext4 $(PART4)
 	-mkdir -p tmp-mnt
 	-mkdir -p tmp-rootfs
 	-sudo mount $(PART4) tmp-mnt && \
 		sudo mount -o loop $(buildroot_rootfs_ext) tmp-rootfs&& \
 		sudo cp -fr tmp-rootfs/* tmp-mnt/
+	sync; sleep 1;
 	sudo umount tmp-mnt
 	sudo umount tmp-rootfs
 	rmdir tmp-mnt
 	rmdir tmp-rootfs
 
-
 #usb config
 format-usb-disk: $(sbi_bin) $(uboot) $(fit) $(vfat_image)
 	@test -b $(DISK) || (echo "$(DISK): is not a block device"; exit 1)

+ 45 - 45
conf/evb-fit-image.its

@@ -1,55 +1,55 @@
 /dts-v1/;
 
 / {
-        description = "U-boot FIT image for jh7110-evb";
-        #address-cells = <2>;
+	description = "U-boot FIT image for jh7110-evb";
+	#address-cells = <2>;
 
-        images {
-                vmlinux {
-                        description = "vmlinux";
-                        data = /incbin/("../work/linux/arch/riscv/boot/Image");
-                        type = "kernel";
-                        arch = "riscv";
-                        os = "linux";
-                        load = <0x0 0x40200000>;
-                        entry = <0x0 0x40200000>;
-                        compression = "none";
-                };
+	images {
+		vmlinux {
+			description = "vmlinux";
+			data = /incbin/("../work/linux/arch/riscv/boot/Image");
+			type = "kernel";
+			arch = "riscv";
+			os = "linux";
+			load = <0x0 0x40200000>;
+			entry = <0x0 0x40200000>;
+			compression = "none";
+		};
 
-                ramdisk {
-                        description = "buildroot initramfs";
-                        data = /incbin/("../work/initramfs.cpio.gz");
-                        type = "ramdisk";
-                        arch = "riscv";
-                        os = "linux";
-                        load = <0x0 0x46100000>;
-                        compression = "none";
-                        hash-1 {
-                                algo = "sha256";
-                        };
-                };
+		ramdisk {
+			description = "buildroot initramfs";
+			data = /incbin/("../work/initramfs.cpio.gz");
+			type = "ramdisk";
+			arch = "riscv";
+			os = "linux";
+			load = <0x0 0x46100000>;
+			compression = "none";
+			hash-1 {
+				algo = "sha256";
+			};
+		};
 
-                fdt {
-                        data = /incbin/("../work/linux/arch/riscv/boot/dts/starfive/jh7110-evb.dtb");
-                        type = "flat_dt";
-                        arch = "riscv";
-                        load = <0x0 0x46000000>;
-                        compression = "none";
-                        hash-1 {
-                                algo = "sha256";
-                        };
-                };
-        };
+		fdt {
+			data = /incbin/("../work/linux/arch/riscv/boot/dts/starfive/jh7110-evb.dtb");
+			type = "flat_dt";
+			arch = "riscv";
+			load = <0x0 0x46000000>;
+			compression = "none";
+			hash-1 {
+				algo = "sha256";
+			};
+		};
+	};
 
-        configurations {
-                default = "config-1";
+	configurations {
+		default = "config-1";
 
-                config-1 {
-                        description = "jh7110-evb with opensbi";
-						kernel = "vmlinux";
-                        fdt = "fdt";
-                        loadables = "ramdisk";
-                };
-        };
+		config-1 {
+			description = "jh7110-evb with opensbi";
+			kernel = "vmlinux";
+			fdt = "fdt";
+			loadables = "ramdisk";
+		};
+	};
 };