Mercurial > hg > beaglert
changeset 58:3ffafa57302c newapi
Added scripts for building on board
author | andrewm |
---|---|
date | Wed, 15 Jul 2015 15:49:00 +0100 |
parents | 72726dd4f66c |
children | 5bdf6efbd0ed |
files | scripts/build_project.sh scripts/run_project.sh scripts/setup_board.sh scripts/stop_running.sh |
diffstat | 4 files changed, 178 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/build_project.sh Wed Jul 15 15:49:00 2015 +0100 @@ -0,0 +1,77 @@ +#!/bin/bash +# +# This script compiles a BeagleRT project on the BeagleBone Black and +# optionally runs it. Pass a directory path in the first argument. +# The source files in this directory are copied to the board and compiled. + +BBB_ADDRESS="root@192.168.7.2" +BBB_PATH="~/BeagleRT" +RUN_PROJECT=1 + +function usage +{ + THIS_SCRIPT=`basename "$0"` + echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [-n] <directory-with-source-files>" + echo " + This script copies a directory of source files to the BeagleBone, compiles + and runs it. The BeagleRT core files should have first been copied over + using the setup_board.sh script supplied with BeagleRT. + + The source directory should contain at least one .c, .cpp or .S file. + If the argument -n is passed, the output will not be run after compiling. + The argument -b will change the local path on the BeagleBone where the + BeagleRT files are found." +} + +OPTIND=1 + +while getopts "b:nh" opt; do + case $opt in + b) BBB_PATH=$OPTARG + ;; + n) RUN_PROJECT=0 + ;; + h|\?) usage + exit 1 + esac +done + +shift $((OPTIND-1)) + +# Check that we have a directory containing at least one source file +# as an argument +if [ -z "$1" ] +then + usage + exit +fi + +C_FILES=$(find "$1" -maxdepth 1 -type f -name "*.c") +CPP_FILES=$(find "$1" -maxdepth 1 -type f -name "*.cpp") +ASM_FILES=$(find "$1" -maxdepth 1 -type f -name "*.S") + +if [[ -z $C_FILES ]] && [[ -z $CPP_FILES ]] && [[ -z $ASM_FILES ]] +then + echo "Please provide a directory containing .c, .cpp or .S files." +# echo "Usage: $THIS_SCRIPT [directory-with-source-files]" + usage + exit +fi + +# Stop BeagleRT and clean out old source files +echo "Stopping BeagleRT and removing old source files..." +ssh -t -t $BBB_ADDRESS "kill -s 2 \`pidof BeagleRT\` 2>/dev/null; sleep 0.5; make sourceclean -C $BBB_PATH" + +# Copy new source files to the board +echo "Copying new source files to BeagleBone..." +scp "$1"/* "$BBB_ADDRESS:$BBB_PATH/source/" + +# Make new BeagleRT executable and run +if [ $RUN_PROJECT -eq 0 ] +then + echo "Building project..." + ssh $BBB_ADDRESS "make all -C $BBB_PATH" +else + echo "Building and running project..." + ssh $BBB_ADDRESS "make all -C $BBB_PATH ; screen -d -m $BBB_PATH/BeagleRT" +fi \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/run_project.sh Wed Jul 15 15:49:00 2015 +0100 @@ -0,0 +1,34 @@ +#!/bin/bash +# +# This script runs an already-compiled BeagleRT project on the +# BeagleBone Black. + +BBB_ADDRESS="root@192.168.7.2" +BBB_PATH="~/BeagleRT" + +function usage +{ + THIS_SCRIPT=`basename "$0"` + echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone]" + + echo " + This script runs a previously compiled BeagleRT project on the + BeagleBone Black. The -b option changes the default path, which + is otherwise $BBB_PATH." +} + +OPTIND=1 + +while getopts "b:h" opt; do + case $opt in + b) BBB_PATH=$OPTARG + ;; + h|\?) usage + exit 1 + esac +done + +shift $((OPTIND-1)) + +echo "Running BeagleRT..." +ssh $BBB_ADDRESS "kill -s 2 \`pidof BeagleRT\` 2>/dev/null ; sleep 0.5 ; screen -d -m $BBB_PATH/BeagleRT" \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/setup_board.sh Wed Jul 15 15:49:00 2015 +0100 @@ -0,0 +1,59 @@ +#!/bin/bash +# +# This script copies the core BeagleRT files to the BeagleBone Black +# in preparation for building projects. It will remove any existing +# BeagleRT directory before copying the files over + +BBB_ADDRESS="root@192.168.7.2" +BBB_PATH="~/BeagleRT" + +function usage +{ + THIS_SCRIPT=`basename "$0"` + echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone]" + + echo " + This script copies the core BeagleRT files to the BeagleBone, REMOVING + any previous files found at that location. This should be done before + running any of the other build scripts in this directory. The -b option + changes the default path, which is otherwise $BBB_PATH." +} + +OPTIND=1 + +while getopts "b:h" opt; do + case $opt in + b) BBB_PATH=$OPTARG + ;; + h|\?) usage + exit 1 + esac +done + +echo "Copying BeagleRT core files to $BBB_PATH" + +shift $((OPTIND-1)) + +# Find location of this script so we can locate the rest of the files +SCRIPTPATH=$(readlink -f "$0") +SCRIPTDIR=$(dirname "$SCRIPTPATH") + +read -p "Warning: this script will DELETE any existing BeagleRT files from your BeagleBone! Continue? " -n 1 -r +echo +if [[ $REPLY =~ ^[Yy]$ ]] +then +# Stop BeagleRT if running and remove all files + echo "Stopping BeagleRT and removing old files." + ssh $BBB_ADDRESS "kill -s 2 \`pidof BeagleRT\` 2>/dev/null ; sleep 0.5 ; rm -rf $BBB_PATH ; mkdir $BBB_PATH" + +# Copy relevant files to BeagleBone Black + echo "Copying new files to BeagleBone..." + scp -r $SCRIPTDIR/../core $SCRIPTDIR/../include $SCRIPTDIR/../Makefile $SCRIPTDIR/../libNE10.a $SCRIPTDIR/../libprussdrv.a $BBB_ADDRESS:$BBB_PATH + +# Make remaining directories needed for building + echo "Creating directory structure on BeagleBone..." + ssh $BBB_ADDRESS "mkdir $BBB_PATH/source ; mkdir $BBB_PATH/build ; mkdir $BBB_PATH/build/core ; mkdir $BBB_PATH/build/source" + + echo "Done." +fi +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/stop_running.sh Wed Jul 15 15:49:00 2015 +0100 @@ -0,0 +1,8 @@ +#!/bin/bash +# +# This script stops the BeagleRT program running on the BeagleBone. + +BBB_ADDRESS="root@192.168.7.2" + +echo "Stopping BeagleRT..." +ssh $BBB_ADDRESS "kill -s 2 \`pidof BeagleRT\` 2>/dev/null" \ No newline at end of file