Skip to content

Commit

Permalink
Merge pull request #340 from mithro/download-prebuilt-fix
Browse files Browse the repository at this point in the history
Fix the download-prebuilt script.
  • Loading branch information
mithro committed Aug 11, 2017
2 parents cd36c1a + f212ba8 commit 4242bb5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 57 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ tftpd_start:
flash: image-flash
@true

info:
@echo "TARGET='$(TARGET)'"
@echo "PLATFORM='$(PLATFORM)'"
@echo "FULL_PLATFORM='$(FULL_PLATFORM)'"
@echo "CPU='$(CPU)'"
@echo "TARGET_BUILD_DIR='$(TARGET_BUILD_DIR)'"

help:
@echo "Environment:"
@echo " PLATFORM=$(shell ls targets/ | grep -v ".py" | grep -v "common" | sed -e"s+targets/++" -e's/$$/ OR/')" | sed -e's/ OR$$//'
Expand Down
94 changes: 37 additions & 57 deletions scripts/download-prebuilt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,70 +14,50 @@ if [ ! -e $BUILD_DIR ]; then
exit 1
fi

CURRENT_GIT_REVISION=$(git symbolic-ref --short HEAD)/$(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"
if [ -z "$HDMI2USB_ENV" ]; then
echo "You appear to have not sourced the HDMI2USB settings."
echo "Please run '. $SETUP_DIR/enter-env.sh' before running this script."
exit 1
fi

FIRMWARE="hdmi2usb.hex"
GITHUB_URL=https://github.com/timvideos/HDMI2USB-firmware-prebuilt/

GATEWARE_DIR="$TOP_DIR/third_party/misoc/build"
FIRMWARE_DIR="$TOP_DIR/firmware/fx2"
UPSTREAM_BRANCH=master
UPSTREAM_REMOTE=$(git remote -v | grep fetch | grep 'github.com/timvideos' | sed -e's/\t.*$//')
#UPSTREAM_GITREV=$(git merge-base $UPSTREAM_REMOTE/$UPSTREAM_BRANCH HEAD)
UPSTREAM_GITREV=$(git show-branch --merge-base $UPSTREAM_REMOTE/$UPSTREAM_BRANCH HEAD)
UPSTREAM_GITDESC=$(git describe $UPSTREAM_GITREV)
eval $(make info)

# 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}"
: ${PREBUILT_REPO:="timvideos/HDMI2USB-firmware-prebuilt"}
echo " Prebuilt Repository: $PREBUILT_REPO"
echo ""
echo " Upstream remote: $UPSTREAM_REMOTE"
echo " Upstream branch: $UPSTREAM_BRANCH"
echo " Upstream git rev: $UPSTREAM_GITREV"
echo " Upstream git describe: $UPSTREAM_GITDESC"
echo ""
echo " Platform: $PLATFORM"
echo " Target: $TARGET"
echo " CPU: $CPU"
echo ""
echo
DOWNLOAD_URL="$GITHUB_URL/trunk/archive/$UPSTREAM_BRANCH/$UPSTREAM_GITDESC/$PLATFORM/$TARGET/$CPU/"
echo "Downloading"
echo " from '$DOWNLOAD_URL'"
echo " to '$TARGET_BUILD_DIR'"
echo "---------------------------------------"
# archive/master/v0.0.3-696-g2f815c1/minispartan6/base/lm32
svn export --force $DOWNLOAD_URL $TARGET_BUILD_DIR | grep -v "^Export"

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} ..."
cd $TARGET_BUILD_DIR
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 ..."
echo "Checking sha256sum of downloaded files in '$TARGET_BUILD_DIR'..."
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 ""
)

echo ""
echo "Done"
echo ""

0 comments on commit 4242bb5

Please sign in to comment.