forked from ahmaurya/brimon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·147 lines (133 loc) · 4.02 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#! /usr/bin/env bash
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Written (W) 2011 Abhinav Maurya
# Copyright (C) 2011 Abhinav Maurya
# Here we run the following:-
# the setup script to setup environment variables
# the make telosb command to build the application
# the make command to burn the binary to mote
# set the five variables given below as per the path of these repositories on your system
APPROOT="/home/ahmaurya/Dropbox/Courses/CS691/brimon/brimon-0.1.0/application"
TOSROOT="/home/ahmaurya/Dropbox/Courses/CS691/brimon/tinyos-2.1.1"
TOSDIR="$TOSROOT/tos"
CLASSPATH="$CLASSPATH:/home/ahmaurya/bin/java:$TOSROOT/support/sdk/java/tinyos.jar:."
MAKERULES="$TOSROOT/support/make/Makerules"
ifburn=false
ifclean=false
ifdocs=false
ifid=false
mote=""
while getopts :bcdin: opt
do
case "$opt" in
b) ifburn=true;;
c) ifclean=true;;
d) ifdocs=true;;
i) ifid=true;;
n) mote="$OPTARG";;
?) echo;
echo "Usage: $0 [-b] [-c] [-d] [-i] [-n device_name]";
echo " b: burns application to all connected motes";
echo " c: cleans the build and doc directories";
echo " d: creates application documentation";
echo " i: burns application to all connected motes; allows specifying TOS_NODE_ID interactively";
echo " n: burns application to a single mote specified by device name; default=/dev/ttyUSB0";
echo;
exit 1;;
esac
done
shift `expr $OPTIND - 1`
echo
echo "***Setting up environment variables***"
echo "----------------------------------------"
echo "Setting up for TinyOS 2.1.1"
export APPROOT
export TOSROOT
export TOSDIR
export CLASSPATH
export MAKERULES
cd $APPROOT
echo
#Build the nesC documentation and exit
if $ifdocs == true;
then
echo "***Building the nesC documentation***"
echo "----------------------------------------"
make telosb docs
echo
exit 0
fi
#Clean any previous nesC application builds and exit
if $ifclean == true;
then
echo "***Cleaning any previous nesC application builds***"
echo "----------------------------------------"
echo "Cleaning previous nesC application build..."
make -s -f "$APPROOT/Makefile" clean
echo "Done!"
echo "Cleaning previous nesC application documentation..."
rm -rf $APPROOT/doc
echo "Done!"
echo
exit 0
fi
#Burn the nesC application to a specific mote connected to system
#Mote ID must be specified using the -n command-line option
if [ -n "$mote" ]
then
echo "***Burning the nesC application***"
echo "----------------------------------------"
echo
echo "Burning application to mote $mote"
echo "----------------------------------------"
chmod 666 $mote
make -s telosb install bsl,$mote
echo
exit 0
fi
#Burn the nesC application to all motes connected to system
if $ifburn == true;
then
echo "***Burning the nesC application***"
echo "----------------------------------------"
for mote in `motelist | awk 'NR<=2{next} {print $2}'`
do
echo
echo "Burning application to mote $mote"
echo "----------------------------------------"
chmod 666 $mote
make -s telosb install bsl,$mote
done
echo
exit 0
fi
#Burn the nesC application to all motes connected to system
#Each mote is burnt with a different ID
#Mote IDs can be specified interactively via commandline
if $ifid == true;
then
echo "***Burning the nesC application***"
echo "----------------------------------------"
for mote in `motelist | awk 'NR<=2{next} {print $2}'`
do
echo
echo "Burning application to mote $mote"
echo "----------------------------------------"
echo -n "Enter the node ID for node $mote: ";
read nodeid
chmod 666 $mote
make -s telosb install,$nodeid bsl,$mote
done
echo
exit 0
fi
#Build the nesC application
#Default operation in case no clean, documentation or burn command-line options
echo "***Building the nesC application***"
echo "----------------------------------------"
make -s telosb
echo