From 96ce2c7c7d474299169e7fe586ad854566619aa8 Mon Sep 17 00:00:00 2001
From: vauban353 <vauban353@gmail.com>
Date: Sat, 1 Jul 2023 14:37:48 +0100
Subject: [PATCH] Programming: Introduce PROG_EXPORT_PATH argument.

The PROG_EXPORT_PATH script argument should eventually replace
FPE_EXPORT_PATH to specify the location of the generated programming
files whether for FlashProExpress, programming through Linux or using
DirectC.
---
 BUILD_BVF_GATEWARE.tcl                    | 32 +++++++++++++++++++----
 script_support/export_flashproexpress.tcl |  4 +--
 script_support/export_spi_prog_file.tcl   |  4 +--
 3 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/BUILD_BVF_GATEWARE.tcl b/BUILD_BVF_GATEWARE.tcl
index ec63c54..963a974 100644
--- a/BUILD_BVF_GATEWARE.tcl
+++ b/BUILD_BVF_GATEWARE.tcl
@@ -54,6 +54,18 @@ set constraint_path ./script_support/constraints
 set project_name "BVF_GATEWARE_025T"
 #set top_level_name BVF_GATEWARE
 
+if {[info exists PROG_EXPORT_PATH]} {
+    set prog_export_path $PROG_EXPORT_PATH/bitstream
+} else {
+    set prog_export_path $local_dir/bitstream
+}
+
+if {[info exists FPE_EXPORT_PATH]} {
+    set fpe_export_path $FPE_EXPORT_PATH
+} else {
+    set fpe_export_path $prog_export_path/FlashProExpress
+}
+
 if {[info exists TOP_LEVEL_NAME]} {
     set top_level_name $TOP_LEVEL_NAME
 } else {
@@ -237,6 +249,10 @@ derive_constraints_sdc
 #
 # // Run the design flow and add eNVM clients if required
 #
+file mkdir $prog_export_path
+file mkdir $prog_export_path/FlashProExpress
+file mkdir $prog_export_path/LinuxProgramming
+file mkdir $prog_export_path/DirectC
 
 if !{[info exists ONLY_CREATE_DESIGN]} {
     run_tool -name {SYNTHESIZE}
@@ -246,14 +262,20 @@ if !{[info exists ONLY_CREATE_DESIGN]} {
         create_eNVM_config "$local_dir/script_support/components/MSS/ENVM.cfg" "$HSS_IMAGE_PATH"
         run_tool -name {GENERATEPROGRAMMINGDATA}
         configure_envm -cfg_file {script_support/components/MSS/ENVM.cfg}
+        source ./script_support/export_spi_prog_file.tcl
+#       configure_spiflash -cfg_file {./script_support/spiflash.cfg} 
+        run_tool -name {GENERATEPROGRAMMINGFILE} 
+#       run_tool -name {GENERATE_SPI_FLASH_IMAGE} 
+        source ./script_support/export_flashproexpress.tcl
     } else {
         run_tool -name {GENERATEPROGRAMMINGDATA}
+        puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+        puts "!!!              No Hart Software Services (HSS) image provided.             !!!"
+        puts "!!! Make sure this is what you were planning. If so, you know what you are   !!!"
+        puts "!!! doing: Open the Libero project to generate the design's programming      !!!"
+        puts "!!! bitstream flavor you need.                                               !!!"
+        puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
     }
-    source ./script_support/export_spi_prog_file.tcl
-    configure_spiflash -cfg_file {./script_support/spiflash.cfg} 
-    run_tool -name {GENERATEPROGRAMMINGFILE} 
-#    run_tool -name {GENERATE_SPI_FLASH_IMAGE} 
-    source ./script_support/export_flashproexpress.tcl
 } 
 
 save_project 
diff --git a/script_support/export_flashproexpress.tcl b/script_support/export_flashproexpress.tcl
index 2d9e94b..b1d18bc 100644
--- a/script_support/export_flashproexpress.tcl
+++ b/script_support/export_flashproexpress.tcl
@@ -2,9 +2,9 @@
 
 export_prog_job \
          -job_file_name ${top_level_name} \
-         -export_dir $FPE_EXPORT_PATH \
+         -export_dir $fpe_export_path \
          -bitstream_file_type {TRUSTED_FACILITY} \
-         -bitstream_file_components {ENVM FABRIC_SNVM} \
+         -bitstream_file_components {FABRIC SNVM ENVM} \
          -zeroization_likenew_action 0 \
          -zeroization_unrecoverable_action 0 \
          -program_design 1 \
diff --git a/script_support/export_spi_prog_file.tcl b/script_support/export_spi_prog_file.tcl
index 08c72f7..3b13a3c 100644
--- a/script_support/export_spi_prog_file.tcl
+++ b/script_support/export_spi_prog_file.tcl
@@ -1,6 +1,6 @@
 export_bitstream_file \
-         -file_name ${top_level_name} \
-         -export_dir $FPE_EXPORT_PATH/../LinuxProgramming \
+         -file_name {mpfs_bitstream} \
+         -export_dir $prog_export_path/LinuxProgramming \
          -format {SPI} \
          -for_ihp 0 \
          -limit_SVF_file_size 0 \
-- 
GitLab