#@TYPE: Machine
#@NAME: VisionFive 2
#@SOC: JH7110
#@DESCRIPTION: Machine configuration for the VisionFive 2 default config

require conf/machine/include/riscv/tune-riscv.inc

MACHINE_FEATURES = "screen keyboard ext2 ext3 serial"

SERIAL_CONSOLE = "115200 ttyS0"

PREFERRED_PROVIDER_virtual/kernel = "linux-starfive-dev"
PREFERRED_PROVIDER_virtual/bootloader = "u-boot-starfive"

# For core-image-minimal-xfce
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_linux-starfive-dev = "5.15.0+gitAUTOINC+d9eee31aae"
PREFERRED_VERSION_glibc ?= "2.35"
PREFERRED_VERSION_gcc ?= "11.3.0"
PREFERRED_VERSION_binutils ?= "2.38"
PREFERRED_VERSION_opensbi ?= "1.2"
PREFERRED_VERSION_xserver-xorg = "1.20.13"

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

RISCV_SBI_PLAT = "generic"
RISCV_SBI_PAYLOAD = "u-boot.bin"
RISCV_SBI_FDT = "starfive_visionfive2.dtb"

KERNEL_CLASSES = "kernel-fitimage"
KERNEL_DEVICETREE ?= "starfive/jh7110-visionfive-v2.dtb"
KERNEL_IMAGETYPE = "fitImage"
UBOOT_ENTRYPOINT = "0x40200000"
UBOOT_DTB_LOADADDRESS = "0x46000000"
UBOOT_RD_ENTRYPOINT = "0x46100000"
UBOOT_RD_LOADADDRESS = "0x46100000"
UBOOT_DTB = "1"

INITRAMFS_FSTYPES = "cpio.gz"
IMAGE_FSTYPES += "wic.gz wic.bmap ext4"
FIT_KERNEL_COMP_ALG = "none"

EXTRA_IMAGEDEPENDS += "u-boot-starfive"

UBOOT_ENV ?= "boot"
UBOOT_ENV_SUFFIX = "scr.uimg"

UBOOT_MACHINE = "starfive_visionfive2_defconfig"
UBOOT_DTB_BINARY = "starfive_visionfive2.dtb"

SPL_BINARY = "spl/u-boot-spl.bin"
SPL_NORMAL_BINARY = "u-boot-spl.bin.normal.out"

## Do not update fstab file when using wic images
WIC_CREATE_EXTRA_ARGS ?=  "--no-fstab-update"

WKS_FILE_DEPENDS ?= " \
	opensbi \
"

IMAGE_BOOT_FILES ?= " \
	vf2_uEnv.txt \
	vf2_nvme_uEnv.txt \
	starfiveu.fit \
	fitImage-linux.bin-starfive-visionfive2 \
	initramfs.img \
	jh7110-visionfive-v2-starfive-visionfive2.dtb \
"
WKS_FILE ?= "starfive-visionfive2.wks"
