ARCH=armhf
SERIALCON='ttyPS0'
LINUXFAMILY=zynq

KERNELSOURCE='https://github.com/Xilinx/linux-xlnx.git'
KERNELBRANCH='tag:xilinx-v2020.2'
KERNELDIR='linux-xlnx'
KERNELPATCHDIR='zynq-'$BRANCH

BOOTSOURCE='https://github.com/Xilinx/u-boot-xlnx.git'
BOOTBRANCH='tag:xilinx-v2020.2'
BOOTCONFIG="xilinx_zynq_virt_defconfig"
BOOTDIR='u-boot-xlnx'
BOOTSCRIPT='boot-zynq.cmd:boot.cmd'
BOOTENV_FILE='zynq.txt'
UBOOT_TARGET_MAP=';;u-boot.elf'

family_tweaks()
{
	true
}

uboot_custom_postprocess()
{
	# Precompiled first stage bootloader
	(fetch_from_repo "https://github.com/tparys/xilinx-fsbl-blobs" "xilinx-fsbl" "branch:master")
	cp ${SRC}/cache/sources/xilinx-fsbl/zynq/fsbl.elf .

	# Compile Xilinx bootgen to make boot image
	compile_xilinx_bootgen

	# Create a bootgen build instruction file
    	cat > build.bif <<EOF
the_ROM_image : {
  [bootloader]fsbl.elf
  u-boot.elf
}
EOF

	# Regenerate boot.bin
	rm -f boot.bin
	bootgen -image build.bif -o i boot.bin

	# And a simple README for users
	cat > README <<EOF
# Regenerate Zynq boot.bin from fsbl.elf, u-boot.elf
bootgen -image build.bif -o i boot.bin
EOF

	# Package build components into u-boot lib dir
	cp fsbl.elf "$uboottempdir/${uboot_name}/usr/lib/${uboot_name}/${f_dst}"
	cp build.bif "$uboottempdir/${uboot_name}/usr/lib/${uboot_name}/${f_dst}"
	cp README "$uboottempdir/${uboot_name}/usr/lib/${uboot_name}/${f_dst}"

	# Package boot.bin as a u-boot "config file", so package manager
	# won't fight end users who update this themselves ...
	mkdir -p "$uboottempdir/${uboot_name}/boot"
	cp boot.bin "$uboottempdir/${uboot_name}/boot"
	mkdir -p "$uboottempdir/${uboot_name}/DEBIAN"
	echo "/boot/boot.bin" > "$uboottempdir/${uboot_name}/DEBIAN/conffiles"
}

write_uboot_platform()
{
	:
}
