Jump to content
  • 0

Dynamically load bitstream on Petalinux


malkauns

Question

I have a Zybo Z7 board I want to be able to dynamically load my .bit file after the system has booted.  I am using petalinux-v2017.4-final-installer.run.  In earlier versions I was able to do: cat file.bit > /dev/xdevcfg to have the bitstream loaded into the FPGA.  However, /dev/xdevcfg does not exist for me.  Is there something I have to configure when building the project and configuring the kernel to get this device to show up or is there some other way that I should be doing this?

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

So it looks like /dev/xdevcfg is deprecated and /sys/class/fpga_manager/fpga0/firmware should be used instead.  However, after configuring Vivado to generate a .bin file I get the following error when trying to load the bitstream:

root@Zybo-Z7-20:~# cd /run/media/mmcblk0p2
root@Zybo-Z7-20:/run/media/mmcblk0p2# 
root@Zybo-Z7-20:/run/media/mmcblk0p2# mkdir /lib/firmware
root@Zybo-Z7-20:/run/media/mmcblk0p2# cp system_wrapper.bin /lib/firmware/
root@Zybo-Z7-20:/run/media/mmcblk0p2# echo system_wrapper.bin > /sys/class/fpga_manager/fpga0/firmware
fpga_manager fpga0: writing system_wrapper.bin to Xilinx Zynq FPGA Manager
fpga_manager fpga0: Invalid bitstream, could not find a sync word. Bitstream must be a byte swapped .bin file
fpga_manager fpga0: Error preparing FPGA for writing
-sh: echo: write error: Invalid argument

 

I read about using write_cfgmem to create a byte swapped bin file and tried the following TCL command in vivado:

write_cfgmem -format bin -loadbit "up 0x0 /path/to/bit/file/system_wrapper.bit" out.bin 

 

When trying to load the bitstream it results in the same error above.  How do I create a valid "byte swapped .bin file"?  Is there something wrong with my TCL command?

Link to comment
Share on other sites

I can only get /dev/xdevcfg if I change "1496c680c6df2e3911feed13aa9663a851bf30e9" under Linux Components Selection -> Remote linux-kernel settings -> Remote Linux-kernel git TAG/Commit ID to "master".  But then I lose /dev/media0 for the camera.  Please advise.

Link to comment
Share on other sites

Ah, I apologize... the Zybo-Z7 20 project is actually unique... While it is a 2017.4 it uses a 2018.2 kernel for Pcam support and the 2018.2 kernel has the FPGA manager as you said.

This page talks about swapping bytes and also references Xilinx's documentation on the FPGA manager

The Xilinx documentation doesn't mention byte swapping, but the section is called "Generating .bin from .bit file using Bootgen"

Link to comment
Share on other sites

Ok, I know its been long but I'm finally resuming this project.  I generated a bitstream (.bit file) and want to create a .bin so that I can dynamically load it.  However, when trying to convert it to a .bin file I get the following error:

 

/opt/pkg/petalinux/tools/hsm/bin/bootgen -image system_wrapper.bit -arch zynq -process_bitstream bin
WARNING: bad character! '' (0x00)
WARNING: bad character! '' (0x0F)
WARNING: bad character! '�' (0xFFFFFFF0)
WARNING: bad character! '' (0x0F)
WARNING: bad character! '�' (0xFFFFFFF0)
WARNING: bad character! '' (0x0F)
WARNING: bad character! '�' (0xFFFFFFF0)
WARNING: bad character! '' (0x0F)
WARNING: bad character! '�' (0xFFFFFFF0)
WARNING: bad character! '' (0x00)
WARNING: bad character! '' (0x00)
WARNING: bad character! '' (0x01)
WARNING: bad character! '' (0x00)

ERROR:BootGen - syntax error
   Line #1, "system_wrapper.bit".
... ���a0system_wrapper;UserID=0XFFFFFFFF;Version=2018.2b
                                                         7z010cl
              ^^^^^^^^^^^^^^^^

 

Please advise on how to properly convert from .bit to .bin.

Link to comment
Share on other sites

On 1/29/2020 at 6:02 AM, Cosmin said:

Hello, malkauns.

 

We built a small set of tools some time ago to handle dynamic generation and loading of bitstream files.

Check it out at https://github.com/Digilent/zynq-dynamic-tools.

 

Cosmin.

Thanks, I was able to create a bin file using "zynq" as the architecture argument.  Judging by the script its the only option anyway.  I'll try it out tonight on the hardware to see if it works.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...