comparison scripts/update_board @ 455:0567af952cfa prerelease

merge
author Giulio Moro <giuliomoro@yahoo.it>
date Sun, 19 Jun 2016 23:31:25 +0100
parents 7f9032f43f41 1d66b4e8ced9
children aa3f38d8a9b6
comparison
equal deleted inserted replaced
451:7f9032f43f41 455:0567af952cfa
1 \#!/bin/sh 1 #!/bin/sh
2 # 2 #
3 # This script copies the core Bela files to the BeagleBone Black 3 # This script copies the core Bela files to the BeagleBone Black
4 # in preparation for building projects. It will remove any existing 4 # in preparation for building projects. It will remove any existing
5 # Bela directory before copying the files over 5 # Bela directory before copying the files over
6 [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2" 6 [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2"
7 [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="/root/Bela/" 7 [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="/root/Bela/"
8 8
9 # . ./.bela_common || exit 1 9 . ./.bela_common || exit 1
10 10
11 FILES_TO_COPY="core include Makefile libNE10.a libprussdrv.a examples Doxyfile" 11 FILES_TO_COPY="core include Makefile libNE10.a libprussdrv.a examples Doxyfile"
12 12
13 # The following variables are manually copied from the Makefile. 13 # The following variables are manually copied from the Makefile.
14 # It is a bit nasty, but here we need to handle the case that the board may be 14 # It is a bit nasty, but here we need to handle the case that the board may be
17 SCREEN_NAME=Bela 17 SCREEN_NAME=Bela
18 18
19 usage () 19 usage ()
20 { 20 {
21 THIS_SCRIPT=`basename "$0"` 21 THIS_SCRIPT=`basename "$0"`
22 echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone] [--clean] [-y]" 22 echo "Usage: $THIS_SCRIPT [--clean] [--no-frills] [-dy ] [-i user@ip] [-b /path/to/remote/Bela]"
23 23
24 echo " 24 echo "
25 This script updates the core Bela files on the BeagleBone, bringing it up 25 This script updates the core Bela files on the BeagleBone, bringing it up
26 to date with the files in the folder on the host computer. 26 to date with the files in the folder on the host computer.
27 The script must be run once to initialize the board before running any of 27 The script must be run once to initialize the board before running any of
32 32
33 Command line options: 33 Command line options:
34 -i arg : allows to set the username and IP address of the remote end (default: $BBB_ADDRESS) 34 -i arg : allows to set the username and IP address of the remote end (default: $BBB_ADDRESS)
35 -b arg : allows to set the path to the Bela folder on the remote end. Use quotes if you use the \"~\" symbol (default: $BBB_BELA_HOME) 35 -b arg : allows to set the path to the Bela folder on the remote end. Use quotes if you use the \"~\" symbol (default: $BBB_BELA_HOME)
36 --clean : removes all the files in the $BBB_BELA_HOME folder, INCLUDING any source code you may have in the $BBB_BELA_HOME/projects/ subdirectory. 36 --clean : removes all the files in the $BBB_BELA_HOME folder, INCLUDING any source code you may have in the $BBB_BELA_HOME/projects/ subdirectory.
37 -d : skips re-generating Doxygen documentation on the board.
38 --no-frills : skips some optional commands.
37 -y : does not prompt the user before deleting the remote files. 39 -y : does not prompt the user before deleting the remote files.
38 " 40 "
39 } 41 }
40 42
41 signal_handler () 43 signal_handler ()
48 50
49 error_handler () { 51 error_handler () {
50 [ $1 -eq 0 ] && printf "done\n" || { [ -z "$2" ] && printf "\nAn error occurred. Is the board connected?\n" || printf "$2"; exit 1; } 52 [ $1 -eq 0 ] && printf "done\n" || { [ -z "$2" ] && printf "\nAn error occurred. Is the board connected?\n" || printf "$2"; exit 1; }
51 } 53 }
52 54
55 FULL=1
53 OPTIND=1 56 OPTIND=1
54 ALWAYS_YES=0 57 ALWAYS_YES=0
55 RESET_BOARD=0 58 RESET_BOARD=0
59 DOXYGEN=1
56 while [ "$1" != "" ]; do 60 while [ "$1" != "" ]; do
57 case $1 in 61 case $1 in
58 -b) 62 -b)
59 shift 63 shift
60 BBB_BELA_HOME=$1 64 BBB_BELA_HOME=$1
64 BBB_ADDRESS=$1 68 BBB_ADDRESS=$1
65 ;; 69 ;;
66 --clean) 70 --clean)
67 RESET_BOARD=1 71 RESET_BOARD=1
68 ;; 72 ;;
73 -d)
74 DOXYGEN=0
75 ;;
76 --no-frills)
77 FULL=0
78 ;;
69 -y) 79 -y)
70 ALWAYS_YES=1 80 ALWAYS_YES=1
71 ;; 81 ;;
72 *) 82 *)
73 usage 83 usage
80 90
81 # Find location of this script so we can locate the rest of the files 91 # Find location of this script so we can locate the rest of the files
82 SCRIPTDIR=$(dirname "$0") 92 SCRIPTDIR=$(dirname "$0")
83 [ -z "$IDE_FOLDER" ] && IDE_FOLDER=$SCRIPTDIR/../../bela-ide/ 93 [ -z "$IDE_FOLDER" ] && IDE_FOLDER=$SCRIPTDIR/../../bela-ide/
84 94
85 set_date "stat $BBB_BELA_HOME &>/dev/null" && DESTINATION_EMPTY=0 || DESTINATION_EMPTY=1 95 # Check if destination folder exists
96 # the StrictHostKeyChecking no should prevent the unkown host prompt
97 ssh -o "StrictHostKeyChecking no" $BBB_ADDRESS stat $BBB_BELA_HOME &>/dev/null && DESTINATION_EMPTY=0 || DESTINATION_EMPTY=1
98 # Set the date on the board
99 [ $FULL -eq 1 ] && set_date
86 100
87 if [ $DESTINATION_EMPTY -eq 0 ]; 101 if [ $DESTINATION_EMPTY -eq 0 ];
88 then 102 then
89 echo "Updating the Bela core code in $BBB_ADDRESS:$BBB_BELA_HOME" 103 echo "Updating the Bela core code in $BBB_ADDRESS:$BBB_BELA_HOME"
90 if [ $RESET_BOARD -eq 1 ]; 104 if [ $RESET_BOARD -eq 1 ];
102 fi 116 fi
103 else 117 else
104 echo "Installing Bela core code in $BBB_ADDRESS:$BBB_BELA_HOME" 118 echo "Installing Bela core code in $BBB_ADDRESS:$BBB_BELA_HOME"
105 fi 119 fi
106 120
107 echo "Updating Bela cores files to remote folder $BBB_BELA_HOME" 121 echo "Updating Bela core files to remote folder $BBB_BELA_HOME"
108 # Stop Bela if running and remove all files 122 # Stop Bela if running and remove all files
109 printf "Stopping Bela..." 123 if [ $FULL -eq 1 ]
110 ssh $BBB_ADDRESS "make -C $BBB_BELA_HOME idestop stop &>/dev/null; screen -X -S Bela quit &>/dev/null; screen -X -S IDE-Bela quit &>/dev/null; true"; 124 then
111 error_handler $? 125 printf "Stopping Bela..."
126 ssh $BBB_ADDRESS "make -C $BBB_BELA_HOME idestop stop &>/dev/null; screen -X -S Bela quit &>/dev/null; screen -X -S IDE-Bela quit &>/dev/null; true";
127 error_handler $?
128 fi
112 129
113 if [ $RESET_BOARD -eq 1 ]; 130 if [ $RESET_BOARD -eq 1 ];
114 then 131 then
115 printf "Removing old files..." 132 printf "Removing old files..."
116 ssh $BBB_ADDRESS "rm -rf $BBB_BELA_HOME"; 133 ssh $BBB_ADDRESS "rm -rf $BBB_BELA_HOME";
144 # Create remaining directories needed for building 161 # Create remaining directories needed for building
145 printf "Creating directory structure on BeagleBone..." 162 printf "Creating directory structure on BeagleBone..."
146 ssh $BBB_ADDRESS "mkdir -p $BBB_BELA_HOME/build/core $BBB_BELA_HOME/projects" 163 ssh $BBB_ADDRESS "mkdir -p $BBB_BELA_HOME/build/core $BBB_BELA_HOME/projects"
147 error_handler $? 164 error_handler $?
148 165
149 printf "Generating on-board documentation..." 166 if [ $DOXYGEN -eq 1 ]
150 #ssh $BBB_ADDRESS "cd $BBB_BELA_HOME; doxygen &> /dev/null" 167 then
151 error_handler $? "\nError while generating Doxygen documentation\n" 168 printf "Generating on-board documentation..."
169 ssh $BBB_ADDRESS "cd $BBB_BELA_HOME; doxygen &> /dev/null"
170 error_handler $? "\nError while generating Doxygen documentation\n"
171 fi
152 172
153 printf "Building example projects..." 173 printf "Building example projects..."
154 ssh $BBB_ADDRESS "sh $BBB_BELA_HOME/examples/core/link_core.sh" 174 ssh $BBB_ADDRESS "sh $BBB_BELA_HOME/examples/core/link_core.sh"
155 error_handler $? "\nError while building example projects\n" 175 error_handler $? "\nError while building example projects\n"
156 176
162 #Installing IDE 182 #Installing IDE
163 [ $ALWAYS_YES -eq 0 ] && ALWAYS_YES_FLAG= || ALWAYS_YES_FLAG="-y" 183 [ $ALWAYS_YES -eq 0 ] && ALWAYS_YES_FLAG= || ALWAYS_YES_FLAG="-y"
164 ls $IDE_FOLDER/scripts/setup_IDE.sh >/dev/null 2>/dev/null 184 ls $IDE_FOLDER/scripts/setup_IDE.sh >/dev/null 2>/dev/null
165 if [ $? -eq 0 ] 185 if [ $? -eq 0 ]
166 then 186 then
187 export BBB_ADDRESS BBB_BELA_HOME
167 cd $IDE_FOLDER/scripts && ./setup_IDE.sh $ALWAYS_YES_FLAG 188 cd $IDE_FOLDER/scripts && ./setup_IDE.sh $ALWAYS_YES_FLAG
168 # run the IDE 189 # run the IDE
169 ssh $BBB_ADDRESS "make -C $BBB_BELA_HOME --no-print-directory idestart" 190 [ $FULL -eq 1 ] && ssh $BBB_ADDRESS "make -C $BBB_BELA_HOME --no-print-directory idestart"
170 else 191 else
171 # run the IDE 192 # run the IDE
172 ssh $BBB_ADDRESS "make -C $BBB_BELA_HOME --no-print-directory idestart" 193 [ $FULL -eq 1 ] && ssh $BBB_ADDRESS "make -C $BBB_BELA_HOME --no-print-directory idestart"
173 echo \ 194 [ $FULL -eq 1 ] && echo "The Bela core files were updated on the board, but a valid IDE folder was not found in $IDE_FOLDER/, so the IDE was not updated. If there was an older version of the IDE on the board, it is being restarted.
174 "The Bela core files were updated the board, but a valid IDE folder was not found in $IDE_FOLDER/, so the IDE was not updated. If there was an older version of the IDE on the board, it is being restarted.
175 You can get a copy of the most up-to-date IDE files from https://github.com/LBDonovan/bela-ide 195 You can get a copy of the most up-to-date IDE files from https://github.com/LBDonovan/bela-ide
176 " 196 "
177 fi 197 fi
178 198
179 ssh $BBB_ADDRESS make -C $BBB_BELA_HOME --no-print-directory idestartup nostartup && echo "The board will now run the IDE at startup, but startup of the Bela program has been disabled. To enable it, use the set_startup.sh script" 199 [ $FULL -eq 1 ] && ssh $BBB_ADDRESS make -C $BBB_BELA_HOME --no-print-directory idestartup nostartup && echo "The board will now run the IDE at startup, but startup of the Bela program has been disabled. To enable it, use the set_startup.sh script"
180 200
181 { [ $ALWAYS_YES -eq 1 ] || [ $SHLVL -ge 1 ]; } && printf "\nSetup complete.\n\n" || { 201 [ $ALWAYS_YES -eq 1 ] && printf "\nSetup complete.\n\n" || {
182 printf '\nSetup complete, press any key to continue\n\n' 202 printf '\nSetup complete, press any key to continue\n\n'
183 read 203 read
184 } 204 }