## Instructions on how to create the PDI file

### Description
The PDI files in this directory are built specifically for each individual board.  Each PDI boots the firmware on its corresponding Versal silicon and then invokes the u-boot elf file on APU.  The u-boot is configured to download the Build-In-Self-Test (BIST) binary to QSPI flash device and then drop into u-boot prompt.  It does not attempt to boot Linux.

> All references below are for VCK190 board.  The same steps are applicable for other boards as well.

### Building PDI
The PDI is generated by the [Bootgen](https://www.xilinx.com/support/documentation/sw_manuals/xilinx2021_1/ug1283-bootgen-user-guide.pdf) utility with the following invocation:

	bootgen -arch versal -padimageheader=0 -log trace -w -o vck190_system_wrapper.pdi -image uboot.bif

The `uboot.bif` file is input to bootgen and it contains:

	the_ROM_image:
	{
        	id_code = 0x14ca8093
        	extended_id_code = 0x01

        	image {
                	{ type=bootimage, file=project_1.pdi }
                	{ type=bootloader, file=plm.elf }
                	{ core=psm, file=psmfw.elf }
        	}

        	image {
                	id = 0x1c000000, name=apu_subsystem 
                	{ type=raw, load=0x00080000, file=blinkbist.bin }
                	{ type=raw, load=0x00001000, file=system.dtb }
                	{ core=a72-0, exception_level=el-3, trustzone, file=bl31.elf }
                	{ core=a72-0, exception_level=el-2, file=u-boot.elf }
        	}
	}

The majority of files referenced by `uboot.bif` can be obtained from [VCK190 Petalinux BSP](https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/embedded-design-tools.html) link of [Versal AI Core Series VCK190 Evaluation Kit](https://www.xilinx.com/products/boards-and-kits/vck190.html) wiki page.  The `plm.elf`, `psmfw.elf`, `system.dtb`, and `bl31.elf` binaries are from `pre-built` directory of BSP.  The `project_1.pdi` binary is from `hardware/xilinx-vck190-2021.1/outputs` directory of BSP.

The `u-boot.elf` is built from [u-boot-xlnx](https://github.com/Xilinx/u-boot-xlnx) repository with the following commands:

	make xilinx_versal_virt_defconfig
	sed -i -e '/CONFIG_BOOTDELAY/s/5/0/' .config
	sed -i -e '/CONFIG_BOOTCOMMAND/s/"run distro_bootcmd"/"sf probe 0 0 0; sf erase 0 0x1400000; sf write 0x80000 0 0x1400000;"/' .config
	make CROSS_COMPILE=aarch64-linux-gnu- -j32

File `blinkbist.bin` is the Build-In-Self-Test program that tests different aspects of the board.  This binary can be obtained from [XTP613 - VCK190 Board Interface Test](https://www.xilinx.com/member/forms/download/design-license.html?cid=b83eede2-f9d2-4e81-a393-67a1a8ba609e&filename=rdf0574-vck190-bit-c-2020-2.zip) link of [Versal AI Core Series VCK190 Evaluation Kit](https://www.xilinx.com/products/boards-and-kits/vck190.html#documentation) wiki page.  The location of BIST program is at `vck190_bit/BoardUI/tests/VCK190/qspi/blinkbist.mcs`.

A file with `.mcs` extension is in HEX format and needs to be converted to `.bin` format.  This conversion is possible with utilities like [SRecord](http://srecord.sourceforge.net/).  This utility is a Windows application and can be invoked on a PC to convert `blinkbist.mcs` to `blinkbist.bin`:

	srec_cat.exe blinkbist.mcs -Intel -o blinkbist.bin -Binary
