2 # Copyright 2012 Adam Green (http://mbed.org/users/AdamGreen/)
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 # Logs the command to be run and then executes the command while logging the results.
19 echo `date` Executing $@
>>$LOGFILE
20 $@
1>>$LOGFILE 2>$ERRORFILE
21 if [ "$?" != "0" ] ; then
22 cat $ERRORFILE >>$LOGFILE
23 echo `date` Failure forced early
exit>>$LOGFILE
27 read -n 1 -sp "Press any key to continue..." dummy
; echo
33 # Setup script variables.
38 LOGFILE
=$ROOTDIR/linux_install.log
39 ERRORFILE
=$ROOTDIR/linux_install.err
40 GCC4ARM_VERSION
=gcc-arm-none-eabi-4_6-2012q1
41 GCC4ARM_FILENAME
=gcc-arm-none-eabi-4_6-2012q1-20120316.
tar.bz2
42 GCC4ARM_URL
=https
://launchpad.net
/gcc-arm-embedded
/4.6/4.6-2012-q1-update/+download
/$GCC4ARM_FILENAME
43 GCC4ARM_TAR
=$ROOTDIR/$GCC4ARM_FILENAME
44 GCC4ARM_MD5
=3999e0ce25ecd97b3138f3b0dc13c76f
45 GCC4ARM_EXTRACT
=$ROOTDIR/$GCC4ARM_VERSION
46 GCC4ARM_DIR
=$ROOTDIR/gcc-arm-none-eabi
47 GCC4ARM_BINDIR
=$GCC4ARM_DIR/bin
48 GCC4ARM_LIBEXEC
=$GCC4ARM_DIR/libexec
/gcc
/arm-none-eabi
/4.6.2
49 NEWBIN_URL
=https
://github.com
/adamgreen
/GCC-ARM-Embedded-20120316
/tarball
/master
50 NEWBIN_TAR
=$ROOTDIR/GCC-ARM-Embedded-20120316.
tar.gz
51 NEWBIN_MD5
=ab3e32a3418a38121eceb267e4366848
52 NEWBIN_BASEDIR
=$ROOTDIR/GCC-ARM-Embedded
53 NEWBIN_DIR
=$NEWBIN_BASEDIR/lin32
55 BUILDSHELL_CMD
=$ROOTDIR/BuildShell
56 BUILDSHELL_DEBUG_CMD
=$ROOTDIR/BuildShellDebug
59 echo Logging
install results to
$LOGFILE
60 echo `date` Starting
$0 $
*>$LOGFILE
62 echo Downloading GNU Tools
for ARM Embedded Processors...
63 rm $GCC4ARM_FILENAME >/dev
/null
2>/dev
/null
64 echo `date` Executing wget
$GCC4ARM_URL>>$LOGFILE
67 echo Validating md5 signature of GNU Tools
for ARM Embedded Processors...
68 echo `date` Validating md5 signature of GNU Tools
for ARM Embedded Processors
>>$LOGFILE
69 archive_match
=`md5sum $GCC4ARM_FILENAME | grep -c $GCC4ARM_MD5`
70 if [ "$archive_match" != "1" ] ; then
71 echo $GCC4ARM_FILENAME failed MD5 signature check.
>>$LOGFILE
72 echo `date` Failure forced early
exit>>$LOGFILE
76 read -n 1 -sp "Press any key to continue..." dummy
; echo
80 echo Downloading updated GCC binaries from github...
81 rm $NEWBIN_TAR >/dev
/null
2>/dev
/null
82 echo `date` Executing wget
-O $NEWBIN_TAR $NEWBIN_URL>>$LOGFILE
83 wget
-O $NEWBIN_TAR $NEWBIN_URL
85 echo Validating md5 signature of updated GCC binaries...
86 echo `date` Validating md5 signature of csgcc4mac project
>>$LOGFILE
87 archive_match
=`md5sum $NEWBIN_TAR | grep -c $NEWBIN_MD5`
88 if [ "$archive_match" != "1" ] ; then
89 echo $NEWBIN_TAR failed MD5 signature check.
>>$LOGFILE
90 echo `date` Failure forced early
exit>>$LOGFILE
94 read -n 1 -sp "Press any key to continue..." dummy
; echo
98 echo Extracting GNU Tools
for ARM Embedded Processors...
99 rm -r $GCC4ARM_DIR >/dev
/null
2>/dev
/null
100 RunAndLog
tar xf
$GCC4ARM_TAR
101 RunAndLog
mv $GCC4ARM_EXTRACT $GCC4ARM_DIR
103 echo Extracting updated GCC binaries...
104 RunAndLog
tar -x --xform s
/adamgreen-GCC-ARM-Embedded-
[0-9]*-[a-f0-9
]*/GCC-ARM-Embedded
/ -f $NEWBIN_TAR
106 echo Installing updated GCC binaries...
107 RunAndLog
cp $NEWBIN_DIR/arm-none-eabi-gdb
$GCC4ARM_BINDIR/
109 echo Creating helper scripts...
110 echo "#! /usr/bin/env bash">$BUILDSHELL_CMD
111 echo "# Modify next line and set destination drive to match mbed device">>$BUILDSHELL_CMD
112 echo "export LPC_DEPLOY='cp PROJECT.bin /media/MBED/ ; sync'">>$BUILDSHELL_CMD
113 echo>>$BUILDSHELL_CMD
114 echo "SCRIPT_PATH=\$0">>$BUILDSHELL_CMD
115 echo "SCRIPT_PATH=\${SCRIPT_PATH%/*}">>$BUILDSHELL_CMD
116 echo "cd \$SCRIPT_PATH">>$BUILDSHELL_CMD
117 echo "SCRIPT_PATH=\$PWD">>$BUILDSHELL_CMD
118 echo "export PATH=\$SCRIPT_PATH/gcc-arm-none-eabi/bin:\$PATH">>$BUILDSHELL_CMD
119 echo "exec bash">>$BUILDSHELL_CMD
120 chmod +x
$BUILDSHELL_CMD
122 echo "#! /usr/bin/env bash">$BUILDSHELL_DEBUG_CMD
123 echo "# Modify next line and set destination drive to match mbed device">>$BUILDSHELL_DEBUG_CMD
124 echo "export LPC_DEPLOY='cp PROJECT.bin /media/MBED/ ; sync'">>$BUILDSHELL_DEBUG_CMD
125 echo>>$BUILDSHELL_DEBUG_CMD
126 echo "SCRIPT_PATH=\$0">>$BUILDSHELL_DEBUG_CMD
127 echo "SCRIPT_PATH=\${SCRIPT_PATH%/*}">>$BUILDSHELL_DEBUG_CMD
128 echo "cd \$SCRIPT_PATH">>$BUILDSHELL_DEBUG_CMD
129 echo "SCRIPT_PATH=\$PWD">>$BUILDSHELL_DEBUG_CMD
130 echo "export PATH=\$SCRIPT_PATH/gcc-arm-none-eabi/bin:\$PATH">>$BUILDSHELL_DEBUG_CMD
131 echo "export GCC4MBED_TYPE=Debug">>$BUILDSHELL_DEBUG_CMD
132 echo "exec bash">>$BUILDSHELL_DEBUG_CMD
133 chmod +x
$BUILDSHELL_DEBUG_CMD
135 # Place arm-none-eabi-* tools in the path before building gcc4mbed code.
136 PATH
=$GCC4ARM_BINDIR:$PATH
138 echo Performing a clean build of the gcc4mbed samples...
139 RunAndLog
$OUR_MAKE clean
142 echo Cleaning up intermediate files...
143 RunAndLog
rm -r $NEWBIN_BASEDIR
144 RunAndLog
rm $NEWBIN_TAR
145 RunAndLog
rm $GCC4ARM_TAR
148 echo To build gcc4mbed samples
, you will first need to run the following
script
149 echo so that your environment variables are
set correctly
:
151 echo You will want to run this each
time you start a new Terminal. You
152 echo can simply double-click on this
script file from Finder to launch a
153 echo bash Terminal that has been properly initialized
for building gcc4mbed
154 echo based code. Feel free to customize it as you desire.
156 echo You can also just edit your existing setup
script such as \~
/.profile
157 echo to update the PATH environment variable to include
:
161 # Restore current directory and exit script on success.
162 echo `date` Finished successfully
>>$LOGFILE
163 echo Finished successfully
166 read -n 1 -sp "Press any key to continue..." dummy
; echo