set device xc7z035_1
set BOOT_file ./output/BOOT.bin
set FSBL_file ./output/zynq_fsbl.elf

open_hw_manager
connect_hw_server -allow_non_jtag
open_hw_target
current_hw_device [get_hw_devices $device]
refresh_hw_device -update_hw_probes false [lindex [get_hw_devices $device] 0]
create_hw_cfgmem -hw_device [lindex [get_hw_devices $device] 0] [lindex [get_cfgmem_parts {mt25ql256-qspi-x8-dual_parallel}] 0]

set_property PROGRAM.BLANK_CHECK    0                   [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices $device] 0]]
set_property PROGRAM.ERASE          1                   [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices $device] 0]]
set_property PROGRAM.CFG_PROGRAM    1                   [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices $device] 0]]
set_property PROGRAM.VERIFY         0                   [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices $device] 0]]
set_property PROGRAM.CHECKSUM       0                   [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices $device] 0]]
set_property PROGRAM.ADDRESS_RANGE  {use_file}          [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices $device] 0]]
set_property PROGRAM.FILES          [list "$BOOT_file"] [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices $device] 0]]
set_property PROGRAM.BIN_OFFSET     {0}                 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices $device] 0]]
set_property PROGRAM.ZYNQ_FSBL      ${FSBL_file}        [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices $device] 0]]
program_hw_cfgmem -hw_cfgmem                            [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices $device] 0]]
puts "Finished loading the QPSI memory, DO NOT FORGET TO RESET (POR)!"
