#@TYPE: Machine
#@NAME: starfive-jh8100
#@SOC: JH8100
#@DESCRIPTION: Machine configuration for the JH8100 default config

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

EXTRA_IMAGEDEPENDS:append = " qemu-helper-native:do_addto_recipe_sysroot"
IMAGE_CLASSES += " qemuboot "
QB_MACHINE = "-machine virt"
QB_DEFAULT_KERNEL = "Image-starfive-jh8100.bin"
QB_CPU = "-cpu rv64"
QB_MEM = "-m 8G"
QB_DEFAULT_FSTYPE = "ext4"
SERIAL_CONSOLES = "115200;ttyS0"
QB_SYSTEM_NAME = "qemu-system-riscv64"
QB_ROOTFS_OPT = "-drive file=@ROOTFS@,format=raw,id=hd0 -device virtio-blk-device,drive=hd0"

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"

LLVMVERSION = "16.0.5"
GLIBCVERSION = "2.36"
BINUVERSION = "2.39"
GCCVERSION = "12.2.0"
QEMUVERSION = "7.2.0"
PREFERRED_VERSION_openocd = "riscv"
PREFERRED_VERSION_openocd-native = "riscv"
PREFERRED_VERSION_opensbi ?= "1.2"
PREFERRED_VERSION_xserver-xorg = "1.20.13"
PREFERRED_VERSION_mbedtls = "3.4.0"
PREFERRED_PROVIDER_dhcp-relay = "dhcp"
PREFERRED_PROVIDER_nodejs = "18.0.0"

RISCV_SBI_PLAT = "generic"
#RISCV_SBI_PAYLOAD = "u-boot.bin"
#RISCV_SBI_FDT = "jh8100-fpga.dtb"

IMAGE_FSTYPES += " ext4 wic.gz wic.bmap cpio cpio.gz"

KERNEL_DEVICETREE ?= "starfive/jh8100-fpga.dtb"
KERNEL_IMAGETYPE = "Image"

FIT_KERNEL_COMP_ALG = "none"

EXTRA_IMAGEDEPENDS += " u-boot-starfive openocd-native"

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

UBOOT_MACHINE = "starfive_jh8100_defconfig"
#UBOOT_MACHINE = "qemu-riscv64_spl_defconfig"
UBOOT_DTB_BINARY = "jh8100-fpga.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 \
	bmap-tools-native \
"
IMAGE_BOOT_FILES ?= " \
        jh8100-fpga.dtb \
	Image \
"
WKS_FILE ?= "starfive-jh8100.wks"
