63 lines
3.3 KiB
Tcl
63 lines
3.3 KiB
Tcl
# Template: Steps 4+5 - Connect hardware, configure cfgmem, and program Flash
|
|
# Called by program_flash.py via: vivado -mode batch -source step4_5_program.tcl -tclargs <flash_part> <bit_file> <mcs_file> <ltx_file>
|
|
#
|
|
# Arguments (passed via -tclargs):
|
|
# argv[0] = FLASH_PART - Flash part name, e.g. w25q128bv-spi-x1_x2_x4
|
|
# argv[1] = BIT_FILE_PATH - Full path to the .bit file
|
|
# argv[2] = MCS_FILE_PATH - Full path to the .mcs file
|
|
# argv[3] = LTX_FILE_PATH - Full path to .ltx file, or empty string "" if no ILA
|
|
#
|
|
# Success indicator: output contains "End of startup status: HIGH" and no ERROR lines
|
|
|
|
set flash_part [lindex $argv 0]
|
|
set bit_file [lindex $argv 1]
|
|
set mcs_file [lindex $argv 2]
|
|
set ltx_file [lindex $argv 3]
|
|
set has_ltx [expr {$ltx_file ne ""}]
|
|
|
|
open_hw
|
|
connect_hw_server
|
|
open_hw_target
|
|
|
|
set_property PROGRAM.FILE $bit_file [get_hw_devices xc7a200t_0]
|
|
if {$has_ltx} {
|
|
set_property PROBES.FILE $ltx_file [get_hw_devices xc7a200t_0]
|
|
set_property FULL_PROBES.FILE $ltx_file [get_hw_devices xc7a200t_0]
|
|
}
|
|
current_hw_device [get_hw_devices xc7a200t_0]
|
|
refresh_hw_device [lindex [get_hw_devices xc7a200t_0] 0]
|
|
|
|
create_hw_cfgmem -hw_device [lindex [get_hw_devices xc7a200t_0] 0] \
|
|
[lindex [get_cfgmem_parts $flash_part] 0]
|
|
set_property PROGRAM.BLANK_CHECK 0 [get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a200t_0] 0]]
|
|
set_property PROGRAM.ERASE 1 [get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a200t_0] 0]]
|
|
set_property PROGRAM.CFG_PROGRAM 1 [get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a200t_0] 0]]
|
|
set_property PROGRAM.VERIFY 1 [get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a200t_0] 0]]
|
|
set_property PROGRAM.CHECKSUM 0 [get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a200t_0] 0]]
|
|
set_property PROGRAM.FILES [list $mcs_file] \
|
|
[get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a200t_0] 0]]
|
|
refresh_hw_device [lindex [get_hw_devices xc7a200t_0] 0]
|
|
|
|
# --- CRITICAL: load Vivado's flash-loader bitstream into the FPGA FIRST so it
|
|
# bridges JTAG<->SPI flash and takes over the SPI bus. Without this, the user
|
|
# design (or boot image) holds the SPI pins and the flash read returns
|
|
# "Mfg ID : 0 / Unable to read device properties" (program fails silently).
|
|
# This is exactly what the Vivado GUI "Program Configuration Memory Device"
|
|
# does under the hood before program_hw_cfgmem. ---
|
|
set loader_bit [get_property PROGRAM.HW_CFGMEM_BITFILE [lindex [get_hw_devices xc7a200t_0] 0]]
|
|
create_hw_bitstream -hw_device [lindex [get_hw_devices xc7a200t_0] 0] $loader_bit
|
|
program_hw_devices [lindex [get_hw_devices xc7a200t_0] 0]
|
|
|
|
# Erase + program + verify the SPI flash (this is the actual flash write).
|
|
program_hw_cfgmem -hw_cfgmem [get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a200t_0] 0]]
|
|
|
|
# Optionally reload the user bit + probes so the device runs the design (with ILA)
|
|
# after flashing. A power-cycle will boot the same content from flash.
|
|
if {$has_ltx} {
|
|
set_property PROBES.FILE $ltx_file [get_hw_devices xc7a200t_0]
|
|
set_property FULL_PROBES.FILE $ltx_file [get_hw_devices xc7a200t_0]
|
|
}
|
|
set_property PROGRAM.FILE $bit_file [get_hw_devices xc7a200t_0]
|
|
program_hw_devices [get_hw_devices xc7a200t_0]
|
|
refresh_hw_device [lindex [get_hw_devices xc7a200t_0] 0]
|