andrewm@58
|
1 #!/bin/bash
|
andrewm@58
|
2 #
|
giuliomoro@377
|
3 # This script copies the core Bela files to the BeagleBone Black
|
andrewm@58
|
4 # in preparation for building projects. It will remove any existing
|
giuliomoro@377
|
5 # Bela directory before copying the files over
|
andrewm@58
|
6
|
giuliomoro@367
|
7 [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2"
|
giuliomoro@377
|
8 [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/Bela/"
|
andrewm@58
|
9 function usage
|
andrewm@58
|
10 {
|
andrewm@58
|
11 THIS_SCRIPT=`basename "$0"`
|
andrewm@58
|
12 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone]"
|
andrewm@58
|
13
|
andrewm@58
|
14 echo "
|
giuliomoro@377
|
15 This script copies the core Bela files to the BeagleBone, REMOVING
|
andrewm@58
|
16 any previous files found at that location. This should be done before
|
andrewm@58
|
17 running any of the other build scripts in this directory. The -b option
|
giuliomoro@367
|
18 changes the default path, which is otherwise $BBB_BELA_HOME."
|
andrewm@58
|
19 }
|
andrewm@58
|
20
|
andrewm@58
|
21 OPTIND=1
|
andrewm@58
|
22
|
andrewm@58
|
23 while getopts "b:h" opt; do
|
andrewm@58
|
24 case $opt in
|
giuliomoro@367
|
25 b) BBB_BELA_HOME=$OPTARG
|
andrewm@58
|
26 ;;
|
andrewm@58
|
27 h|\?) usage
|
andrewm@58
|
28 exit 1
|
andrewm@58
|
29 esac
|
andrewm@58
|
30 done
|
andrewm@58
|
31
|
giuliomoro@377
|
32 echo "Copying Bela core files to $BBB_BELA_HOME"
|
andrewm@58
|
33
|
andrewm@58
|
34 shift $((OPTIND-1))
|
andrewm@58
|
35
|
andrewm@58
|
36 # Find location of this script so we can locate the rest of the files
|
giuliomoro@300
|
37 SCRIPTPATH=$(readlink "$0")
|
andrewm@58
|
38 SCRIPTDIR=$(dirname "$SCRIPTPATH")
|
l@405
|
39 [ -z "$IDE_FOLDER" ] && IDE_FOLDER=$SCRIPTDIR/../../bela-ide/
|
andrewm@58
|
40
|
giuliomoro@377
|
41 read -p "Warning: this script will DELETE any existing Bela files from your BeagleBone! Continue? (y/N) " -r
|
andrewm@58
|
42 echo
|
giuliomoro@243
|
43 if [[ $REPLY = [yY] ]]
|
andrewm@58
|
44 then
|
giuliomoro@377
|
45 # Stop Bela if running and remove all files
|
giuliomoro@377
|
46 echo "Stopping Bela and removing old files."
|
giuliomoro@377
|
47 ssh $BBB_ADDRESS "screen -X -S Bela quit &>/dev/null; pkill Bela; sleep 0.5 ; rm -rf $BBB_BELA_HOME ; mkdir $BBB_BELA_HOME"
|
andrewm@58
|
48
|
andrewm@58
|
49 # Copy relevant files to BeagleBone Black
|
andrewm@58
|
50 echo "Copying new files to BeagleBone..."
|
l@406
|
51 scp -q -r $SCRIPTDIR/../core $SCRIPTDIR/../include $SCRIPTDIR/../Makefile $SCRIPTDIR/../libNE10.a $SCRIPTDIR/../libprussdrv.a $SCRIPTDIR/../examples $SCRIPTDIR/../Doxyfile $BBB_ADDRESS:$BBB_BELA_HOME &&\
|
giuliomoro@402
|
52 scp -q $SCRIPTDIR/../libpd.so $BBB_ADDRESS:/usr/lib
|
giuliomoro@64
|
53 if [ $? -ne 0 ]
|
giuliomoro@64
|
54 then
|
giuliomoro@64
|
55 echo "Error while copying files"
|
giuliomoro@64
|
56 exit
|
giuliomoro@64
|
57 fi
|
giuliomoro@402
|
58 # Create remaining directories needed for building
|
andrewm@58
|
59 echo "Creating directory structure on BeagleBone..."
|
giuliomoro@367
|
60 ssh $BBB_ADDRESS "mkdir -p $BBB_BELA_HOME/build ; mkdir -p $BBB_BELA_HOME/build/core ; mkdir -p $BBB_BELA_HOME/build/projects; mkdir -p $BBB_BELA_HOME/projects" &&\
|
andrewm@58
|
61 echo "Done."
|
giuliomoro@83
|
62 else
|
giuliomoro@83
|
63 echo "Aborting..."
|
giuliomoro@402
|
64 exit
|
andrewm@58
|
65 fi
|
andrewm@58
|
66
|
giuliomoro@402
|
67 #-------------
|
giuliomoro@402
|
68 #Installing IDE
|
giuliomoro@402
|
69 stat $IDE_FOLDER/scripts/setup_IDE.sh > /dev/null
|
giuliomoro@402
|
70 if [ $? -eq 0 ]
|
giuliomoro@402
|
71 then
|
giuliomoro@402
|
72 cd $IDE_FOLDER/scripts;
|
giuliomoro@402
|
73 ./setup_IDE.sh
|
giuliomoro@402
|
74 else
|
giuliomoro@402
|
75 echo "No IDE found, no IDE installed. You can get a copy of the IDE files from https://github.com/LBDonovan/bela-ide"
|
giuliomoro@402
|
76 fi;
|