Enable programmable logic support¶
Goal¶
- In this tutorial you will
- Expand Vivado project from Create minimalist Vivado project for Leopard DPU with support for Programmable Logic 
- Build bitstream with two UART peripherals connected together 
 
A bit of background¶
Leopard DPU configuration that you created in Create minimalist Vivado project tutorial has support only for Processing System. Usage of Programmable Logic part of Zynq UltraScale+ requires following capabilities from Processing System side:
- Clock for programmable logic 
- Interrupt lines between Processing System and Programmable Logic 
- Memory interface between Processing System and Programmable Logic 
Zynq UltraScale+ IP block (the same block that you used to configure base settings like DDR memory or I/O pins) configures these options. All Vivado projects describing different “content” of Programmable Logic must use the same base settings. Vivado provides preset mechanism to transfer processing system configuration between projects.
 
Fig. 8 
Multiple Vivado projects sharing Processing System configuration using presets and producing different .xsa files.¶
Building content for programmable logic involves putting different IP blocks on block design, connecting them together using memory interfaces, interrupts, and clocks. To be usable from Linux distribution, IPs connect to “extension points” provided by Processing System.
Vivado stores content for Programmable Logic in .xsa file in form called bitstream. Using running Linux operating system you can use FPGA Manager to load different bitstreams to Programmable Logic.
Prerequisites¶
- Base Leopard DPU project from Create minimalist Vivado project 
- Base Yocto project for Leopard DPU from Minimalist Linux distribution 
- EGSE Host prepared to boot Leopard DPU from network as described in Minimalist Linux distribution 
Provided outputs¶
Following files (Tutorial files) are associated with this tutorial:
- Leopard/Zero-to-hero/03 Enable programmable logic support/leopard-minimalistic-with-pl.tcl- Vivado preset for Leopard with enabled PL support
- Leopard/Zero-to-hero/03 Enable programmable logic support/leopard-minimalistic-pl-base.xsa- Base XSA file with enabled PL support
- Leopard/Zero-to-hero/03 Enable programmable logic support/leopard-double-uart.xsa- Double UART XSA file
- Leopard/Zero-to-hero/03 Enable programmable logic support/boot-common.bin- Boot firmware for Leopard
- Leopard/Zero-to-hero/03 Enable programmable logic support/nominal-image-leopard-dpu.rootfs.cpio.gz.u-boot- Root filesystem for Leopard
- Leopard/Zero-to-hero/03 Enable programmable logic support/Image- Linux kernel
- Leopard/Zero-to-hero/03 Enable programmable logic support/system.dtb- Device tree
Use these files if you want to skip building bitstream or Yocto distribution by yourself.
Enable programmable logic support Vivado¶
- Open Leopard DPU project from Create minimalist Vivado project in Vivado 
- Use option to open - top_bdblock design
- Customize Zynq UltraScale+ block by double-clicking on it - Enable PL to PS interrupts - IRQ0[0-7]
- Enable PS-PL Master interface - AXI HPM0 FPD
- Enable PL-PS Slave interfaces - Enable - AXI HPC0 FPD
- Enable - AXI HPC1 FPD
- Enable - AXI LPD, set Data Width to 32 bits
 
- Enable Fabric Reset Enable 
- Set Number of Fabric Resets to 1 
- Enable PL fabric clock in Output clocks tab - Enable - PL0and set it to 100MHz
 
 
- In - top_bdblock design connect- maxihpm0_fpd_aclkto- pl0_clk
- In - top_bdblock design connect- saxihpc0_fpd_aclkto- pl0_clk
- In - top_bdblock design connect- saxihpc1_fpd_aclkto- pl0_clk
- In - top_bdblock design connect- saxi_lpd_aclkto- pl0_clk
- At this point block design should contain single IP block with each clock connected to - pl0_clk  - Fig. 9 Block design with Zynq UltraScale+ IP block configured to support Programmable Logic¶ 
- Open customization of Zynq UltraScale+ IP block and export preset by selecting - Use - leopard-minimalistic-with-plas preset name
- Save to - leopard-minimalistic-with-pl.tclfile
 
- Generate bitstream 
- Export hardware without bitstream. Use - leopard-minimalistic-pl-base.xsafor output file name.
Note
Selected Zynq UltraScale+ configuration covers needs of programmable logic content in this tutorial and next ones.
Create double UART bitstream Vivado¶
- Start Vivado and create new project. In new project wizard select following options: - Project type: RTL Project - Select 
- Don’t select 
 
- Part: - xczu9eg-ffvc900-1L-i
 
- Create top-level block design by using in Flow Navigator. Use - double_uart_bdas name.
- In block design diagram editor add Zynq UltraScale+ MPSoC IP block. 
- Start customization of Zynq UltraScale+ MPSoC IP block by double-clicking on it. - Apply previously exported preset by selecting and select - leopard-minimalistic-with-pl.tclfile.
 
- In - double_uart_bdblock design connect- maxihpm0_fpd_aclkto- pl0_clk.
- In - double_uart_bdblock design connect- saxihpc0_fpd_aclkto- pl0_clk
- In - double_uart_bdblock design connect- saxihpc1_fpd_aclkto- pl0_clk
- In - double_uart_bdblock design connect- saxi_lpd_aclkto- pl0_clk
- Place two - AXI UartliteIPs on block design
- Cross-connect UARTs by connecting - axu_uartlite1TX to- axu_uartlite0RX and vice versa.
- Click - Run connection automationand let Vivado instantiate necessary interconnects and resets.
- Add - ConcatIP block
- Connect - doutpin of- Concatblock to- pl_ps_irqpin of Zynq UltraScale+ block
- Connect - interruptpin of- axi_uartlite0to- In0of- Concatblock
- Connect - interruptpin of- axi_uartlite1to- In1of- Concatblock
- Final block design should look like this:   - Fig. 10 Block design with double UARTs connected together and available to Processing System¶ 
- In Sources view select and click in context menu. Use option. 
- Generate bitstream 
- Export hardware including bitstream to file - leopard-double-uart.xsa
Enable programmable logic support in boot firmware Yocto¶
- Add - leopard-minimalistic-pl-base.xsato- sources/meta-local/recipes-bsp/hdf/external-hdf/directory.
- Modify - sources/meta-local/recipes-bsp/hdf/external-hdf_%.bbappendto use new XSA file.- FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" HDF_BASE = "file://" HDF_PATH = "leopard-minimalistic-pl-base.xsa"
Add double UART bitstream to Linux distribution Yocto¶
Note
If necessary, re-enable Yocto environment using
machine:~/leopard-linux-1$ source sources/poky/oe-init-build-env ./build
- Create directory - sources/meta-local/recipes-example/bitstreams/double-uart/and copy- leopard-double-uart.xsato it.
- Create new recipe - sources/meta-local/recipes-example/bitstreams/double-uart.bbthat will install bitstream with double UART.- LICENSE = "CLOSED" inherit bitstream SRC_URI += "file://leopard-double-uart.xsa" BITSTREAM_HDF_FILE = "${WORKDIR}/leopard-double-uart.xsa"
- Create append for - leopard-allrecipe- machine:~/leopard-linux-1/build$ recipetool newappend ../sources/meta-local/ nominal-image NOTE: Starting bitbake server... WARNING: The ZynqMP pmu-rom is not enabled, qemu may not be able to emulate a ZynqMP system without it. To enable this you must add 'xilinx' to the LICENSE_FLAGS_ACCEPTED to indicate you accept the software license. Loading cache: 100% |#############################################################################################################################################################################| Time: 0:00:00 Loaded 3317 entries from dependency cache. Parsing recipes: 100% |###########################################################################################################################################################################| Time: 0:00:00 Parsing of 2006 .bb files complete (2004 cached, 2 parsed). 3318 targets, 570 skipped, 0 masked, 0 errors. WARNING: No bb files in default matched BBFILE_PATTERN_meta-kp-classes '^~/leopard-linux-1/sources/meta-kp-classes/meta-kp-classes/' Summary: There was 1 WARNING message. ~/leopard-linux-1/sources/meta-local/recipes-leopard/images/nominal-image.bbappend
- Add new packages into Linux image by editing - sources/meta-local/recipes-leopard/images/nominal-image.bbappend- IMAGE_INSTALL += "\ fpga-manager-script \ double-uart \ "
- Build firmware and image - machine:~/leopard-linux-1/build$ bitbake leopard-all
- Prepare build artifacts for transfer to EGSE Host - machine:~/leopard-linux-1/build$ mkdir -p ../egse-host-transfer machine:~/leopard-linux-1/build$ cp tmp/deploy/images/leopard-dpu/bootbins/boot-common.bin ../egse-host-transfer machine:~/leopard-linux-1/build$ cp tmp/deploy/images/leopard-dpu/system.dtb ../egse-host-transfer machine:~/leopard-linux-1/build$ cp tmp/deploy/images/leopard-dpu/nominal-image-leopard-dpu.rootfs.cpio.gz.u-boot ../egse-host-transfer machine:~/leopard-linux-1/build$ cp tmp/deploy/images/leopard-dpu/Image ../egse-host-transfer
- Transfer content of - egse-host-transferdirectory to EGSE Host and place it in- /var/tftp/tutorialdirectory
Loading double UART bitstream on DPU EGSE Host¶
- Verify that all necessary artifacts are present on EGSE Host: - customer@egse-host:~$ ls -lh /var/tftp/tutorial total 54M -rw-rw-r-- 1 customer customer 21M Jul 16 07:35 Image -rw-rw-r-- 1 customer customer 1.6M Jul 16 07:35 boot-common.bin -rw-rw-r-- 1 customer customer 41M Jul 16 07:35 nominal-image-leopard-dpu.rootfs.cpio.gz.u-boot -rw-rw-r-- 1 customer customer 39K Jul 16 07:35 system.dtb- Note - Exact file size might differ a bit but they should be in the same range (for example - nominal-image-leopard-dpu.rootfs.cpio.gz.u-bootshall be about ~40MB)
- Ensure that Leopard is powered off - customer@egse-host:~$ sml power off Powering off...Success
- Open second SSH connection to EGSE Host and start - minicomto observe boot process- customer@egse-host:~$ minicom -D /dev/sml/leopard-pn1-uart- Leave this terminal open and get back to SSH connection used in previous steps. 
- Power on Leopard - customer@egse-host:~$ sml power on Powering on...Success
- Write boot firmware to DPU boot flash - customer@egse-host:~$ sml boot-flash write --nor-memory nor1 0 /var/tftp/tutorial/boot-common.bin Uploading ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00 48.6 MB/s Erasing ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00 553.3 kB/s Programming ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00 13.5 kB/s
- Power on Processing Node 1 - customer@egse-host:~$ sml pn1 power on --nor-memory nor1 Powering on processing node Node1...Success
- DPU boot process should be visible in - minicomterminal
- Log in to DPU using - rootuser- leopard login: root root@leopard:~#
- Load double UART bitstream - root@leopard:~# fpgautil -o /lib/firmware/double-uart/overlay.dtbo [ 17.334051] fpga_manager fpga0: writing double-uart/bitstream.bit.bin to Xilinx ZynqMP FPGA Manager [ 17.478795] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /fpga-full/firmware-name [ 17.488941] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /fpga-full/resets [ 17.498582] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/afi0 [ 17.508081] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/axi_uartlite_0 [ 17.518445] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/axi_uartlite_1 [ 17.532846] a0000000.serial: ttyUL0 at MMIO 0xa0000000 (irq = 45, base_baud = 0) is a uartlite [ 17.543564] uartlite a0000000.serial: Runtime PM usage count underflow! [ 17.553041] a0010000.serial: ttyUL1 at MMIO 0xa0010000 (irq = 46, base_baud = 0) is a uartlite [ 17.563853] uartlite a0010000.serial: Runtime PM usage count underflow! root@leopard:~#- Note - Despite warnings UARTs in bitstream will still function correctly 
- Verify presence of two new UART devices - root@leopard:~# ls -l /dev/ttyUL* crw-rw---- 1 root dialout 204, 187 Sep 20 11:23 /dev/ttyUL0 crw-rw---- 1 root dialout 204, 188 Sep 20 11:23 /dev/ttyUL1
- Start receiving data from - /dev/ttyUL0in background- root@leopard:~# cat /dev/ttyUL0 &- catprocess will be running in background allowing you to enter another command in the same terminal. Output from- cat(data received from UART) and your commands will mix in terminal.
- Write something to second UART: - root@leopard:~# echo "Hello from UART1" > /dev/ttyUL1 Hello from UART1 root@leopard:~#- Text - Hello from UART1is coming from- catrunning in background.
Summary¶
In this tutorial, you enabled usage of Programmable Logic part of Zynq UltraScale+ device. As an example, you added bitstream with two UARTs connected together. After rebuilding Yocto project, you used FPGA Manager to load bitstream dynamically and used newly added devices.