olofk / fusesoc

Package manager and build abstraction tool for FPGA/ASIC development
BSD 2-Clause "Simplified" License
1.14k stars 235 forks source link

fusesoc export xsa file #656

Closed isomoye closed 5 months ago

isomoye commented 6 months ago

I usually build petalinux after generating hardware. right now fusesoc only exports the bitstream which means i need to open up the project later on and export the full xsa. Would we be able to just add the xsa export too.

olofk commented 6 months ago

I think the easiest way is to add some tcl script that does the xsa export. You can add custom tcl files by setting file_type : tclSource. Now, the trick is to make sure the tcl script is executed at the right time. I'm not familiar with xsa in particular, but generally speaking there are two options here. Either, it's just a property that you set for the project, and then you will get your xsa file, or it's an extra command that needs to be run at the right point. For the latter, which I suspect is the case here, you would need to define a script hook in your custom TCL script so that Vivado will pick it up at the right time. Let me see if I can find some example of that.

garankonic commented 5 months ago

In the top-level project, you can create a dedicated target which build xsa (without bitstream):

filesets:
   xsa:
        files:
          - scripts/export_xsa.tcl: { file_type: tclSource }
targets:
    xsa_target:
        toplevel: your_toplevel
        filesets:
          - xsa
        flow: vivado
        flow_options:
          part: your_part
          source_mgmt_mode: All
          jobs: 1

In this way XSA script will be the last one to execute. The script itself looks as follows:

# switches to vhdl top-level
set_property target_language VHDL [current_project]
# generate output products
generate_target all [get_files *.bd]
# export xsa
write_hw_platform -fixed -force -file file.xsa
isomoye commented 5 months ago

This solution worked. Thansk @garankonic . closing issue.