|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# clupload script to invoke lsz |
| 4 | +# Copyright (C) 2014 Intel Corporation |
| 5 | +# |
| 6 | +# This library is free software; you can redistribute it and/or |
| 7 | +# modify it under the terms of the GNU Lesser General Public |
| 8 | +# License as published by the Free Software Foundation; either |
| 9 | +# version 2.1 of the License, or (at your option) any later version. |
| 10 | +# |
| 11 | +# This library is distributed in the hope that it will be useful, |
| 12 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | +# Lesser General Public License for more details. |
| 15 | +# |
| 16 | +# You should have received a copy of the GNU Lesser General Public |
| 17 | +# License along with this library; if not, write to the Free Software |
| 18 | +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | +# |
| 20 | +echo "starting download script" |
| 21 | +echo "Args to shell:" $* |
| 22 | +# |
| 23 | +# ARG 1: Path to lsz executable. |
| 24 | +# ARG 2: Elf File to download |
| 25 | +# ARG 3: TTY port to use. |
| 26 | +# |
| 27 | +#path may contain \ need to change all to / |
| 28 | +path_to_exe=$1 |
| 29 | +fixed_path=${path_to_exe//\\/\/} |
| 30 | +# |
| 31 | +tty_port_id=$3 |
| 32 | +echo "Serial Port PORT" $com_port_id "(note: should be /dev/cu.xxxxxx for OSX)" |
| 33 | +echo "Using tty Port" $tty_port_id |
| 34 | +# |
| 35 | +echo "Sending Command String to move to download if not already in download mode" |
| 36 | +echo "~sketch downloadGalileo" > $tty_port_id |
| 37 | +#Give the host time to stop the process and wait for download |
| 38 | +sleep 1 |
| 39 | +# |
| 40 | +#Move the existing sketch on target. |
| 41 | +echo "Deleting existing sketch on target" |
| 42 | +"$fixed_path/lsz" --escape -c "mv -f /sketch/sketch.elf /sketch/sketch.elf.old" < $tty_port_id > $tty_port_id |
| 43 | +#"$fixed_path/lsz.exe" --escape -c "mv -f /sketch/sketch.elf /sketch/sketch.elf.old" < $tty_port_id > $tty_port 1>&0 |
| 44 | +# |
| 45 | +# Execute the target download command |
| 46 | +# |
| 47 | +#Download the file. |
| 48 | +host_file_name=$2 |
| 49 | +"$fixed_path/lsz" --escape --binary --overwrite $host_file_name < $tty_port_id > $tty_port_id |
| 50 | +# |
| 51 | +#mv the downloaded file to /sketch/sketch.elf |
| 52 | +target_download_name="${host_file_name##*/}" |
| 53 | +echo "Moving downloaded file to /sketch/sketch.elf on target" |
| 54 | +"$fixed_path/lsz" --escape -c "mv $target_download_name /sketch/sketch.elf; chmod +x /sketch/sketch.elf" < $tty_port_id > $tty_port_id |
| 55 | +# |
| 56 | +# |
0 commit comments