Browse Source

linux-starfive-dev: Fix do_compile[nostamp] issue

Previously do_compile[nostamp] is enabled due to kernel/dtb not recompiling
for different Dubhe image builds, which qspi-image has kernel bundled with
initramfs and others does not. Same goes to dtb, which will have different
bootargs depending on image (QSPI, EXT4, UBI, NFS). Currently, this will
be mitigated by:

	- Generating 4 different dtbs, each with different bootargs
	- Generating two different fw_payload.bin, one with Image and
	  another with Image+Initramfs bundled

Signed-off-by: Jun Yuan Tan <junyuan.tan@starfivetech.com>
Jun Yuan Tan 8 months ago
parent
commit
45f2288cb7

+ 7 - 3
conf/machine/starfive-dubhe.conf

@@ -29,7 +29,12 @@ require conf/machine/include/riscv/tune-riscv.inc
 
 MACHINE_FEATURES = "screen keyboard ext2 ext3 serial"
 
-KERNEL_DEVICETREE ?= "starfive/dubhe_fpga.dtb starfive/dubhe_fpga_dual.dtb "
+KERNEL_DEVICETREE ?= "starfive/dubhe_fpga.dtb \
+		starfive/dubhe_fpga_dual.dtb \
+		starfive/dubhe_fpga_ext4.dtb \
+		starfive/dubhe_fpga_ubi.dtb \ 
+		starfive/dubhe_fpga_nfs.dtb \
+"
 KERNEL_IMAGETYPE = "Image"
 
 KEEPUIMAGE = "no"
@@ -39,7 +44,7 @@ INITRAMFS_MAXSIZE = "524288"
 PREFERRED_PROVIDER_virtual/kernel ?= "linux-starfive-dev"
 PREFERRED_VERSION_linux-starfive-dev = "6.1.20+gitAUTOINC+0a9c9aa420"
 RISCV_SBI_PLAT = "generic"
-RISCV_SBI_PAYLOAD = "${@oe.utils.conditional('ENABLE_INIT','1','Image-initramfs-starfive-dubhe.bin','Image-starfive-dubhe.bin',d)}"
+RISCV_SBI_PAYLOAD = "Image-starfive-dubhe.bin"
 
 QEMU_EXTRAOPTIONS:riscv64 = " -cpu rv64,x-b=true,x-v=true"
 
@@ -70,5 +75,4 @@ WKS_FILE_DEPENDS ?= " \
 ###    ${RISCV_SBI_FDT}  \
 ###    boot.scr.uimg \
 ###"
-
 WKS_FILE ?= "starfive-dubhe.wks"

+ 7 - 0
recipes-bsp/opensbi/opensbi_%.bbappend

@@ -16,3 +16,10 @@ do_deploy:append:starfive-visionfive2() {
         cd ${DEPLOYDIR}
         mkimage -f visionfive2-uboot-fit-image.its -A riscv -O u-boot -T firmware visionfive2_fw_payload.img
 }
+
+do_deploy:append:starfive-dubhe(){
+	oe_runmake clean
+	oe_runmake PLATFORM=${RISCV_SBI_PLAT} I=${D} FW_PIC=n CLANG_TARGET= PLATFORM_DEFCONFIG=starfive_defconfig FW_PAYLOAD_PATH=${DEPLOY_DIR_IMAGE}/Image-initramfs-starfive-dubhe.bin
+	install -m 755 ${B}/build/platform/generic/firmware/fw_payload.bin ${DEPLOYDIR}/fw_payload_initramfs.bin
+	install -m 755 ${B}/build/platform/generic/firmware/fw_payload.elf ${DEPLOYDIR}/fw_payload_initramfs.elf
+}

+ 1 - 1
recipes-core/images/dubhe-image-minimal_0.1.bb

@@ -36,7 +36,7 @@ do_qspi[depends] += " virtual/kernel:do_deploy"
 do_qspi (){
 	dd if=${DEPLOY_DIR_IMAGE}/bootcode_min.bin of=${DEPLOY_DIR_IMAGE}/QSPI-EXT4-Image.bin bs=32 seek=0 count=128
         dd if=${DEPLOY_DIR_IMAGE}/bootjump.bin of=${DEPLOY_DIR_IMAGE}/QSPI-EXT4-Image.bin bs=32 seek=128 count=1
-        dd if=${DEPLOY_DIR_IMAGE}/dubhe_fpga.dtb of=${DEPLOY_DIR_IMAGE}/QSPI-EXT4-Image.bin bs=32 seek=129 count=255
+        dd if=${DEPLOY_DIR_IMAGE}/dubhe_fpga_ext4.dtb of=${DEPLOY_DIR_IMAGE}/QSPI-EXT4-Image.bin bs=32 seek=129 count=255
         dd if=${DEPLOY_DIR_IMAGE}/fw_payload.bin of=${DEPLOY_DIR_IMAGE}/QSPI-EXT4-Image.bin bs=32 seek=384
 }
 

+ 1 - 1
recipes-core/images/qspi-image_0.1.bb

@@ -19,5 +19,5 @@ IMAGE_CMD:qspi () {
 	dd if=${DEPLOY_DIR_IMAGE}/bootcode.bin of=${DEPLOY_DIR_IMAGE}/QSPI-Image.bin bs=32 seek=0 count=128
 	dd if=${DEPLOY_DIR_IMAGE}/bootjump.bin of=${DEPLOY_DIR_IMAGE}/QSPI-Image.bin bs=32 seek=128 count=1
 	dd if=${DEPLOY_DIR_IMAGE}/dubhe_fpga.dtb of=${DEPLOY_DIR_IMAGE}/QSPI-Image.bin bs=32 seek=129 count=255
-	dd if=${DEPLOY_DIR_IMAGE}/fw_payload.bin of=${DEPLOY_DIR_IMAGE}/QSPI-Image.bin bs=32 seek=384
+	dd if=${DEPLOY_DIR_IMAGE}/fw_payload_initramfs.bin of=${DEPLOY_DIR_IMAGE}/QSPI-Image.bin bs=32 seek=384
 }

+ 1 - 1
recipes-core/images/qspi-nfs-image_0.1.bb

@@ -36,7 +36,7 @@ do_qspi[depends] += " virtual/kernel:do_deploy"
 do_qspi (){
 	dd if=${DEPLOY_DIR_IMAGE}/bootcode_min.bin of=${DEPLOY_DIR_IMAGE}/QSPI-NFS-Image.bin bs=32 seek=0 count=128
         dd if=${DEPLOY_DIR_IMAGE}/bootjump.bin of=${DEPLOY_DIR_IMAGE}/QSPI-NFS-Image.bin bs=32 seek=128 count=1
-        dd if=${DEPLOY_DIR_IMAGE}/dubhe_fpga.dtb of=${DEPLOY_DIR_IMAGE}/QSPI-NFS-Image.bin bs=32 seek=129 count=255
+        dd if=${DEPLOY_DIR_IMAGE}/dubhe_fpga_nfs.dtb of=${DEPLOY_DIR_IMAGE}/QSPI-NFS-Image.bin bs=32 seek=129 count=255
         dd if=${DEPLOY_DIR_IMAGE}/fw_payload.bin of=${DEPLOY_DIR_IMAGE}/QSPI-NFS-Image.bin bs=32 seek=384
 }
 

+ 1 - 1
recipes-core/images/qspi-ubifs-image_0.1.bb

@@ -29,7 +29,7 @@ do_qspi[depends] += " virtual/kernel:do_deploy"
 do_qspi () {
         dd if=${DEPLOY_DIR_IMAGE}/bootcode.bin of=${DEPLOY_DIR_IMAGE}/QSPI-Ubifs-Image.bin bs=32 seek=0 count=128
         dd if=${DEPLOY_DIR_IMAGE}/bootjump.bin of=${DEPLOY_DIR_IMAGE}/QSPI-Ubifs-Image.bin bs=32 seek=128 count=1
-        dd if=${DEPLOY_DIR_IMAGE}/dubhe_fpga.dtb of=${DEPLOY_DIR_IMAGE}/QSPI-Ubifs-Image.bin bs=32 seek=129 count=255
+        dd if=${DEPLOY_DIR_IMAGE}/dubhe_fpga_ubi.dtb of=${DEPLOY_DIR_IMAGE}/QSPI-Ubifs-Image.bin bs=32 seek=129 count=255
         dd if=${DEPLOY_DIR_IMAGE}/fw_payload.bin of=${DEPLOY_DIR_IMAGE}/QSPI-Ubifs-Image.bin bs=32 seek=384 count=1048192
 	dd if=${IMGDEPLOYDIR}/qspi-ubifs-starfive-dubhe.ubi of=${DEPLOY_DIR_IMAGE}/QSPI-Ubifs-Image.bin bs=64KiB seek=512
 }

+ 9 - 0
recipes-kernel/linux/files/add-dubhe-additional-dtb.patch

@@ -0,0 +1,9 @@
+diff --git a/arch/riscv/boot/dts/starfive/Makefile b/arch/riscv/boot/dts/starfive/Makefile
+index 7179c511f2fa..2807b20c2d73 100644
+--- a/arch/riscv/boot/dts/starfive/Makefile
++++ b/arch/riscv/boot/dts/starfive/Makefile
+@@ -1,3 +1,4 @@
+ # SPDX-License-Identifier: GPL-2.0
+ dtb-$(CONFIG_SOC_STARFIVE) += jh7100-beaglev-starlight-a1.dtb jh7100-beaglev-starlight.dtb jh7100-starfive-visionfive-v1.dtb
+ dtb-$(CONFIG_SOC_STARFIVE_DUBHE) += dubhe_fpga.dtb dubhe_fpga_dual.dtb
++dtb-$(CONFIG_SOC_STARFIVE_DUBHE) += dubhe_fpga_ext4.dtb dubhe_fpga_ubi.dtb dubhe_fpga_nfs.dtb

+ 15 - 6
recipes-kernel/linux/linux-starfive-dev_6.1.20.bb

@@ -27,15 +27,13 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
 SRC_URI:starfive-dubhe = " \
         git://git@192.168.110.45/${FORK}/linux.git;protocol=ssh;branch=${BRANCH} \
         file://cpio.cfg \
-        ${@oe.utils.conditional('ENABLE_EXT4','1','file://ext4.patch','',d)} \
-        ${@oe.utils.conditional('ENABLE_UBI','1','file://ubi.patch','',d)} \
-        ${@oe.utils.conditional('ENABLE_NFS','1','file://nfs.patch','',d)} \
+	file://add-dubhe-additional-dtb.patch \
         "
 SRC_URI:starfive-jh8100 = "git://git@192.168.110.45/${FORK}/linux.git;protocol=ssh;branch=${BRANCH}"
 
 
-INITRAMFS_IMAGE_BUNDLE:starfive-dubhe = "${@oe.utils.conditional('ENABLE_INIT','1','1','',d)}"
-INITRAMFS_IMAGE:starfive-dubhe = "${@oe.utils.conditional('ENABLE_INIT','1','dubhe-image-initramfs','',d)}"
+INITRAMFS_IMAGE_BUNDLE:starfive-dubhe = "1"
+INITRAMFS_IMAGE:starfive-dubhe = "dubhe-image-initramfs"
 
 KBUILD_DEFCONFIG:starfive-dubhe = "starfive_dubhe_defconfig"
 KBUILD_DEFCONFIG:starfive-jh8100 = "jh8100_defconfig"
@@ -44,4 +42,15 @@ COMPATIBLE_MACHINE = "(starfive-dubhe|starfive-jh8100)"
 
 FILES:${KERNEL_PACKAGE_NAME}-base += "/usr/*"
 
-do_compile[nostamp] = "1"
+BOOTARGS_EXT4 = "console=ttySIF0,115200 earlycon=sbi root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait ip=:::255.255.255.0::eth0:dhcp"
+BOOTARGS_UBI = "console=ttySIF0,115200 earlycon=sbi ip=:::255.255.255.0::eth0:dhcp root=ubi0:starfive-dubhe-rootfs ubi.mtd=1 rw rootfstype=ubifs rootwait"
+BOOTARGS_NFS = "console=ttySIF0,115200 earlycon=sbi root=/dev/nfs rw nfsroot=192.168.1.1:/filepath,rw,tcp,vers=3 ip=:::255.255.255.0::eth0:dhcp rootfstype=ext4 rootwait"
+
+do_configure:append:starfive-dubhe() {
+	cp ${S}/arch/riscv/boot/dts/starfive/dubhe_fpga.dts ${S}/arch/riscv/boot/dts/starfive/dubhe_fpga_ext4.dts
+	cp ${S}/arch/riscv/boot/dts/starfive/dubhe_fpga.dts ${S}/arch/riscv/boot/dts/starfive/dubhe_fpga_ubi.dts
+	cp ${S}/arch/riscv/boot/dts/starfive/dubhe_fpga.dts ${S}/arch/riscv/boot/dts/starfive/dubhe_fpga_nfs.dts
+	sed -i "s+bootargs.*+bootargs = \"${BOOTARGS_EXT4}\";+g" ${S}/arch/riscv/boot/dts/starfive/dubhe_fpga_ext4.dts
+	sed -i "s+bootargs.*+bootargs = \"${BOOTARGS_UBI}\";+g" ${S}/arch/riscv/boot/dts/starfive/dubhe_fpga_ubi.dts
+	sed -i "s+bootargs.*+bootargs = \"${BOOTARGS_NFS}\";+g" ${S}/arch/riscv/boot/dts/starfive/dubhe_fpga_nfs.dts
+}