From cc6621a6d7a9ef30e95fbf13e9f7fa425798e705 Mon Sep 17 00:00:00 2001
From: vauban353 <vauban353@gmail.com>
Date: Sun, 11 Jun 2023 21:37:40 +0100
Subject: [PATCH 1/2] Programming: Add SPI flash programming file generation.

---
 BUILD_BVF_GATEWARE.tcl                  |  3 +++
 script_support/export_spi_prog_file.tcl | 35 +++++++++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 script_support/export_spi_prog_file.tcl

diff --git a/BUILD_BVF_GATEWARE.tcl b/BUILD_BVF_GATEWARE.tcl
index 9b74822..ec63c54 100644
--- a/BUILD_BVF_GATEWARE.tcl
+++ b/BUILD_BVF_GATEWARE.tcl
@@ -249,7 +249,10 @@ if !{[info exists ONLY_CREATE_DESIGN]} {
     } else {
         run_tool -name {GENERATEPROGRAMMINGDATA}
     }
+    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
 } 
 
diff --git a/script_support/export_spi_prog_file.tcl b/script_support/export_spi_prog_file.tcl
new file mode 100644
index 0000000..08c72f7
--- /dev/null
+++ b/script_support/export_spi_prog_file.tcl
@@ -0,0 +1,35 @@
+export_bitstream_file \
+         -file_name ${top_level_name} \
+         -export_dir $FPE_EXPORT_PATH/../LinuxProgramming \
+         -format {SPI} \
+         -for_ihp 0 \
+         -limit_SVF_file_size 0 \
+         -limit_SVF_file_by_max_filesize_or_vectors {} \
+         -svf_max_filesize {} \
+         -svf_max_vectors {} \
+         -master_file 0 \
+         -master_file_components {} \
+         -encrypted_uek1_file 0 \
+         -encrypted_uek1_file_components {} \
+         -encrypted_uek2_file 0 \
+         -encrypted_uek2_file_components {} \
+         -trusted_facility_file 1 \
+         -trusted_facility_file_components {FABRIC SNVM ENVM} \
+         -zeroization_likenew_action 0 \
+         -zeroization_unrecoverable_action 0 \
+         -master_backlevel_bypass 0 \
+         -uek1_backlevel_bypass 0 \
+         -uek2_backlevel_bypass 0 \
+         -master_include_plaintext_passkey 0 \
+         -uek1_include_plaintext_passkey 0 \
+         -uek2_include_plaintext_passkey 0 \
+         -sanitize_snvm 0 \
+         -sanitize_envm 0 \
+         -trusted_facility_keep_fabric_operational 0 \
+         -trusted_facility_skip_startup_seq 0 \
+         -uek1_keep_fabric_operational 0 \
+         -uek1_skip_startup_seq 0 \
+         -uek1_high_water_mark {} \
+         -uek2_keep_fabric_operational 0 \
+         -uek2_skip_startup_seq 0 \
+         -uek2_high_water_mark {} 
-- 
GitLab


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 2/2] 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