#
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (c) 2013-2023 Igor Pecovnik, igor@armbian.com
#
# This file is a part of the Armbian Build Framework
# https://github.com/armbian/build/
#
ARCH="riscv64"

BOOTSOURCE='https://github.com/smaeul/u-boot'
BOOTBRANCH='branch:d1-wip'
BOOTPATCHDIR="u-boot-nezha"
UBOOT_TARGET_MAP=";;u-boot.img"

LINUXFAMILY="d1"
LINUXCONFIG="linux-d1-${BRANCH}"

case "${BRANCH}" in

	edge)
		declare -g KERNEL_MAJOR_MINOR="6.1" # Major and minor versions of this kernel. For mainline caching.
		KERNELSOURCE='https://github.com/smaeul/linux'
		KERNELBRANCH="branch:riscv/d1-wip"
		KERNELPATCHDIR="d1-${BRANCH}"
		LINUXCONFIG="linux-d1-${BRANCH}"
		KERNEL_DRIVERS_SKIP+=(driver_rtw88) # This is custom 6.1 driver, skip rtw88 to avoid patching failures
		;;

esac

#KERNELPATCHDIR="archive/starfive-${KERNEL_MAJOR_MINOR}" # Don't use symlinks.

write_uboot_platform() {
	dd if=$SRC/packages/blobs/riscv64/nezha/boot0_sdcard_sun20iw1p1.bin of=$2 bs=8192 seek=16 conv=notrunc
	dd if=$SRC/packages/blobs/riscv64/nezha/u-boot.toc1 of=$2 bs=512 seek=32800 conv=notrunc
	dd if=$SRC/packages/blobs/riscv64/nezha/u-boot.toc1 of=$2 bs=512 seek=24576 conv=notrunc
}
