## Step 3: Create the Vitis Platform ### Prepare Files for Platform Packaging 1. We would store all the necessary files for Vitis platform creation flow. Here we name it ```zcu104_custom_pkg ```. Then we create a `pfm` folder inside to hold platform creation source components. ``` mkdir zcu104_custom_pkg cd zcu104_custom_pkg mkdir pfm ``` After this step, your directory hierarchy looks like this. ``` - zcu104_custom_platform # Vivado Project Directory - zcu104_custom_plnx # PetaLinux Project Directory - zcu104_custom_pkg # Platform Packaging Directory - pfm # Platform Packaging Sources ``` 2. Install sysroot: - Go to /images/linux directory. - Type `./sdk.sh -d ` to install PetaLinux SDK. use the `-d` option to provide a full pathname to the output directory **zcu104_custom_pkg** (This is an example ) and confirm. - Note: The environment variable **LD_LIBRARY_PATH** must not be set when running this command We would install Vitis AI library and DNNDK into this rootfs during test phase. 3. Create `boot` directory and `image` directory inside pfm directory ```bash cd zcu104_custom_pkg/pfm mkdir boot mkdir image ``` After this step, your directory hierarchy looks like this. ``` - zcu104_custom_platform # Vivado Project Directory - zcu104_custom_plnx # PetaLinux Project Directory - zcu104_custom_pkg # Platform Packaging Directory - sysroots # Extracted Sysroot Directory - pfm # Platform Packaging Sources - boot # Platform boot components - image # Files to be put in FAT32 partition ``` We'll prepare BIF file and the files it refers to into **boot** directory; we'll prepare all files needed for FAT32 partition to **image** directory. 4. Create BIF (linux.bif) to describe boot component structure for bootgen - Add a BIF file (linux.bif) to the **/pfm/boot** directory with the contents shown below. - The file names should match the contents of the boot directory. The Vitis tool expands these pathnames relative to the sw directory of the platform at v++ link time or when generating an SD card. However, if the bootgen command is used directly to create a BOOT.BIN file from a BIF file, full pathnames in the BIF are necessary. Bootgen does not expand the names between the <> symbols. ``` /* linux */ the_ROM_image: { [fsbl_config] a53_x64 [bootloader] [pmufw_image] [destination_device=pl] [destination_cpu=a53-0, exception_level=el-3, trustzone] [destination_cpu=a53-0, exception_level=el-2] } ``` - The file names in `<>` are placeholders. Vitis will replace the placeholders with the relative path to platform during platform packaging. V++ packager, which runs when buiding the final application would expand it further to the full path during image packaging. - Filename placeholders point to the files in boot directory. The filenames in boot directory need to match with placeholders in BIF file. - `` is a reserved keyword. V++ packager will replace it with the final system bit file. - It's a known issue that v++ packager only recognizes FSBL with ``. So for MPSoC, it's needed to copy `zynqmp_fsbl.elf` that PetaLinux generates to `fsbl.elf` in image directory. This issue is fixed in 2020.2. 5. Prepare for the boot coomponents Copy the generated Linux software boot components from **/images/linux directory** to the **/pfm/boot** directory to prepare for running the Vitis platform packaging flow: - zynqmp_fsbl.elf: **rename as fsbl.elf** as a workaround of a Vitis known issue. - pmufw.elf - bl31.elf - u-boot.elf Note: These files are the sources of creating BOOT.BIN mentioned bin linux.bif. The bitstream component in the linux.bif is not available now yet because it will be generated by v++ linker. V++ packager will handle it automatically. 6. Prepare **image** directory. Contents in this directory will be packaged to FAT32 partition by v++ package tool. - Copy the generated Linux software components from **/images/linux directory** to the **/pfm/image** directory. - boot.scr: script for u-boot initialization. - system.dtb: the device tree blob that u-boot reads during boot to understand system setup. Note: - In Vitis 2020.1, init.sh and platform_desc.txt in image directory are required by XRT to setup environment variables. They are not needed by XRT 2020.2. ### Create a Vitis Platform First we create a Vitis platform project with the XSA file generated by Vivado from Step 1. 1. Launch Vitis IDE - Go to the **zcu104_custom_pkg** folder you created: ``` cd ``` - Launch Vitis by typing `vitis &` in the console. - Select **zcu104_custom_pkg** folder as workspace directory. 2. Create a new platform project - Select menu **File > New > Platform Project** to create a platform project.
- Enter the project name. For this example, type ```zcu104_custom```. Click **Next**. - In the Platform page, - Click **Browse** button, select the XSA file generated by the Vivado. In this case, it is ```zcu104_custom_platform.xsa```.
- Set the operating system to **linux**.
- Set the processor to **psu_cortexa53**.
- Architecture: **64-bit**
- **Uncheck** option **Generate boot components**, because we'll use PetaLinux generated boot components.
- Click **Finish**. 3. Setup software settings in Platform Settings view. - Click the **linux on psu_cortexa53** domain, browse to the locations and select the directory or file needed to complete the dialog box for the following: - **Bif file**: Browse to **zcu104_custom_pkg/pfm/boot/linux.bif** file and click OK. - **Boot Components Direcotory**: Browse to **zcu104_custom_pkg/pfm/boot** and click OK. - **Linux Image Directory**: Browse to **zcu104_custom_pkg/pfm/image** and click OK. ![vitis_linux_config.png](./images/vitis_linux_config.png) Note: - Vitis 2020.2 will setup default QEMU arguments to enable Vitis platform emulation. If there are additional QEMU settings, please write your own qemu_args.txt and set the file name in **QEMU Arguments** field. 4. Click **zcu104_custom** project in the Vitis Explorer view, click the **Build** button to generate the platform. ![](./images/build_vitis_platform.png) **Note: The generated platform is placed in the export directory. BSP and source files are also provided for re-building the FSBL and PMU if desired and are associated with the platform. The platform is ready to be used for application development.** ![](./images/vitis_platform_output.png) If you'd create an Vitis application in the same workspace as this platform, you can find this platform available in the platform selection page in platform creation wizard. If you'd like to reuse this platform in another workspace, add its path to PLATFORM_REPO_PATHS environment variable before launching Vitis GUI, or use "Add" button in platform selection page of Vitis GUI to add its path. **[Next let's try to build some applications on this platform and test them.](./step4.md)** ### Fast Track Scripts are provided to create the Vitis platform. To use these scripts, please run the following steps. 1. Run build ``` # cd to the step directory, e.g. cd step3_pfm make all ``` 2. To clean the generated files, please run ```bash make clean ```

Copyright© 2020 Xilinx