#!/bin/sh # This script is used to test fpga flash functionality for Cyclone-5. FPGA_DEVICE="/dev/fpga0" if [ ! -e $FPGA_DEVICE ]; then echo "FAIL: fpga device $FPGA_DEVICE does not exist" exit 1 fi echo "PASS: fpga device $FPGA_DEVICE exists" FPGA_STAT_DIR="/sys/class/fpga/fpga0" FPGA_STAT_FILE="$FPGA_STAT_DIR/status" if [ ! -d "$FPGA_STAT_DIR" ]; then echo "FAIL: fpga status directory $FPGA_STAT_DIR does not exist" exit 1 fi echo "PASS: fpga status directory $FPGA_STAT_DIR exists" cat $FPGA_STAT_FILE if [ $? -ne 0 -o ! -s $FPGA_STAT_FILE ]; then echo "FAIL: fpga status file $FPGA_STAT_FILE unaccessible or empty" exit 1 fi echo "PASS: fpga status file $FPGA_STAT_FILE has content" FPGA_BRIDGE_DIR="/sys/class/fpga-bridge" if [ ! -d "$FPGA_BRIDGE_DIR" ]; then echo "FAIL: fpga bridge directory $FPGA_BRIDGE_DIR does not exist" exit 1 fi echo "PASS: fpga status bridge $FPGA_BRIDGE_DIR exists" FPGA_BR2HPS_FILE="$FPGA_BRIDGE_DIR/fpga2hps/enable" FPGA_BR2FPGA_FILE="$FPGA_BRIDGE_DIR/fpga2hps/enable" FPGA_BR2LWHPS_FILE="$FPGA_BRIDGE_DIR/lwhps2fpga/enable" cat $FPGA_BR2HPS_FILE if [ $? -ne 0 -o ! -s $FPGA_BR2HPS_FILE ]; then echo "FAIL: fpga bridge file $FPGA_BR2HPS_FILE unaccessible or empty" exit 1 fi echo "PASS: fpga bridge file $FPGA_BR2HPS_FILE has content" cat $FPGA_BR2FPGA_FILE if [ $? -ne 0 -o ! -s $FPGA_BR2FPGA_FILE ]; then echo "FAIL: fpga bridge file $FPGA_BR2FPGA_FILE unaccessible or empty" exit 1 fi echo "PASS: fpga bridge file $FPGA_BR2FPGA_FILE has content" cat $FPGA_BR2LWHPS_FILE if [ $? -ne 0 -o ! -s $FPGA_BR2LWHPS_FILE ]; then echo "FAIL: fpga bridge file $FPGA_BR2LWHPS_FILE unaccessible or empty" exit 1 fi echo "PASS: fpga bridge file $FPGA_BR2LWHPS_FILE has content" DD_CMD=`which dd` if [ "x$DD_CMD" != "x" ]; then echo "PASS: fpga dd tool found" else echo "FAIL: fpga dd tool not found" exit 1 fi SD_MMC_PARTITION="/dev/mmcblk0p1" MOUNT_DIR="/mnt/mmc2" FILE_TO_COPY="$MOUNT_DIR/soc_system.rbf" umount $MOUNT_DIR &> /dev/null rmdir $MOUNT_DIR &> /dev/null mkdir $MOUNT_DIR mount $SD_MMC_PARTITION $MOUNT_DIR if [ ! -f "$FILE_TO_COPY" ]; then echo "FAIL: fpga programming file $FILE_TO_COPY does not exist" exit 1 fi echo "PASS: fpga programming file $FILE_TO_COPY found" $DD_CMD if=$FILE_TO_COPY of=$FPGA_DEVICE bs=1M if [ $? -ne 0 ]; then umount $MOUNT_DIR echo "FAIL: programming fpga device $FPGA_DEVICE fail" exit 1 fi umount $MOUNT_DIR echo "PASS: programming fpga device $FPGA_DEVICE success" echo "PASS: fpga test passed" exit 0