OpenCores
URL https://opencores.org/ocsvn/radiohdl/radiohdl/trunk

Subversion Repositories radiohdl

[/] [radiohdl/] [trunk/] [quartus/] [run_sof] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 danv
#!/bin/bash -eu
2
# -------------------------------------------------------------------------- #
3
#
4
# Copyright (C) 2011
5
# ASTRON (Netherlands Institute for Radio Astronomy) 
6
# JIVE (Joint Institute for VLBI in Europe) 
7
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
8
#
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation, either version 3 of the License, or
12
# (at your option) any later version.
13
#
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
# GNU General Public License for more details.
18
#
19
# You should have received a copy of the GNU General Public License
20
# along with this program.  If not, see .
21
#
22
# -------------------------------------------------------------------------- #
23
#
24
# Run this tool with at least the commandline arguments:
25
#   run_sof buildset design_name
26
# example:
27
#   run_sof unb2 unb2_minimal
28
 
29
# read generic functions/definitions
30
. ${RADIOHDL_GEAR}/generic.sh
31
 
32
# helper function for command parsing
33
exit_with_error() {
34
    hdl_error_noexit $0 "$@"
35
    cat <<@EndOfHelp@
36
Usage: $(basename $0) [options] buildset project nodes [options]
37
Arguments: buildset     Name of the buildset to create the app for.
38
           project      Project file to use for the build.
39
           nodes        A list of nodes: this can be:
40
                        - a list of node numbers (=boardnumber[0..3] and relative nodenr[0..7])
41
                          e.g: "03 04 17 23 35"
42
                        - 'magic' words like bn, fn or all where each of the words may be preceded
43
                          by a boardnumber([0..3]).
44
                          e.g: "0fn 1fn" or "3all"
45
                        - any combination of the above like e.g: "0fn 12 13 3fn"
46
 
47
Options: --timelimited:   ???
48
         --cable=*:       ???
49
         --sof=*:         ???
50
         --rev=*:         ???
51
--> Note: It does not matter where the options are placed: before, in between or after the arguments.
52
@EndOfHelp@
53
    exit 1
54
}
55
 
56
# parse cmdline
57
POSITIONAL=()
58
timelimited=
59
cable=1
60
sof=
61
rev=
62
while [[ $# -gt 0 ]]
63
do
64
    case $1 in
65
        --timelimited)
66
            timelimited="_time_limited"
67
            ;;
68
        --cable=*)
69
            cable=${1#*=}
70
            ;;
71
        --rev=*)
72
            rev=${1#*=}
73
            ;;
74
        --sof=*)
75
            sof=${1#*=}
76
            ;;
77
        -*|--*)
78
            exit_with_error "Unknown option: "$1
79
            ;;
80
        *)  POSITIONAL+=("$1")
81
            ;;
82
    esac
83
    shift
84
done
85
if [ ${#POSITIONAL[@]} -gt 0 ]; then
86
    set -- "${POSITIONAL[@]}"
87
fi
88
# check the positional parameters
89
if [ $# -lt 3 ]; then
90
    exit_with_error "Wrong number of arguments specified."
91
fi
92
buildset=$1
93
project=$2
94
nodelist=${@:3}
95
 
96
# Multi board node ID's
97
frontnodes0="00 01 02 03"
98
backnodes0="04 05 06 07"
99
frontnodes1="10 11 12 13"
100
backnodes1="14 15 16 17"
101
frontnodes2="20 21 22 23"
102
backnodes2="24 25 26 27"
103
frontnodes3="30 31 32 33"
104
backnodes3="34 35 36 37"
105
# Single board node ID's
106
frontnodes=${frontnodes1}
107
backnodes=${backnodes1}
108
 
109
nodes=
110
for node_spec in ${nodelist}
111
do
112
    # if we encounter one of the "magic" strings ..
113
    # we shortcircuit. stop commandlineprocessing
114
    # and set nodes to whatever we take them to mean
115
    # Single board arguments:
116
    if [ "${node_spec}" = "all" ]; then
117
        nodes="${nodes} ${frontnodes} ${backnodes}"
118
    elif [ "${node_spec}" = "fn" ]; then
119
        nodes="${nodes} ${frontnodes}"
120
    elif [ "${node_spec}" = "bn" ]; then
121
        nodes="${nodes} ${backnodes}"
122
 
123
    # Multi board arguments:
124
    elif [ "${node_spec}" = "0all" ]; then
125
        nodes="${nodes} ${frontnodes0} ${backnodes0}"
126
    elif [ "${node_spec}" = "0fn" ]; then
127
        nodes="${nodes} ${frontnodes0}"
128
    elif [ "${node_spec}" = "0bn" ]; then
129
        nodes="${nodes} ${backnodes0}"
130
 
131
    elif [ "${node_spec}" = "1all" ]; then
132
        nodes="${nodes} ${frontnodes1} ${backnodes1}"
133
    elif [ "${node_spec}" = "1fn" ]; then
134
        nodes="${nodes} ${frontnodes1}"
135
    elif [ "${node_spec}" = "1bn" ]; then
136
        nodes="${nodes} ${backnodes1}"
137
 
138
    elif [ "${node_spec}" = "2all" ]; then
139
        nodes="${nodes} ${frontnodes2} ${backnodes2}"
140
    elif [ "${node_spec}" = "2fn" ]; then
141
        nodes="${nodes} ${frontnodes2}"
142
    elif [ "${node_spec}" = "2bn" ]; then
143
        nodes="${nodes} ${backnodes2}"
144
 
145
    elif [ "${node_spec}" = "3all" ]; then
146
        nodes="${nodes} ${frontnodes3} ${backnodes3}"
147
    elif [ "${node_spec}" = "3fn" ]; then
148
        nodes="${nodes} ${frontnodes3}"
149
    elif [ "${node_spec}" = "3bn" ]; then
150
        nodes="${nodes} ${backnodes3}"
151
 
152
    else
153
        if [ ${#node_spec} -eq 1 ]; then
154
            nodes="${nodes} 1${node_spec}" # no board spec
155
        else
156
            nodes="${nodes} ${node_spec}"
157
        fi
158
    fi
159
done
160
 
161
# check projectfile
162
PRJS="${RADIOHDL_BUILD_DIR}"
163
PRJ=
164
for prj in ${PRJS}
165
    do
166
        if [ -d "${prj}/${buildset}/quartus/${project}" ]; then
167
            PRJ=${prj}
168
        fi
169
    done
170
if [ -z "${project}" -o -z "${PRJ}" ]; then
171
    hdl_error $0 "Please enter a valid project name"
172
fi
173
 
174
# check if the quartusdirectory does exist
175
# (such that it won't fail with a cryptic error but with
176
#  a readable one
177
quartusdir[1]="${PRJ}/${buildset}/quartus/${project}"
178
hdl_exec $0 msg=no test -d ${quartusdir[1]}
179
 
180
if [ -z "${rev}" ]; then
181
  project_rev="${project}"
182
  hdl_info $0 "No project revision passed, defaulting to ${project_rev}"
183
else
184
  if [ -f "${quartusdir[1]}/${rev}.qsf" ]; then
185
    project_rev="${rev}"
186
    hdl_info $0 "Selecting project revision ${project_rev}"
187
  else
188
    hdl_error $0 "Invalid project revision"
189
  fi
190
fi
191
 
192
if [ -z "${sof}" ]; then
193
  :
194
else
195
  if [ -f "${quartusdir[1]}/${sof}.sof" ]; then
196
    project_rev="${sof}"
197
    hdl_info $0 "Selecting programming file ${project_rev}.sof"
198
  else
199
    hdl_error $0 "Invalid programming file"
200
  fi
201
fi
202
 
203
#Convert user passed node to actual FPGA JTAG ID
204
#===============================================
205
# In the UniRack, the JTAG board IDs for board 0 (JTAG ID 1..8) and board 1 (JTAG ID 9..16) are swapped.
206
# This makes it use counter loops and such, so we'll just use an associative array to map
207
# the multi-board IDs to actual FPGA JTAG ID.
208
declare -A node_jtag=(\
209
    ["00"]="9"\
210
    ["01"]="10"\
211
    ["02"]="11"\
212
    ["03"]="12"\
213
    ["04"]="13"\
214
    ["05"]="14"\
215
    ["06"]="15"\
216
    ["07"]="16"\
217
    ["10"]="1"\
218
    ["11"]="2"\
219
    ["12"]="3"\
220
    ["13"]="4"\
221
    ["14"]="5"\
222
    ["15"]="6"\
223
    ["16"]="7"\
224
    ["17"]="8"\
225
    ["20"]="17"\
226
    ["21"]="18"\
227
    ["22"]="19"\
228
    ["23"]="20"\
229
    ["24"]="21"\
230
    ["25"]="22"\
231
    ["26"]="23"\
232
    ["27"]="24"\
233
    ["30"]="25"\
234
    ["31"]="26"\
235
    ["32"]="27"\
236
    ["33"]="28"\
237
    ["34"]="29"\
238
    ["35"]="30"\
239
    ["36"]="31"\
240
    ["37"]="32"\
241
)
242
 
243
# Now append an fpga JTAG ID to our fpga list for every match between the list of passed
244
# nodes (e.g. '00 01 02') and our associative array
245
fpgas=
246
for node in ${nodes}
247
do
248
    echo $node
249
    if [ -z "${node_jtag[$node]:-}" ]; then
250
        hdl_error $0 "Invalid node ID. Node IDs should be passed as [0..3][0..7]"
251
    fi
252
    fpgas="${fpgas} ${node_jtag[$node]:-}"
253
done
254
 
255
#Prepare command: '-o p;my_project.sof@1 -o p\;my_project.sof@2' etc.
256
command=
257
for fpga in ${fpgas}; do
258
  command="${command} -o p;${quartusdir[1]}/${project_rev}${timelimited}.sof@${fpga}"
259
done
260
 
261
if [ "${timelimited}" != "_time_limited" ]; then
262
  if [ -f "${quartusdir[1]}/${project_rev}_time_limited.sof" ]; then
263
    hdl_warning $0 "Also a time-limited SOF file present. Add --timelimited to use that file"
264
  fi
265
fi
266
 
267
hdl_info $0 "Programming FPGAs @ JTAG IDs:${fpgas} on cable ${cable}"
268
hdl_exec $0 quartus_pgm -m jtag ${command} --cable=${cable}
269
 
270
#Example of full command to program fpgas 1 and 2 with unb_mesh_nios.sof:
271
#quartus_pgm -c USB-BLASTER -m jtag -o p\;unb_mesh_nios.sof@1 -o p\;unb_mesh_nios.sof@2
272
 
273
# Wish list: multi SOF support:
274
# run_sof ${buildset} unb_mesh 1 unb_tr_nonbonded --rev=bn_tr_nonbonded bn

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.