From d16bc5a3f240a1ca3d71900eaa0670686ac41de7 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sun, 3 Jul 2022 23:26:01 +0100 Subject: [PATCH] visionfive: Add initial support for Starfive Visionfive board This is largely based on the beaglev code nbut tweaked to work with current starfive kernel repositories and tweak to the board. The kernel and rootfs boot with working network and graphics. The u-boot binary builds but is as yet untested. Signed-off-by: Richard Purdie --- conf/machine/visionfive.conf | 61 +++++++++++++++++++ .../u-boot-starfive/fix-riscv-isa.patch | 19 ++++++ .../u-boot-starfive/uEnv-visionfive.txt | 11 ++++ .../u-boot/u-boot-starfive_v2021.04.bb | 24 ++++++-- recipes-kernel/linux/linux-starfive-dev.bb | 11 ++-- recipes-kernel/linux/linux-starfive/extra.cfg | 2 + 6 files changed, 120 insertions(+), 8 deletions(-) create mode 100644 conf/machine/visionfive.conf create mode 100644 recipes-bsp/u-boot/u-boot-starfive/fix-riscv-isa.patch create mode 100644 recipes-bsp/u-boot/u-boot-starfive/uEnv-visionfive.txt diff --git a/conf/machine/visionfive.conf b/conf/machine/visionfive.conf new file mode 100644 index 0000000..a9fdd86 --- /dev/null +++ b/conf/machine/visionfive.conf @@ -0,0 +1,61 @@ +#@TYPE: Machine +#@NAME: visionfive +#@SOC: StarFive JH7100 +#@DESCRIPTION: Machine configuration for the VisionFive board + +require conf/machine/include/riscv/tune-riscv.inc + +MACHINE_FEATURES = "screen keyboard ext2 ext3 serial" + +KERNEL_CLASSES = "kernel-fitimage" +KERNEL_IMAGETYPE = "fitImage" +UBOOT_ENV ?= "boot" +UBOOT_ENV_SUFFIX = "scr.uimg" +PREFERRED_PROVIDER_virtual/kernel ?= "linux-starfive-dev" +PREFERRED_PROVIDER_virtual/bootloader ?= "u-boot-starfive" + +PREFERRED_VERSION_openocd-native = "riscv" +PREFERRED_VERSION_openocd = "riscv" + +EXTRA_IMAGEDEPENDS += "opensbi" +RISCV_SBI_PLAT = "generic" + +## This sets u-boot as the default OpenSBI payload +RISCV_SBI_PAYLOAD ?= "u-boot.bin" + +RISCV_SBI_FDT ?= "jh7100-visionfive.dtb" + +SERIAL_CONSOLES = "115200;ttyS0" + +MACHINE_EXTRA_RRECOMMENDS += " kernel-modules linux-firmware-beaglev-bcm43430" + +IMAGE_FSTYPES += "wic.gz wic.bmap ext4" +KERNEL_DEVICETREE ?= "starfive/jh7100-starfive-visionfive-v1.dtb" + +## Do not update fstab file when using wic images +WIC_CREATE_EXTRA_ARGS ?= "--no-fstab-update" + +EXTRA_IMAGEDEPENDS += "u-boot-starfive" +UBOOT_MACHINE = "starfive_jh7100_visionfive_smode_defconfig" + +UBOOT_ENTRYPOINT = "0x80200000" +UBOOT_DTB_LOADADDRESS = "0x82200000" +UBOOT_DTB = "1" +UBOOT_DTB_BINARY = "jh7100-visionfive.dtb" + +## wic default support +WKS_FILE_DEPENDS ?= " \ + opensbi \ + e2fsprogs-native \ + bmap-tools-native \ +" + +IMAGE_BOOT_FILES ?= " \ + fw_payload.bin \ + ${KERNEL_IMAGETYPE} \ + ${RISCV_SBI_FDT} \ + boot.scr.uimg \ + uEnv.txt \ +" + +WKS_FILE ?= "beaglev.wks" diff --git a/recipes-bsp/u-boot/u-boot-starfive/fix-riscv-isa.patch b/recipes-bsp/u-boot/u-boot-starfive/fix-riscv-isa.patch new file mode 100644 index 0000000..f8f64f6 --- /dev/null +++ b/recipes-bsp/u-boot/u-boot-starfive/fix-riscv-isa.patch @@ -0,0 +1,19 @@ +u-boot for visionfive won't build with recent versions of the toolchain +and ISA without using this specific architecture flag. + +Upstream-Status: Pending +Signed-off-by: Richard Purdie + +Index: riscv/Makefile +=================================================================== +--- riscv.orig/arch/riscv/Makefile ++++ riscv/arch/riscv/Makefile +@@ -15,7 +15,7 @@ ifeq ($(CONFIG_RISCV_ISA_A),y) + ARCH_A = a + endif + ifeq ($(CONFIG_RISCV_ISA_C),y) +- ARCH_C = c ++ ARCH_C = c_zicsr_zifencei + endif + ifeq ($(CONFIG_CMODEL_MEDLOW),y) + CMODEL = medlow diff --git a/recipes-bsp/u-boot/u-boot-starfive/uEnv-visionfive.txt b/recipes-bsp/u-boot/u-boot-starfive/uEnv-visionfive.txt new file mode 100644 index 0000000..e5c325e --- /dev/null +++ b/recipes-bsp/u-boot/u-boot-starfive/uEnv-visionfive.txt @@ -0,0 +1,11 @@ +fdt_high=0xffffffffffffffff +initrd_high=0xffffffffffffffff +scriptaddr=0x88100000 +script_offset_f=0x1fff000 +script_size_f=0x1000 +kernel_addr_r=0x84000000 +kernel_comp_addr_r=0x90000000 +kernel_cx_addr_r=0x88000000 +ramdisk_addr_r=0x88300000 +load mmc 0:1 0xa0000000 fitImage +bootm 0xa0000000 diff --git a/recipes-bsp/u-boot/u-boot-starfive_v2021.04.bb b/recipes-bsp/u-boot/u-boot-starfive_v2021.04.bb index 557390b..0587d5f 100644 --- a/recipes-bsp/u-boot/u-boot-starfive_v2021.04.bb +++ b/recipes-bsp/u-boot/u-boot-starfive_v2021.04.bb @@ -3,13 +3,25 @@ require recipes-bsp/u-boot/u-boot.inc FILESEXTRAPATHS:prepend := "${THISDIR}/files:" -SRC_URI = "git://github.com/starfive-tech/u-boot.git;protocol=https;branch=Fedora_VIC_7100_2021.04 \ +BRANCH:visionfive = "JH7100_VisionFive_OH_dev" +BRANCH:beaglev-starlight-jh7100 = "Fedora_VIC_7100_2021.04" + +SRC_URI = "git://github.com/starfive-tech/u-boot.git;protocol=https;branch=${BRANCH} \ file://tftp-mmc-boot.txt \ - file://977abc529f98c1c90a80ad280fe9e58ddd43c87a.patch \ - file://2feaab2bd04ed736c637518b3b553615f0c97890.patch \ " +SRC_URI:append:beaglev-starlight-jh7100 = " \ + file://977abc529f98c1c90a80ad280fe9e58ddd43c87a.patch \ + file://2feaab2bd04ed736c637518b3b553615f0c97890.patch \ + " + +SRC_URI:append:visionfive = " \ + file://fix-riscv-isa.patch \ + file://uEnv-visionfive.txt \ +" + SRCREV = "7b70e1d44ba9702a519ca936cabf19070309123a" +SRCREV:visionfive = "ccecef294d355e9d05edf0bb6058002a0fe08908" DEPENDS:append = " u-boot-tools-native" @@ -22,6 +34,10 @@ do_configure:prepend() { -d ${WORKDIR}/tftp-mmc-boot.txt ${WORKDIR}/${UBOOT_ENV_BINARY} } -COMPATIBLE_MACHINE = "(beaglev-starlight-jh7100)" +do_deploy:append:visionfive() { + install -m 644 ${WORKDIR}/uEnv-visionfive.txt ${DEPLOYDIR}/uEnv.txt +} + +COMPATIBLE_MACHINE = "(beaglev-starlight-jh7100|visionfive)" TOOLCHAIN = "gcc" diff --git a/recipes-kernel/linux/linux-starfive-dev.bb b/recipes-kernel/linux/linux-starfive-dev.bb index 4a733b9..ce1d4c7 100644 --- a/recipes-kernel/linux/linux-starfive-dev.bb +++ b/recipes-kernel/linux/linux-starfive-dev.bb @@ -6,17 +6,20 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46" KERNEL_VERSION_SANITY_SKIP = "1" SRCREV = "${AUTOREV}" +SRCREV:visionfive = "f754a58449f0de76312bf84249139f5d8b232c66" +BRANCH:visionfive = "esmil_starlight" +BRANCH:beaglev-starlight-jh7100 = "beaglev_fedora_devel" FORK ?= "starfive-tech" -BRANCH ?= "esmil_starlight" SRC_URI = "git://github.com/${FORK}/linux.git;protocol=https;branch=${BRANCH} \ file://0001-riscv-Use-mno-relax-when-using-lld-linker.patch \ file://extra.cfg \ file://modules.cfg \ " -LINUX_VERSION ?= "5.14.0" -LINUX_VERSION_EXTENSION:append = "-starlight" +LINUX_VERSION ?= "5.19.0-rc4" +LINUX_VERSION_EXTENSION:append:beaglev-starlight-jh7100 = "-starlight" KBUILD_DEFCONFIG:beaglev-starlight-jh7100 = "beaglev_defconfig" +KBUILD_DEFCONFIG:visionfive = "visionfive_defconfig" -COMPATIBLE_MACHINE = "(beaglev-starlight-jh7100)" +COMPATIBLE_MACHINE = "(beaglev-starlight-jh7100|visionfive)" diff --git a/recipes-kernel/linux/linux-starfive/extra.cfg b/recipes-kernel/linux/linux-starfive/extra.cfg index 4b598a2..702d6c0 100644 --- a/recipes-kernel/linux/linux-starfive/extra.cfg +++ b/recipes-kernel/linux/linux-starfive/extra.cfg @@ -15,3 +15,5 @@ CONFIG_SOC_STARFIVE_VIC7100=y # restart CONFIG_MFD_TPS65086=y CONFIG_POWER_RESET_TPS65086=y + +CONFIG_HW_RANDOM_STARFIVE_VIC=y