aboutsummaryrefslogtreecommitdiff
path: root/testing/DMAppFpgaProg/flashpro.sh
diff options
context:
space:
mode:
authorJan Sucan <sucanjan@fit.cvut.cz>2019-06-04 14:34:27 +0200
committerJan Sucan <sucanjan@fit.cvut.cz>2019-06-04 14:34:27 +0200
commitdc8703206e3f0f69605c56d0e1127f7e17f3476a (patch)
tree166823a741dc420c10d54250cb53d1e3a6b74faf /testing/DMAppFpgaProg/flashpro.sh
Initial commit
Diffstat (limited to 'testing/DMAppFpgaProg/flashpro.sh')
-rw-r--r--testing/DMAppFpgaProg/flashpro.sh51
1 files changed, 51 insertions, 0 deletions
diff --git a/testing/DMAppFpgaProg/flashpro.sh b/testing/DMAppFpgaProg/flashpro.sh
new file mode 100644
index 0000000..4bf31fa
--- /dev/null
+++ b/testing/DMAppFpgaProg/flashpro.sh
@@ -0,0 +1,51 @@
+FLASHPRO='/c/Microsemi/Program_Debug_v11.8/bin/flashpro.exe'
+
+# Execute operation with FPGA by FlashPro4 HW programmer
+#
+# Usage: flashpro ACTION STP_FILE RESULT TMPDIR
+# ACTION FlashPro action to execute
+# STP_FILE .STP file with data for the FPGA
+# RESULT expected result, 0 (success) or 1 (failure)
+# TMPDIR temporary directory for FlashPro project and script
+flashpro()
+{
+ if [ $# -ne 4 ]; then
+ echo 'flashpro_verify: ERROR: arguments' >&2
+ return 1
+ fi
+
+ project_name="flashpro_project"
+
+ action="$1"
+ stp_file="$2"
+ project_dir="$4/$project_name"
+ script_file="$4/flashpro_script"
+ log_file="$project_dir/${project_name}.log"
+ expected_result="$3"
+ [ $expected_result -ne 0 ] && expected_result=1
+
+ rm -rf "$project_dir" "$script_file"
+
+ cat << EOF > "$script_file"
+new_project -name {flashpro_project} -location {$(cygpath -a -w "$project_dir")} -mode {single}
+
+configure_flashpro4_prg -vpump {OFF}
+
+set_programming_file -file {$(cygpath -a -w "$stp_file")}
+set_programming_action -action {$action}
+run_selected_actions
+
+close_project
+EOF
+
+ "$FLASHPRO" script:"$(cygpath -a -w "$script_file")" 1>/dev/null 2>&1
+
+ if [ ! -f "$log_file" -o ! -r "$log_file" ]; then
+ return 1;
+ else
+ grep "The 'run_selected_actions' command succeeded\." "$log_file" 1>/dev/null 2>&1
+ # Convert non-zero last return value to 1
+ [ $? -eq 0 ]
+ [ $? -eq $expected_result ]
+ fi
+}