#@TYPE: Machine
#@NAME: freedom-u540
#@SOC: Freedom U540
#@DESCRIPTION: Machine configuration for the HiFive Unleashed development board

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

MACHINE_FEATURES = "screen keyboard ext2 ext3 serial"

KERNEL_IMAGETYPE = "Image"

PREFERRED_PROVIDER_virtual/kernel ?= "linux-mainline"

EXTRA_IMAGEDEPENDS += "opensbi"
RISCV_SBI_PLAT = "sifive/fu540"

# When we have u-boot SD/MMC load support we can swap to
#  u-boot being the defual. Until then it's an option for TFTP boot
# RISCV_SBI_PAYLOAD ?= "u-boot.bin"
# This will set the kernel as the OpenSBI payload
RISCV_SBI_PAYLOAD ?= "${KERNEL_IMAGETYPE}-${MACHINE}.bin"

# Override the DTB from the firmware with this one from openSBI
# Use this to add Microsemi Expansion board support
# RISCV_SBI_FDT ?= "HiFiveUnleashed-MicroSemi-Expansion.dtb"

SERIAL_CONSOLES = "115200;ttySIF0"

MACHINE_EXTRA_RRECOMMENDS += " kernel-modules"

IMAGE_FSTYPES_append = " wic.gz ext4"
KERNEL_IMAGETYPES += "uImage"
KEEPUIMAGE = "no"

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

EXTRA_IMAGEDEPENDS += "u-boot"
UBOOT_MACHINE = "sifive_fu540_defconfig"

UBOOT_ENTRYPOINT = "0x80200000"

# Set this to "tftp-boot" to generate a boot.scr file which should
#  be included in the TFTP directory. It will contain the commands to
#  autoboot Linux from u-boot.
UBOOT_ENV ?= "tftp-boot"

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

IMAGE_BOOT_FILES ?= " \
    Image \
    uImage \
"

WKS_FILE ?= "freedom-u540-opensbi.wks"

BAD_RECOMMENDATIONS += "\
    libcxx-dev \
    libcxx-staticdev \
    compiler-rt-dev \
    compiler-rt-staticdev \
"
ASSUME_PROVIDED += "\
    libcxx-dev \
    libcxx-staticdev \
    compiler-rt-dev \
    compiler-rt-staticdev \
"
