#@TYPE: Machine
#@NAME: starfive-dubhe
#@SOC: Dubhe default
#@DESCRIPTION: Machine configuration for the Dubhe default config

LLVMVERSION = "16.0.5"
CLANGSDK = "1"
EXTRA_IMAGEDEPENDS:append = " llvm file-native rpm-native popt-native openocd-native u-boot-starfive"
EXTRA_IMAGE_FEATURES:append = " dbg-pkgs tools-profile"

PACKAGE_DEBUG_SPLIT_STYLE = 'debug-file-directory'

#require conf/machine/include/qemu.inc
# qemuboot options
EXTRA_IMAGEDEPENDS:append = " qemu-helper-native:do_addto_recipe_sysroot"
IMAGE_CLASSES += " qemuboot "
QB_MACHINE = "-machine virt"
QB_DEFAULT_KERNEL = "${@oe.utils.conditional('ENABLE_INIT','1','Image-initramfs-starfive-dubhe.bin','Image-starfive-dubhe.bin',d)}"
QB_DEFAULT_BIOS = "fw_payload.bin"
QB_CPU = "-cpu rv64"
QB_DEFAULT_FSTYPE = "${@oe.utils.conditional('ENABLE_INIT','1','cpio.gz','ext4',d)}"
SERIAL_CONSOLES = "115200;ttyS0"
QB_SYSTEM_NAME = "qemu-system-riscv64"
QB_MEM = "-m 2048"
QB_OPT_APPEND = "-smp 8"
QB_ROOTFS_OPT = "${@oe.utils.conditional('ENABLE_EXT4','1','-drive file=@ROOTFS@,format=raw,id=mmc0,if=none -device virtio-blk-device,drive=mmc0','',d)}"

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

MACHINE_FEATURES = "screen keyboard ext2 ext3 serial"

KERNEL_DEVICETREE ?= " \
	starfive/dubhe80_fpga.dtb \
	starfive/dubhe90_fpga.dtb \
"
KERNEL_IMAGETYPE = "Image"

KEEPUIMAGE = "no"
INITRAMFS_FSTYPES ?= "cpio.gz cpio.lzma"
INITRAMFS_MAXSIZE = "524288"

PREFERRED_PROVIDER_virtual/kernel ?= "linux-starfive-dev"
PREFERRED_VERSION_linux-starfive-dev = "6.1%"
PREFERRED_PROVIDER_virtual/bootloader = "u-boot-starfive"
RISCV_SBI_PLAT = "generic"

QEMU_EXTRAOPTIONS:riscv64 = " -cpu rv64,x-b=true,x-v=true"

GLIBCVERSION = "2.36"
BINUVERSION = "2.39"
GCCVERSION = "12.2.0"
QEMUVERSION = "7.2.0"
PREFERRED_VERSION_opensbi = "1.2"
PREFERRED_VERSION_gdb = "13.2"
PREFERRED_VERSION_openocd = "riscv"
PREFERRED_VERSION_openocd-native = "riscv"
#
###IMAGE_FSTYPES += "wic.gz wic.bmap ext4 cpio"

#UBOOT_CONFIG = "defconfig"

UBOOT_MACHINE = "starfive_dubhe_fpga_defconfig"
#UBOOT_MACHINE = "qemu-riscv64_spl_defconfig"

UBOOT_DTB_BINARY = "dubhe_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"


## wic default support
WKS_FILE_DEPENDS ?= " \
    opensbi \
    bmap-tools-native \
"


###IMAGE_BOOT_FILES ?= " \
###    fw_payload.bin \
###    ${KERNEL_IMAGETYPE} \
###    ${RISCV_SBI_FDT}  \
###    boot.scr.uimg \
###"
WKS_FILE ?= "starfive-dubhe.wks"
