|
| 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 | + |
| 21 | +echo "starting download script" |
| 22 | +echo "Args to shell:" $* |
| 23 | + |
| 24 | +# ARG 1: Path to lsz executable. |
| 25 | +# ARG 2: Elf File to download |
| 26 | +# ARG 3: COM port to use. |
| 27 | + |
| 28 | +#path contains \ need to change all to / |
| 29 | +path_to_exe=$1 |
| 30 | +fixed_path=${path_to_exe//\\/\/} |
| 31 | + |
| 32 | +#COM ports are not always setup to be addressed via COM for redirect. |
| 33 | +#/dev/ttySx are present. Howwever, COMy -> /dev/ttySx where x = y - 1 |
| 34 | + |
| 35 | +com_port_arg=$3 |
| 36 | +com_port_id=${com_port_arg/COM/} |
| 37 | +echo "COM PORT" $com_port_id |
| 38 | +tty_port_id=/dev/ttyS$((com_port_id-1)) |
| 39 | +echo "Converted COM Port" $com_port_arg "to tty port" $tty_port_id |
| 40 | + |
| 41 | +echo "Sending Command String to move to download if not already in download mode" |
| 42 | +echo "~sketch downloadGalileo" > $tty_port_id |
| 43 | + |
| 44 | +#Move the existing sketch on target. |
| 45 | +echo "Deleting existing sketch on target" |
| 46 | +"$fixed_path/lsz.exe" --escape -c "mv -f /sketch/sketch.elf /sketch/sketch.elf.old" <> $tty_port_id 1>&0 |
| 47 | +# Execute the target download command |
| 48 | + |
| 49 | +#Download the file. |
| 50 | +host_file_name=$2 |
| 51 | +"$fixed_path/lsz.exe" --escape --binary --overwrite $host_file_name <> $tty_port_id 1>&0 |
| 52 | + |
| 53 | +#mv the downloaded file to /sketch/sketch.elf |
| 54 | +target_download_name="${host_file_name##*/}" |
| 55 | +echo "Moving downloaded file to /sketch/sketch.elf on target" |
| 56 | +"$fixed_path/lsz.exe" --escape -c "mv $target_download_name /sketch/sketch.elf; chmod +x /sketch/sketch.elf" <> $tty_port_id 1>&0 |
0 commit comments