# Rockchip RK3399 hexa core 2G/4GB SoC GBe eMMC USB3 WiFi
BOARD_NAME="RockPro 64"
BOARDFAMILY="rockchip64"
BOARD_MAINTAINER="joekhoobyar"
BOOTCONFIG="rockpro64-rk3399_defconfig"
KERNEL_TARGET="current,edge"
KERNEL_TEST_TARGET="current"
FULL_DESKTOP="yes"
BOOT_LOGO="desktop"
BOOT_SCENARIO="blobless"
BOOT_SUPPORT_SPI=yes

# u-boot 2023.01 for rockpro64
BOOTBRANCH_BOARD="tag:v2023.01"
BOOTPATCHDIR="v2023.01"

function add_host_dependencies__new_uboot_wants_python3_rockpro64() {
	declare -g EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} python3-pyelftools" # @TODO: convert to array later
}

function post_family_config__hacks_for_new_uboot_rockpro64() {
	display_alert "$BOARD" "using ATF (blobless) for 2023.01 u-boot" "info"
	# Use latest lts 2.8 ATF
	ATFBRANCH='tag:lts-v2.8.8'
	ATFPATCHDIR="atf-rockchip64" # patches for logging etc
	# With recent-enough u-boot and ATF.
	# bl31.elf is copied directly from ATF build dir to uboot dir anyway.
	UBOOT_TARGET_MAP="BL31=bl31.elf;;idbloader.img u-boot.itb tpl/u-boot-tpl.bin spl/u-boot-spl.bin u-boot.itb rkspi_loader.img"
}

function post_config_uboot_target__extra_configs_for_rockpro64() {
	# Taken from https://gitlab.manjaro.org/manjaro-arm/packages/core/uboot-rockpro64/-/blob/master/PKGBUILD
	display_alert "$BOARD" "u-boot configs for 2023.01 u-boot config" "info"
	run_host_command_logged scripts/config --set-val CONFIG_OF_LIBFDT_OVERLAY "y"
	run_host_command_logged scripts/config --set-val CONFIG_SPL_MMC_SDHCI_SDMA "n"
	run_host_command_logged scripts/config --set-val CONFIG_MMC_HS400_SUPPORT "y"
	run_host_command_logged scripts/config --set-val CONFIG_USE_PREBOOT "n"
}
