Bitstream Reconfiguration (Bare-metal)
December 2, 2015
Suppose we would like to reprogram the FPGA (PL) on bare-metal of a Zynq-based platform during run-time, but we don't want to halt the ARM processor (PS) from running other applications, what should we do? We can use PCAP drivers for this (on Linux, check 03/21/2016 Bitstream Reconfiguration (Linux)). The basic steps are:
Initializing the PCAP driver:
XDcfg_CfgInitialize(DcfgInstPtr, ConfigPtr, ConfigPtr->BaseAddr);
Writing the new bitstream into a memory location:
SD_TransferBinary(BitFile, BIT_STREAM_LOCATION);
Loading the bitstream onto PL:
XDcfg_Transfer(DcfgInstPtr, (u8 *)BIT_STREAM_LOCATION, BIT_STREAM_SIZE_WORDS, (u8 *)XDCFG_DMA_INVALID_ADDRESS, 0, XDCFG_NON_SECURE_PCAP_WRITE);
However, if I only do the above steps, I will also have to push button 6 (BTN 6) before I program the PL every time. Otherwise the bitstream cannot be fully reconfigured. If you look at the Zynq schematic, you will see pressing BTN 6 actually ties the PROGRAM_B_0 pin to the ground.
To prevent users from interacting with the PL, we usually don't want to push any button during run-time. What should we do?
The solution can be found here:
"When the BootROM begins to execute the FSBL, the contents of the PL are not always initialized. The PL contents can retain a full or partial configuration. This can be avoided by tying the PROGRAM_B signal High and having the FSBL set the PCFG_PROG_B bit High."
Hence, the work-around is to add the correct pull-down and pull-up sequence for PROGRAM_B signal during PCAP driver initialization. Also note this is a Zynq-specific issue; so this sequence can be ignored for other platforms.