#@TYPE: Machine
#@NAME: beaglev-starlight-jh7100
#@SOC: StarFive JH7100
#@DESCRIPTION: Machine configuration for the beta BeagleV Starlight 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 ?= "starfive_vic7100_beagle_v.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-beaglev-starlight.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_vic7100_beagle_v_smode_defconfig"

UBOOT_ENTRYPOINT = "0x80200000"
UBOOT_DTB_LOADADDRESS = "0x82200000"
UBOOT_DTB = "1"
UBOOT_DTB_BINARY = "starfive_vic7100_beagle_v.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 \
"

WKS_FILE ?= "beaglev.wks"
