Pynq Troubles: PS7, Hello World, and the Pain to get There

Recently I’ve started to do some work on my PYNQ-Z1 FPGA. It’s a small toy intended for enthusiasts, as well as researchers interested in FPGAs. It uses the unique Zynq chipset, adding 2 ARM cores along with a PL. To use it as an FPGA, there are really a few simple steps. First, grab the [PYNQ][ https://github.com/Xilinx/PYNQ ] git repo and find the board files. Then import them into vivado by manually copying them into the boards directory. Create your project, and you should be good to go…If you’re only planning to use the PL by itself. I came across an issue where the PS FCLKs were not working. The solution was simple: initialize the subsystem by running a simple hello_world application on the xilinx sdk. This will initialize the arm cores and the PS7 system, allowing the PL to access DDR SDRAM using the AXI4 interface. However; I got this message when uploading the elf to the PYNQ board: Memory write error at 0x100000. APB AP transaction error, DAP status f0000021.

Clearly there was something I was missing. 0x100000 references DDR memory, and failed access errors indicate that the initialization process failed. On the xilinx sdk, there are run configurations that are useful to know. You can:

  1. Reset the system, clearing the FPGA fabric
  2. Program the FPGA before running the elf file
  3. Run ps7_init, initializing the Processing Subsystem (PS)
  4. run ps7_post_config, enabling level shifters from PL to PS.

I tried taking out PS7_init to see if I could upload the elf file. The upload failed, but it gave an important error messags: the DDR memory was held in reset. So ps7_init is an essential file that tells the system to initialize. But what does it contain? mostly mask_write commands. But one thing to note is that this file exists in the zynq hw platform directory. Because the PYNQ platform does not natively exist, you have to create your own ps7_init file and send it to the xilinx sdk, because the configurations are incompatable with each other.

So how do I do that?

To use the clocks generated by the PS, Vivado includes a PS7 Wizard that allows you to customize the system to your liking, as well as calibrate its constraints. Additionally, you can apply a tcl script that calibrates the system to work with your board. Digilent, the PYNQ manufacturer, provides this script on their website. After applying the configuration, a PS7_init.tcl will show up in <PROJECT_NAME>ip_userfiles/mem_init_files. This init script is the one required on the Xilinx sdk. After correctly setting up the path, the hello world application should compile and run, enabling PS/PL communication on the FPGA side. happy hacking!