Commit | Line | Data |
---|---|---|
b3f3562f OL |
1 | #!/bin/bash |
2 | ||
3 | # parameters | |
4 | # | |
5 | # ============================================================================ | |
6 | # | |
7 | # Copyright (C) THALES. All rights reserved | |
8 | # Author: Laurent Mazet | |
9 | # | |
10 | # 2014-10-06 V1.0 : Creation | |
11 | # | |
12 | # ============================================================================ | |
13 | ||
14 | DRY= | |
15 | FIRMWARE=/opt/trc6500/config/code_metier/libHwCtrl/Bitstream | |
16 | LIST="application.out production.bin ts12_fp_pano.bin ts22_fp_pano.bin firmware.out" | |
17 | HOST= | |
b3f3562f OL |
18 | TRC6500_SCRIPT_DIR=$(dirname $0) |
19 | ||
20 | # help function | |
21 | ||
22 | function usage () { | |
23 | echo "usage: $PROGNAME [-d] [-f dir] [-h] [-i host] [-l list]" | |
24 | echo " -d: dry mode" | |
25 | echo " -f: firmware directory ($FIRMWARE)" | |
26 | echo " -h: help message" | |
27 | echo " -i: board hostname (or ip)" | |
28 | echo " -l: list of firmware ($LIST)" | |
29 | exit $@ | |
30 | } | |
31 | ||
32 | # formating functions | |
33 | ||
34 | function title () { echo -e "\033[0;1m$*\033[0;0m"; } | |
35 | function pass () { echo -e "\033[1;32m$*\033[0;0m"; } | |
36 | function warn () { echo -e "\033[1;33m$*\033[0;0m"; } | |
37 | function fail () { echo -e "\033[1;31m$*\033[0;0m"; } | |
38 | ||
39 | # argument processing | |
40 | ||
41 | while [ $# -gt 0 ]; do | |
42 | case "$1" in | |
43 | -d) DRY=yes;; | |
44 | -f) shift; FIRMWARE=$1;; | |
45 | -h) usage 0;; | |
46 | -i) shift; HOST=$1;; | |
47 | -l) shift; LIST=$1;; | |
48 | *) usage 1;; | |
49 | esac | |
50 | shift | |
51 | done | |
52 | ||
53 | # check host | |
54 | ||
55 | [ "$HOST" ] || ping -c 1 $HOST >&/dev/null || \ | |
56 | { fail "Can't connect '$HOST'"; exit 1; } | |
57 | ||
58 | # check firmware | |
59 | ||
60 | for f in $LIST; do | |
61 | [ -f $FIRMWARE/$f ] || { fail "Can't find '$FIRMWARE/$f'"; exit 1; } | |
62 | done | |
63 | ||
64 | # check mode | |
65 | ||
66 | protect="" | |
67 | [ "$DRY" = yes ] && protect="!echo" | |
68 | ||
69 | # flash firmware | |
70 | ||
71 | title "flash fe306 '$HOST'" | |
72 | ||
73 | ftp -n <<EOF | |
74 | open $HOST | |
75 | quote USER none | |
76 | quote PASS none | |
77 | binary | |
78 | cd flash | |
79 | $(for f in $LIST; do echo "$protect send $FIRMWARE/$f"; done) | |
80 | bye | |
81 | EOF | |
82 | ||
83 | # vim:set tabstop=4 shiftwidth=4 softtabstop=4: |