Skip to content

Commit

Permalink
Merge pull request #116 from sealne/download-prebuilt
Browse files Browse the repository at this point in the history
Download prebuilt .bit and .hex files from https://github.com/timvideos/HDMI2USB-firmware-prebuilt/
  • Loading branch information
mithro committed Jan 26, 2016
2 parents f8fb036 + cb96670 commit 2cff76e
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis/run.sh
Expand Up @@ -123,7 +123,7 @@ for BOARD in $BOARDS; do
# Not currently built so use .bit instead
#cp ../third_party/misoc/build/*.xsvf $COPY_DEST
cp ../third_party/misoc/build/*.bit $COPY_DEST
cp ../build/output.*.log $COPY_DEST
cp ../build/output.*.log $COPY_DEST/output.log
echo ""
echo "- Uploading .bit and logfile"
# Only hdmi2usb is considered usable just now
Expand Down
11 changes: 10 additions & 1 deletion Makefile
Expand Up @@ -60,6 +60,7 @@ help:
@echo " make all"
@echo " make gateware"
@echo " make firmware"
@echo " make download-prebuilt"
@echo " make load"
@echo " make flash"
@for T in $(TARGETS); do make -s help-$$T; done
Expand Down Expand Up @@ -99,6 +100,10 @@ gateware: gateware-generate gateware-build
firmware: $(addprefix firmware-,$(TARGETS))
@true

# Download pre-built firmware
download-prebuilt:
scripts/download-prebuilt.sh

# Load
load-gateware:
cd $(MSCDIR) && $(CMD) load-bitstream
Expand All @@ -123,6 +128,10 @@ clean:
touch $(MSCDIR)/software/include/generated/.keep_me)
# Cleanup Python3's __pycache__ directories
find . -name __pycache__ -type d -exec rm -r {} +
# Delete any previously downloaded pre-built firmware
rm -rf build/prebuilt
rm -f third_party/misoc/build/*.bit
rm -f firmware/fx2/hdmi2usb.hex

.DEFAULT_GOAL := help
.PHONY: all load-gateware load flash gateware firmware third_party/*
.PHONY: all load-gateware load flash gateware firmware download-prebuilt third_party/*
83 changes: 83 additions & 0 deletions scripts/download-prebuilt.sh
@@ -0,0 +1,83 @@
#!/bin/bash

set -e

SETUP_SRC=$(realpath ${BASH_SOURCE[@]})
SETUP_DIR=$(dirname $SETUP_SRC)
TOP_DIR=$(realpath $SETUP_DIR/..)
BUILD_DIR=$TOP_DIR/build
PREBUILT_DIR=$BUILD_DIR/prebuilt

if [ ! -e $BUILD_DIR ]; then
echo "$BUILD_DIR does not exist so it looks like the prerequisite tools may not be available"
echo "They can be installed by running scripts/get-env-root.sh and scripts/get-env.sh"
exit 1
fi

CURRENT_GIT_REVISION=$(git describe)

: ${BOARD:="atlys"}
: ${TARGET:="hdmi2usb"}
: ${PREBUILT_RELEASE:=$CURRENT_GIT_REVISION}
: ${PREBUILT_REPO:="timvideos/HDMI2USB-firmware-prebuilt"}


if [ "$TARGET" = "hdmi2usb" ]; then
GATEWARE="${BOARD}_hdmi2usb-hdmi2usbsoc-${BOARD}.bit"
elif [ "$TARGET" = "base" ]; then
GATEWARE="${BOARD}_base-basesoc-${BOARD}.bit"
fi

FIRMWARE="hdmi2usb.hex"

GATEWARE_DIR="$TOP_DIR/third_party/misoc/build"
FIRMWARE_DIR="$TOP_DIR/firmware/fx2"

# Check nothing exists before we start
if [ -e $GATEWARE_DIR/$GATEWARE -o -e $FIRMWARE_DIR/$FIRMWARE ]; then
echo ""
echo "It looks like a build has been run before"
echo "Run make clean then try again"
echo ""
exit 1
elif [ -e $PREBUILT_DIR ]; then
echo ""
echo "It looks like a download has been run before"
echo "Run make clean then try again"
echo ""
exit 1
fi

BASE_URL="https://github.com/${PREBUILT_REPO}/raw/master/archive/${PREBUILT_RELEASE}/${BOARD}/${TARGET}"

SHA256SUM_FILE="sha256sum.txt"

(
mkdir $PREBUILT_DIR
cd $PREBUILT_DIR
echo ""
echo "BOARD=$BOARD TARGET=$TARGET PREBUILT_RELEASE=$PREBUILT_RELEASE"
echo "Downloading files from https://github.com/${PREBUILT_REPO} ..."
echo ""
wget -nv ${BASE_URL}/${SHA256SUM_FILE}
FILES=$(cat ${SHA256SUM_FILE}| awk -F' ' '{printf "%s ", $2}')
for f in $FILES; do
wget -nv ${BASE_URL}/${f}
done
echo ""
echo "Checking sha256sum of downloaded files ..."
sha256sum -c $SHA256SUM_FILE
# Script will exit if sums don't match after sha256sum command above
echo ""
echo "Copying files to correct locations ..."
mkdir -p $GATEWARE_DIR
cp $GATEWARE $GATEWARE_DIR
# Not all builds generate FX2 firmware
if [ -e $FIRMWARE ]; then
mkdir -p $FIRMWARE_DIR
cp $FIRMWARE $FIRMWARE_DIR
fi
echo ""
echo "Done"
echo ""
)

0 comments on commit 2cff76e

Please sign in to comment.