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

Subversion Repositories radiohdl

[/] [radiohdl/] [trunk/] [quartus/] [run_rbf] - 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) 2012
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_rbf buildset design_name
26
# example:
27
#   run_rbf 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) buildset project [options]
37
Arguments: buildset     Name of the buildset to create the registermap for.
38
           project      Project file to use.
39
 
40
Options: --rev=*        which revision to use.
41
         --unb2_factory ???
42
--> Note: It does not matter where the options are placed: before, in between or after the arguments.
43
@EndOfHelp@
44
    exit 1
45
}
46
 
47
# parse cmdline
48
POSITIONAL=()
49
rev=
50
arg_unb2_factory=
51
while [[ $# -gt 0 ]]
52
do
53
    case $1 in
54
        --rev=*)
55
            rev=${1#*=}
56
            ;;
57
        --unb2_factory)
58
            arg_unb2_factory=1
59
            ;;
60
        -*|--*)
61
            exit_with_error "Unknown option: "$1
62
            ;;
63
        *)  POSITIONAL+=("$1")
64
            ;;
65
    esac
66
    shift
67
done
68
if [ ${#POSITIONAL[@]} -gt 0 ]; then
69
    set -- "${POSITIONAL[@]}"
70
fi
71
 
72
# check the positional parameters
73
if [ $# -ne 2 ]; then
74
    exit_with_error "Wrong number of arguments specified."
75
fi
76
buildset=$1
77
project=$2
78
# read in the configuration based on the user arguments
79
. ${RADIOHDL_GEAR}/quartus/set_quartus ${buildset}
80
 
81
PRJS="${RADIOHDL_BUILD_DIR}"
82
PRJ=
83
for prj in ${PRJS}
84
    do
85
        if [ -d "${prj}/${buildset}/quartus/${project}" ]; then
86
            PRJ=${prj}
87
        fi
88
    done
89
if [ -z "${project}" -o -z "${PRJ}" ]; then
90
    unb_error $0 "Please enter a valid project name"
91
fi
92
 
93
quartusdir="${PRJ}/${buildset}/quartus/${project}"
94
 
95
if [ -z "${rev}" ]; then
96
  project_rev="${project}"
97
  hdl_info $0 "No project revision passed, defaulting to ${project_rev}"
98
else
99
  if [ -f "${PRJ}/Firmware/designs/${project}/build/synth/quartus/${rev}.qsf" ]; then
100
    project_rev="${rev}"
101
    hdl_info $0 "Selecting project revision ${project_rev}"
102
  else
103
    hdl_error $0 "Invalid project revision"
104
  fi
105
fi
106
 
107
sof_file=${quartusdir}/${project_rev}.sof
108
if [ ! -f "${sof_file}" ]; then
109
        hdl_error $0 "${project_rev}.sof not found in ${quartusdir}/"
110
        exit 1
111
fi
112
 
113
echo "Bitstream_compression=on" > ${HOME}/.run_rbf_temp_options_file
114
 
115
hdl_info $0 "Converting ${quartusdir}/${project_rev}.sof to compressed Raw Binary File"
116
 
117
if [ -z "${arg_unb2_factory}" ]; then
118
  hdl_exec $0 quartus_cpf -c --option=${HOME}/.run_rbf_temp_options_file ${quartusdir}/${project_rev}.sof ${quartusdir}/${project_rev}.rbf
119
else
120
  hdl_info $0 "-> This is a factory image for Uniboard2: Convert .SOF -> .POF -> .HEXOUT -> .RBF"
121
  # for more info see: ${RADIOHDL_WORK}/libraries/io/epcs/doc/README.txt
122
  hdl_exec $0 quartus_cpf -d EPCQL1024 -m ASx4 --option=${HOME}/.run_rbf_temp_options_file -c ${quartusdir}/${project_rev}.sof ${quartusdir}/${project_rev}.pof
123
  hdl_exec $0 quartus_cpf -c ${quartusdir}/${project_rev}.pof ${quartusdir}/${project_rev}.hexout
124
  hdl_exec $0 nios2-elf-objcopy -I ihex -O binary ${quartusdir}/${project_rev}.hexout ${quartusdir}/${project_rev}.rbf
125
 
126
  hdl_info $0 "Truncating RBF:"
127
  echo "Size of .SOF is: "
128
  du -h ${quartusdir}/${project_rev}.sof
129
  echo "Truncating to 40M (FIXME find out if 40M is correct on different SOF files)"
130
  hdl_exec $0 truncate -s 40M ${quartusdir}/${project_rev}.rbf
131
  echo "Deleting temp files"
132
  hdl_exec $0 rm -f ${quartusdir}/${project_rev}.pof
133
  hdl_exec $0 rm -f ${quartusdir}/${project_rev}.hexout
134
fi
135
 
136
 
137
if [ -n "${HDL_GIT_REVISION_SHORT}" ]; then
138
  git_revision=`echo ${HDL_GIT_REVISION_SHORT}`  # ${HDL_GIT_REVISION_SHORT} looks like: "7d81650af"
139
  echo "copy file ${quartusdir}/${project_rev}.rbf to ${quartusdir}/${project_rev}-r${git_revision}.rbf"
140
  cp ${quartusdir}/${project_rev}.rbf ${quartusdir}/${project_rev}-r${git_revision}.rbf
141
fi
142
 
143
 
144
hdl_info $0 "Done"
145
 

powered by: WebSVN 2.1.0

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