Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide support for VisionFive2 #382

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e39d29d
visionfive2: add initial u-boot support
cordlandwehr Jan 7, 2023
05383c9
visionfive2: add initial kernel support
cordlandwehr Jan 7, 2023
dbca4f9
visionfive2: add machine config
cordlandwehr Jan 7, 2023
4052439
mesa-pvr: initial fork of mesa.inc with patches
cordlandwehr Jan 9, 2023
6cae138
mesa-pvr: add patches from visionfive2 buildroot
cordlandwehr Jan 9, 2023
2602dac
mesa-pvr: Force VisionFive2 specific config for mesa-pvr fork
cordlandwehr Jan 14, 2023
4aca186
visionfive2-pvr-graphics: provide closed source PVR driver
cordlandwehr Jan 9, 2023
e0e6136
xorg-xserver: configure X11 for usage on visionfive2
cordlandwehr Jan 14, 2023
531e802
visionfive2.conf: configure mesa, egl and gles provider
cordlandwehr Jan 9, 2023
b009b31
linux-starfive-dev: set CMA memory for visionfive2 to 256MB
cordlandwehr Jan 14, 2023
ecd903d
visionfive2-firmware: introduce shared config for binary blob versions
cordlandwehr Jan 22, 2023
35c7acf
vdec-module: add WAVE511 / vdec kernel module for video decoding
cordlandwehr Jan 22, 2023
91db81a
linux-firmware-vision2-wave511: package WAVE511 firmware blob
cordlandwehr Jan 22, 2023
81ddcab
linux-firmware-visionfive2-imggpu: split IMG_GPU firmware blob
cordlandwehr Jan 22, 2023
60401f4
linux-firmware-visionfive2-wave420l: package WAVE420L firmware blob
cordlandwehr Jan 22, 2023
4055381
venc-module: add WAVE420l video encoder kernel module
cordlandwehr Jan 22, 2023
384a354
jpu-module: package JPU / CODAJ12 kernel module
cordlandwehr Jan 29, 2023
2e98992
linux-starfive-dev: update kernel to VisionFive2 tag 2.8.0
cordlandwehr Jan 22, 2023
ee11efd
libsf-wave511: package WAVE511 decoder library
cordlandwehr Jan 25, 2023
14ac34e
libsf-wave420: Package WAVE420l Encoding library
cordlandwehr Jan 25, 2023
f33ad30
libsf-codaj12: Package SF's JPEG coding library
cordlandwehr Jan 26, 2023
958670a
libsf-omx: Package SF's libomx variant for OpenMAX
cordlandwehr Jan 25, 2023
ce2a066
sf-gst-omx: introduce gst-omx fork
cordlandwehr Jan 28, 2023
daa23ca
visionfive2.conf: recommend VPU kernel modules and use custom omx-il
cordlandwehr Jan 22, 2023
28cd895
libsf-omxil: introduce CMake for better building
cordlandwehr Jan 29, 2023
dcecd08
visionfive2.conf: remove obsolete opensbi
cordlandwehr Feb 14, 2023
30a0ced
gstreamer1.0-plugins-bad: enable kms plugin for visionfive2
cordlandwehr Feb 14, 2023
f07fbec
Merge branch 'master' into feature/visionfive2
kraj Mar 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions conf/machine/visionfive2.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#@TYPE: Machine
#@NAME: visionfive2
#@SOC: StarFive JH7110
#@DESCRIPTION: Machine configuration for the VisionFive 2 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_PROVIDER_virtual/libgl ?= "mesa-pvr"
PREFERRED_PROVIDER_virtual/mesa ?= "mesa-pvr"
PREFERRED_PROVIDER_virtual/libgbm ?= "mesa-pvr"
PREFERRED_PROVIDER_virtual/egl ?= "mesa-pvr"
PREFERRED_PROVIDER_virtual/libgles1 ?= "mesa-pvr"
PREFERRED_PROVIDER_virtual/libgles3 ?= "mesa-pvr"
PREFERRED_PROVIDER_virtual/libgles2 ?= "visionfive2-pvr-graphics"
PREFERRED_PROVIDER_virtual/libomxil ?= "libsf-omxil"

PREFERRED_VERSION_openocd-native = "riscv"
PREFERRED_VERSION_openocd = "riscv"

RISCV_SBI_PLAT = "generic"

## This sets u-boot as the default OpenSBI payload
RISCV_SBI_PAYLOAD ?= "u-boot.bin"

RISCV_SBI_FDT ?= "jh7110-visionfive-v2.dtb"

SERIAL_CONSOLES = "115200;ttyS0"

MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += " \
kernel-modules \
vdec-module \
venc-module \
jpu-module \
"

IMAGE_FSTYPES += "wic.gz wic.bmap ext4"
KERNEL_DEVICETREE ?= "starfive/jh7110-visionfive-v2.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_visionfive2_defconfig"

UBOOT_ENTRYPOINT = "0x80200000"
UBOOT_DTB_LOADADDRESS = "0x82200000"
UBOOT_DTB = "1"
UBOOT_DTB_BINARY = "starfive_visionfive2.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"
6 changes: 6 additions & 0 deletions recipes-bsp/common/visionfive2-firmware.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
VISIONFIVE2FW_DATE ?= "20230111"

SRC_URI += "git://github.com/starfive-tech/soft_3rdpart.git;protocol=https;lfs=1;branch=JH7110_VisionFive2_devel;rev=b580826be8a00fb8143bc5ea3310ba12af612468"
HOMEPAGE ?= "https://github.com/starfive-tech/soft_3rdpart"

PV ?= "${VISIONFIVE2FW_DATE}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
From 796732e49c919d74cab4978e517f02219daba9c4 Mon Sep 17 00:00:00 2001
From: Andreas Cord-Landwehr <cordlandwehr@kde.org>
Date: Sat, 7 Jan 2023 10:58:48 +0100
Subject: [PATCH] riscv: fix build with binutils 2.38

Original patch:
https://lore.kernel.org/all/YhCvlHomlT2js3uO@ubuntu01/T/

From version 2.38, binutils default to ISA spec version 20191213. This
means that the csr read/write (csrr*/csrw*) instructions and fence.i
instruction has separated from the `I` extension, become two standalone
extensions: Zicsr and Zifencei.

The fix is to specify those extensions explicitely in -march. However as
older binutils version do not support this, we first need to detect
that.

Signed-off-by: Andreas Cord-Landwehr <cordlandwehr@kde.org>
---
arch/riscv/Makefile | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 0b80eb8d86..cd1bc49e7c 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -26,6 +26,16 @@ endif

ARCH_FLAGS = -march=$(ARCH_BASE)$(ARCH_A)$(ARCH_C) -mabi=$(ABI) \
-mcmodel=$(CMODEL)
+RISCV_MARCH = $(ARCH_BASE)$(ARCH_A)$(ARCH_C)
+
+# Newer binutils versions default to ISA spec version 20191213 which moves some
+# instructions from the I extension to the Zicsr and Zifencei extensions.
+toolchain-need-zicsr-zifencei := $(call cc-option-yn, -mabi=$(ABI) -march=$(RISCV_MARCH)_zicsr_zifencei)
+ifeq ($(toolchain-need-zicsr-zifencei),y)
+ RISCV_MARCH := $(RISCV_MARCH)_zicsr_zifencei
+endif
+
+ARCH_FLAGS = -march=$(RISCV_MARCH) -mabi=$(ABI) -mcmodel=$(CMODEL)

PLATFORM_CPPFLAGS += $(ARCH_FLAGS)
CFLAGS_EFI += $(ARCH_FLAGS)
--
2.37.2

14 changes: 14 additions & 0 deletions recipes-bsp/u-boot/u-boot-starfive/uEnv-visionfive2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
fdt_high=0xffffffffffffffff
initrd_high=0xffffffffffffffff
kernel_addr_r=0x44000000
kernel_comp_addr_r=0x90000000
kernel_comp_size=0x10000000
fdt_addr_r=0x48000000
ramdisk_addr_r=0x48100000
# Move distro to first boot to speed up booting
boot_targets=distro mmc0 dhcp
# Fix wrong fdtfile name
fdtfile=starfive/jh7110-visionfive-v2.dtb
# Fix missing bootcmd
bootcmd=run bootcmd_distro
bootargs=root=/dev/mmcblk1p2 rw console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0
15 changes: 14 additions & 1 deletion recipes-bsp/u-boot/u-boot-starfive_v2021.04.bb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ LIC_FILES_CHKSUM = "file://Licenses/README;md5=5a7450c57ffe5ae63fd732446b988025"
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"

BRANCH:visionfive = "JH7100_VisionFive_OH_dev"
BRANCH:visionfive2 = "JH7110_VisionFive2_devel"
BRANCH:beaglev-starlight-jh7100 = "Fedora_JH7100_2021.04"


SRC_URI = "git://github.com/starfive-tech/u-boot.git;protocol=https;branch=${BRANCH} \
file://tftp-mmc-boot.txt \
"
Expand All @@ -21,10 +23,17 @@ SRC_URI:append:visionfive = " \
file://fix-riscv-isa.patch \
file://uEnv-visionfive.txt \
"
SRC_URI:append:visionfive2 = " \
file://0001-riscv-fix-build-with-binutils-2.38.patch \
file://uEnv-visionfive2.txt \
"

SRCREV = "7b70e1d44ba9702a519ca936cabf19070309123a"
SRCREV:visionfive = "ccecef294d355e9d05edf0bb6058002a0fe08908"

# tag VF2_v2.6.0
SRCREV:visionfive2 = "66a72185a813c36b8975fd7ded9d74d6a5525db7"

DEPENDS:append = " u-boot-tools-native"

# Overwrite this for your server
Expand All @@ -40,7 +49,11 @@ do_deploy:append:visionfive() {
install -m 644 ${WORKDIR}/uEnv-visionfive.txt ${DEPLOYDIR}/uEnv.txt
}

COMPATIBLE_MACHINE = "(beaglev-starlight-jh7100|visionfive)"
do_deploy:append:visionfive2() {
install -m 644 ${WORKDIR}/uEnv-visionfive2.txt ${DEPLOYDIR}/uEnv.txt
}

COMPATIBLE_MACHINE = "(beaglev-starlight-jh7100|visionfive|visionfive2)"

TOOLCHAIN = "gcc"

Expand Down
65 changes: 65 additions & 0 deletions recipes-graphics/drivers/visionfive2-pvr-graphics_1.17.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
LICENSE="CLOSED"

PROVIDES = "virtual/libgles2"
COMPATIBLE_MACHINE = "visionfive2"

require recipes-bsp/common/visionfive2-firmware.inc
inherit update-rc.d

S = "${WORKDIR}/git"

IMG_GPU_POWERVR_VERSION = "img-gpu-powervr-bin-1.17.6210866"

PACKAGES += " \
${PN}-firmware \
${PN}-tools \
"

do_install () {
tar xz --no-same-owner -f ${S}/IMG_GPU/out/${IMG_GPU_POWERVR_VERSION}.tar.gz -C ${D}
mv ${D}/${IMG_GPU_POWERVR_VERSION}/target/* ${D}
install -d ${D}/usr/include/
cp -r ${D}/${IMG_GPU_POWERVR_VERSION}/staging/usr/include/drv/ ${D}/usr/include/
cp -r ${D}/${IMG_GPU_POWERVR_VERSION}/staging/usr/include/GLES/ ${D}/usr/include/
cp -r ${D}/${IMG_GPU_POWERVR_VERSION}/staging/usr/include/GLES2/ ${D}/usr/include/
cp -r ${D}/${IMG_GPU_POWERVR_VERSION}/staging/usr/include/GLES3/ ${D}/usr/include/
install -d ${D}/usr/lib/pkgconfig/
cp -r ${D}/${IMG_GPU_POWERVR_VERSION}/staging/usr/lib/pkgconfig/* ${D}/usr/lib/pkgconfig/

# provided via separate arch-independent firmware package
rm -rf ${D}/lib/firmware
rmdir ${D}/lib

# cleanup unused
rm -rf ${D}/${IMG_GPU_POWERVR_VERSION}
}

INITSCRIPT_NAME = "rc.pvr"

FILES_SOLIBSDEV = ""
FILES:${PN} += " \
${libdir}/*.so \
"

FILES:${PN}-tools = " \
${prefix}/local/bin/ \
"

FILES:${PN}-firmware = " \
${base_libdir}/firmware/ \
"

RDEPENDS:${PN} += " \
bash \
libdrm \
linux-firmware-visionfive2-imggpu \
"

RDEPENDS:${PN}-tools += " \
python3 \
"

INSANE_SKIP:${PN} += "already-stripped dev-so"
# ignore dependency check for python scripting
INSANE_SKIP:${PN}-tools += "already-stripped file-rdeps"
INSANE_SKIP:${PN}-firmware += "arch"
Loading