andrewm@58: #!/bin/bash andrewm@58: # andrewm@58: # This script copies the core BeagleRT files to the BeagleBone Black andrewm@58: # in preparation for building projects. It will remove any existing andrewm@58: # BeagleRT directory before copying the files over andrewm@58: andrewm@58: BBB_ADDRESS="root@192.168.7.2" andrewm@58: BBB_PATH="~/BeagleRT" andrewm@58: andrewm@58: function usage andrewm@58: { andrewm@58: THIS_SCRIPT=`basename "$0"` andrewm@58: echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone]" andrewm@58: andrewm@58: echo " andrewm@58: This script copies the core BeagleRT files to the BeagleBone, REMOVING andrewm@58: any previous files found at that location. This should be done before andrewm@58: running any of the other build scripts in this directory. The -b option andrewm@58: changes the default path, which is otherwise $BBB_PATH." andrewm@58: } andrewm@58: andrewm@58: OPTIND=1 andrewm@58: andrewm@58: while getopts "b:h" opt; do andrewm@58: case $opt in andrewm@58: b) BBB_PATH=$OPTARG andrewm@58: ;; andrewm@58: h|\?) usage andrewm@58: exit 1 andrewm@58: esac andrewm@58: done andrewm@58: andrewm@58: echo "Copying BeagleRT core files to $BBB_PATH" andrewm@58: andrewm@58: shift $((OPTIND-1)) andrewm@58: andrewm@58: # Find location of this script so we can locate the rest of the files andrewm@58: SCRIPTPATH=$(readlink -f "$0") andrewm@58: SCRIPTDIR=$(dirname "$SCRIPTPATH") andrewm@58: andrewm@58: read -p "Warning: this script will DELETE any existing BeagleRT files from your BeagleBone! Continue? " -n 1 -r andrewm@58: echo giuliomoro@83: if [[ $REPLY = y ]] andrewm@58: then andrewm@58: # Stop BeagleRT if running and remove all files andrewm@58: echo "Stopping BeagleRT and removing old files." giuliomoro@85: ssh $BBB_ADDRESS "screen -X -S BeagleRT quit &>/dev/null; pkill BeagleRT; sleep 0.5 ; rm -rf $BBB_PATH ; mkdir $BBB_PATH" andrewm@58: andrewm@58: # Copy relevant files to BeagleBone Black andrewm@58: echo "Copying new files to BeagleBone..." andrewm@58: scp -r $SCRIPTDIR/../core $SCRIPTDIR/../include $SCRIPTDIR/../Makefile $SCRIPTDIR/../libNE10.a $SCRIPTDIR/../libprussdrv.a $BBB_ADDRESS:$BBB_PATH andrewm@58: giuliomoro@64: if [ $? -ne 0 ] giuliomoro@64: then giuliomoro@64: echo "Error while copying files" giuliomoro@64: exit giuliomoro@64: fi andrewm@58: # Make remaining directories needed for building andrewm@58: echo "Creating directory structure on BeagleBone..." giuliomoro@64: ssh $BBB_ADDRESS "mkdir -p $BBB_PATH/source ; mkdir -p $BBB_PATH/build ; mkdir -p $BBB_PATH/build/core ; mkdir -p $BBB_PATH/build/source" &&\ andrewm@58: echo "Done." giuliomoro@83: else giuliomoro@83: echo "Aborting..." andrewm@58: fi andrewm@58: