New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DueFromOSX.sh to auto-locate bossac and related utils #118

Merged
merged 1 commit into from Nov 25, 2017
Jump to file or symbol
Failed to load files and symbols.
+30 −7
Diff settings

Always

Just for now

@@ -4,10 +4,10 @@ PATH=$PATH:$arduinoAppDir/Arduino.app/Contents/Resources/Java/hardware/tools/g++
function show_usage() { function show_usage() {
cat <<END cat <<END
USAGE: $0 -f TinyG.elf -p <native port> USAGE: $0 -f TinyG2.elf -p <native port>
Replacing <native port> with the device name of the Arduino Due native port Replacing <native port> with the device name of the Arduino Due native port
or TinyG v9 port, respctively. or TinyG v9 port, respectively.
One of the following may be a valid choice: One of the following may be a valid choice:
@@ -45,7 +45,9 @@ while getopts h?f:p:P: flag; do
done done
if [[ ${file} == "" ]]; then if [[ ${file} == "" ]]; then
echo "Error: Please specify a file to program. The name will most likely be 'TinyG.elf'." echo "Error: Please specify a file to program. The name will most likely be 'TinyG2.elf'."
echo
show_usage
exit 1; exit 1;
fi fi
@@ -55,8 +57,29 @@ if [[ ${port} == "" ]]; then
exit 1; exit 1;
fi fi
# Check for bossac in the Arduino IDE 1.6+ locations
bossac_binary=`find $HOME/Library/Arduino15/packages -type f -name bossac 2>/dev/null`
if [[ ${bossac_binary}x == "x" ]]; then
# Wasn't found, so lets check in the Arduino IDE <1.6 location
bossac_binary=`find /Applications/Arduino.app/Contents/Resources/Java/hardware/tools -type f -name bossac 2>/dev/null`
if [[ ${bossac_binary}x == "x" ]]; then
echo "Error: bossac could not be found. Is the Arduino IDE installed, along with the Arduino SAM Boards extension?"
exit 1;
fi
fi
# Check for objcopy in the Arduino IDE 1.6+ locations
objcopy_binary=`find $HOME/Library/Arduino15/packages -type f -name arm-none-eabi-objcopy 2>/dev/null`
if [[ ${objcopy_binary}x == "x" ]]; then
# Wasn't found, so lets check in the Arduino IDE <1.6 location
objcopy_binary=`find /Applications/Arduino.app/Contents/Resources/Java/hardware/tools -type f -name arm-none-eabi-objcopy 2>/dev/null`
if [[ ${objcopy_binary}x == "x" ]]; then
echo "Error: arm-none-eabi-objcopy could not be found. Is the Arduino IDE installed, along with the Arduino SAM Boards extension??"
exit 1;
fi
fi
arm-none-eabi-objcopy -O binary "${file}" "${file/.elf/.bin}" $objcopy_binary -O binary "${file}" "${file/.elf/.converted}"
echo "Forcing reset using 1200bps open/close on port ${port}" echo "Forcing reset using 1200bps open/close on port ${port}"
# perl -e 'open(my $fh, ">", "${port}"); close($fh);' # perl -e 'open(my $fh, ">", "${port}"); close($fh);'
@@ -69,12 +92,12 @@ sleep 0.5
# stty -f "${port}" 115200 # stty -f "${port}" 115200
echo "Starting programming of file ${file} -> ${file/.elf/.bin} on port ${port/\/dev\//}" echo "Starting programming of file ${file} -> ${file/.elf/.converted} on port ${port/\/dev\//}"
$arduinoAppDir/Arduino.app/Contents/Resources/Java/hardware/tools/bossac -e -w -v -b "${file/.elf/.bin}" $bossac_binary -e -w -v -b "${file/.elf/.converted}"
echo echo
echo "WARNING: You may need to hit the RESET button on the device at this point." echo "WARNING: You may need to hit the RESET button on the device at this point."
##----------- PROGRAMMING port ##----------- PROGRAMMING port
#Forcing reset using 1200bps open/close on port /dev/tty.usbmodem26231 #Forcing reset using 1200bps open/close on port /dev/tty.usbmodem26231
#bossac --port=tty.usbmodem26231 -U false -e -w -v -b $tmp/BareMinimum.cpp.bin -R #bossac --port=tty.usbmodem26231 -U false -e -w -v -b $tmp/BareMinimum.cpp.bin -R