Browse Source

visionfive2: u-boot: Added u-boot recipes and uEnv files

Added u-boot recipes to generate u-boot-spl.bin.normal.out and include uEnv files to support different boot mode.

Signed-off-by: yang.lee <yang.lee@starfivetech.com>
yang.lee 1 year ago
parent
commit
eeb3800a50

+ 44 - 0
recipes-bsp/u-boot/files/tftp-mmc-boot.txt

@@ -0,0 +1,44 @@
+# This is the default TFTP and MMC u-boot boot script
+# The order is as follows:
+#  1. TFTP load a uEnv.txt
+#  2. TFTP boot a fitImage
+#  3. MMC load a uEnv.txt
+#  4. MMC load a fitImage
+#  5. TFTP load a uImage
+#  6. MMC load a fitImage
+
+# Setup the DHCP for a TFTP boot
+setenv serverip @SERVERIP@
+dhcp
+
+# See if we have a TFTP uEnv.txt file
+if tftpboot ${scriptaddr} uEnv.txt; then
+    env import -t ${scriptaddr} ${filesize}
+    run bootcmd
+fi;
+
+# Try to boot a fitImage from the TFTP server
+if tftpboot ${ramdisk_addr_r} fitImage; then
+  bootm ${ramdisk_addr_r}
+fi;
+
+# See if we have a MMC uEnv.txt file
+if fatload ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} /uEnv.txt; then
+    env import -t ${scriptaddr} ${filesize}
+    run bootcmd
+fi;
+
+# Try to boot a fitImage from the MMC
+if load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} fitImage; then
+  bootm ${ramdisk_addr_r}
+fi;
+
+# Fallback to a TFTP uImage
+if tftpboot ${kernel_addr_r} uImage; then
+  bootm ${kernel_addr_r} - ${fdt_addr_r}
+fi;
+
+# Finally fallback to a MMC uImage
+if load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} uImage; then
+  bootm ${kernel_addr_r} - ${fdt_addr_r}
+fi;

+ 32 - 0
recipes-bsp/u-boot/files/vf2_nvme_uEnv.txt

@@ -0,0 +1,32 @@
+# This is the sample jh7110_uEnv.txt file for starfive visionfive U-boot
+# The current convention (SUBJECT TO CHANGE) is that this file
+# will be loaded from the third partition on the
+# NVME ssd.
+#devnvm=0
+partnum=3
+
+# The FIT file to boot from
+fitfile=starfiveu.fit
+
+# for debugging boot
+bootargs_ext=if test ${devnvme} = 0; then setenv bootargs "earlyprintk console=tty1 console=ttyS0,115200 debug rootwait earlycon=sbi root=/dev/nvme0n1p4"; else setenv bootargs "earlyprintk console=tty1 console=ttyS0,115200 debug rootwait earlycon=sbi root=/dev/nvme1n1p4"; fi;
+#bootargs=earlyprintk console=ttyS0,115200 debug rootwait earlycon=sbi root=/dev/nvme0n1p4
+
+# for addr info
+fileaddr=0xa0000000
+fdtaddr=0x46000000
+# boot Linux flat or compressed 'Image' stored at 'kernel_addr_r'
+kernel_addr_r=0x40200000
+irdaddr=46100000
+irdsize=5f00000
+
+# Use the FDT in the FIT image..
+setupfdt1=fdt addr ${fdtaddr}; fdt resize;
+
+setupird=setexpr irdend ${irdaddr} + ${irdsize}; fdt set /chosen linux,initrd-start <0x0 0x${irdaddr}>; fdt set /chosen linux,initrd-end <0x0 0x${irdend}>
+
+setupfdt2=fdt set /chosen bootargs "${bootargs}";
+
+bootwait=setenv _delay ${bootdelay}; echo ${_delay}; while test ${_delay} > 0; do sleep 1; setexpr _delay ${_delay} - 1; echo ${_delay}; done
+
+boot2=run bootargs_ext; nvme dev ${devnvme}; fatload nvme ${devnvme}:${partnum} ${fileaddr} ${fitfile}; bootm start ${fileaddr}; run setupfdt1;run setupird;run setupfdt2; bootm loados ${fileaddr}; run chipa_set_linux; run cpu_vol_set; echo "Booting kernel in"; booti ${kernel_addr_r} ${irdaddr}:${filesize} ${fdtaddr}

+ 32 - 0
recipes-bsp/u-boot/files/vf2_uEnv.txt

@@ -0,0 +1,32 @@
+# This is the sample jh7110_uEnv.txt file for starfive visionfive U-boot
+# The current convention (SUBJECT TO CHANGE) is that this file
+# will be loaded from the third partition on the
+# MMC card.
+#devnum=1
+partnum=3
+
+# The FIT file to boot from
+fitfile=starfiveu.fit
+
+# for debugging boot
+bootargs_ext=if test ${devnum} = 0; then setenv bootargs "earlyprintk console=tty1 console=ttyS0,115200 debug rootwait earlycon=sbi root=/dev/mmcblk0p4"; else setenv bootargs "earlyprintk console=tty1 console=ttyS0,115200 debug rootwait earlycon=sbi root=/dev/mmcblk1p4"; fi;
+#bootargs=earlyprintk console=ttyS0,115200 debug rootwait earlycon=sbi root=/dev/mmcblk1p4
+
+# for addr info
+fileaddr=0xa0000000
+fdtaddr=0x46000000
+# boot Linux flat or compressed 'Image' stored at 'kernel_addr_r'
+kernel_addr_r=0x40200000
+irdaddr=46100000
+irdsize=5f00000
+
+# Use the FDT in the FIT image..
+setupfdt1=fdt addr ${fdtaddr}; fdt resize;
+
+setupird=setexpr irdend ${irdaddr} + ${irdsize}; fdt set /chosen linux,initrd-start <0x0 0x${irdaddr}>; fdt set /chosen linux,initrd-end <0x0 0x${irdend}>
+
+setupfdt2=fdt set /chosen bootargs "${bootargs}";
+
+bootwait=setenv _delay ${bootdelay}; echo ${_delay}; while test ${_delay} > 0; do sleep 1; setexpr _delay ${_delay} - 1; echo ${_delay}; done
+
+boot2=run bootargs_ext; mmc dev ${devnum}; fatload mmc ${devnum}:${partnum} ${fileaddr} ${fitfile}; bootm start ${fileaddr}; run setupfdt1;run setupird;run setupfdt2; bootm loados ${fileaddr}; run chipa_set_linux; run cpu_vol_set; echo "Booting kernel in"; booti ${kernel_addr_r} ${irdaddr}:${filesize} ${fdtaddr}

+ 61 - 0
recipes-bsp/u-boot/files/visionfive2-fit-image.its

@@ -0,0 +1,61 @@
+/dts-v1/;
+
+/ {
+        description = "Kernel fitImage for visionfive2";
+        #address-cells = <1>;
+
+        images {
+                kernel-1 {
+                        description = "Linux kernel";
+                        data = /incbin/("./tmp/fitImage-linux.bin-starfive-visionfive2");
+                        type = "kernel";
+                        arch = "riscv";
+                        os = "linux";
+                        compression = "none";
+                        load = <0x40200000>;
+                        entry = <0x40200000>;
+                        hash-1 {
+                                algo = "sha256";
+                        };
+                };
+                fdt-starfive_jh7110-visionfive-v2.dtb {
+                        description = "Flattened Device Tree blob";
+                        data = /incbin/("./tmp/jh7110-visionfive-v2-starfive-visionfive2.dtb");
+                        type = "flat_dt";
+                        arch = "riscv";
+                        compression = "none";
+                        load = <0x46000000>;
+                        hash-1 {
+                                algo = "sha256";
+                        };
+                };
+                ramdisk-1 {
+                        description = "core-image-minimal-initramfs";
+                        data = /incbin/("initramfs.img");
+                        type = "ramdisk";
+                        arch = "riscv";
+                        os = "linux";
+                        compression = "none";
+                        load = <0x46100000>;
+                        entry = <0x46100000>;
+                        hash-1 {
+                                algo = "sha256";
+                        };
+                };
+        };
+
+        configurations {
+                default = "conf-starfive_jh7110-visionfive-v2.dtb";
+                conf-starfive_jh7110-visionfive-v2.dtb {
+                        description = "1 Linux kernel, FDT blob, ramdisk";
+                        kernel = "kernel-1";
+                        fdt = "fdt-starfive_jh7110-visionfive-v2.dtb";
+                        ramdisk = "ramdisk-1";
+
+
+                        hash-1 {
+                                algo = "sha256";
+                        };
+                };
+        };
+};

+ 42 - 0
recipes-bsp/u-boot/u-boot-starfive.bb

@@ -0,0 +1,42 @@
+require recipes-bsp/u-boot/u-boot-common.inc
+require recipes-bsp/u-boot/u-boot.inc
+
+inherit uboot-extlinux-config
+
+FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
+
+FORK = "sbc"
+BRANCH = "vf2-devel"
+
+SRC_URI = "git://git@192.168.110.45/${FORK}/u-boot.git;protocol=ssh;branch=${BRANCH} \
+           file://vf2_uEnv.txt \
+	   file://vf2_nvme_uEnv.txt \
+	   file://tftp-mmc-boot.txt \
+	   file://visionfive2-fit-image.its \
+          "
+SRCREV = "77781526125544acc873b51959f19bbdb50a4f2e"
+
+DEPENDS:append = " u-boot-tools-native starfive-tool-native"
+
+# Overwrite this for your server
+TFTP_SERVER_IP ?= "127.0.0.1"
+
+do_configure:prepend() {
+    sed -i -e 's,@SERVERIP@,${TFTP_SERVER_IP},g' ${WORKDIR}/tftp-mmc-boot.txt
+    mkimage -O linux -T script -C none -n "U-Boot boot script" \
+        -d ${WORKDIR}/tftp-mmc-boot.txt ${WORKDIR}/${UBOOT_ENV_BINARY}
+}
+
+do_deploy:append:starfive-visionfive2() {
+    install -m 644 ${WORKDIR}/vf2_nvme_uEnv.txt ${DEPLOYDIR}/vf2_nvme_uEnv.txt
+    install -m 644 ${WORKDIR}/vf2_uEnv.txt ${DEPLOYDIR}/vf2_uEnv.txt
+    install -m 644 ${WORKDIR}/visionfive2-fit-image.its ${DEPLOYDIR}/visionfive2-fit-image.its
+    spl_tool -c -f ${DEPLOYDIR}/${SPL_IMAGE}
+    ln -sf ${SPL_IMAGE}.normal.out ${DEPLOYDIR}/${SPL_BINARYNAME}.normal.out
+    ln -sf ${SPL_IMAGE}.normal.out ${DEPLOYDIR}/${SPL_SYMLINK}.normal.out
+}
+
+TOOLCHAIN = "gcc"
+
+COMPATIBLE_MACHINE = "(starfive-visionfive2)"
+