1 |
commit: deed2865465552e9d6e3233470a89bbc2ffc9e73 |
2 |
Author: Rick Farina <zerochaos <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Jan 8 22:17:48 2019 +0000 |
4 |
Commit: Rick Farina <zerochaos <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Jan 8 22:19:29 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=deed2865 |
7 |
|
8 |
net-wireless/hackrf-tools: add hackrf_easy_flash |
9 |
|
10 |
helper script for updating firmware/cpld and switching firmware |
11 |
|
12 |
Package-Manager: Portage-2.3.54, Repoman-2.3.12 |
13 |
Signed-off-by: Rick Farina <zerochaos <AT> gentoo.org> |
14 |
|
15 |
net-wireless/hackrf-tools/files/hackrf_easy_flash | 161 +++++++++++++++++++++ |
16 |
...1.1.ebuild => hackrf-tools-2018.01.1-r1.ebuild} | 4 +- |
17 |
2 files changed, 164 insertions(+), 1 deletion(-) |
18 |
|
19 |
diff --git a/net-wireless/hackrf-tools/files/hackrf_easy_flash b/net-wireless/hackrf-tools/files/hackrf_easy_flash |
20 |
new file mode 100755 |
21 |
index 00000000000..3c802b440fa |
22 |
--- /dev/null |
23 |
+++ b/net-wireless/hackrf-tools/files/hackrf_easy_flash |
24 |
@@ -0,0 +1,161 @@ |
25 |
+#!/bin/sh |
26 |
+ |
27 |
+DFU_MODE=0 |
28 |
+CPLD=0 |
29 |
+ |
30 |
+get_dfu() { |
31 |
+ if [ -r "/usr/share/hackrf/hackrf_one_usb.dfu" ]; then |
32 |
+ ram_firmware="/usr/share/hackrf/hackrf_one_usb.dfu" |
33 |
+ else |
34 |
+ printf "Unable to find hackrf_one_usb.dfu in the search path\n" |
35 |
+ exit 1 |
36 |
+ fi |
37 |
+ export ram_firmware |
38 |
+} |
39 |
+ |
40 |
+get_cpld() { |
41 |
+ if [ -r "/usr/share/hackrf/hackrf_cpld_default.xsvf" ]; then |
42 |
+ cpld="/usr/share/hackrf/hackrf_cpld_default.xsvf" |
43 |
+ else |
44 |
+ printf "Unable to find default.xsvf in the search path\n" |
45 |
+ exit 1 |
46 |
+ fi |
47 |
+ export cpld |
48 |
+} |
49 |
+ |
50 |
+usage() { |
51 |
+ printf "hackrf_easy_flash list\n" |
52 |
+ printf "hackrf_easy_flash upgrade\n" |
53 |
+} |
54 |
+ |
55 |
+if [ -z "${1}" ]; then |
56 |
+ usage |
57 |
+ exit 0 |
58 |
+fi |
59 |
+ |
60 |
+list_firmware() { |
61 |
+ if [ ${DFU_MODE} = 1 ]; then |
62 |
+ if [ -z "${ram_firmware}" ]; then |
63 |
+ get_dfu |
64 |
+ fi |
65 |
+ printf "Best DFU found: ${ram_firmware}\n" |
66 |
+ fi |
67 |
+ printf "Available firmware options:\n" |
68 |
+ if [ -r "/usr/share/hackrf/hackrf_one_usb.bin" ]; then |
69 |
+ printf "hackrf (default)\n" |
70 |
+ fi |
71 |
+ if [ -r "/usr/share/hackrf/portapack-h1-firmware.bin" ]; then |
72 |
+ printf "portapack (--portapack)\n" |
73 |
+ fi |
74 |
+ if [ -r "/usr/share/hackrf/portapack-h1-havoc.bin" ]; then |
75 |
+ printf "portapack-havoc (--havoc)\n" |
76 |
+ fi |
77 |
+} |
78 |
+ |
79 |
+#parse args |
80 |
+while [ -n "${1}" ]; do |
81 |
+ case $1 in |
82 |
+ -h|--help) |
83 |
+ usage |
84 |
+ exit 0 |
85 |
+ ;; |
86 |
+ list|--list) |
87 |
+ list_firmware |
88 |
+ exit 0 |
89 |
+ ;; |
90 |
+ update|--update|upgrade|--upgrade|hackrf|--hackrf) |
91 |
+ firmware="/usr/share/hackrf/hackrf_one_usb.bin" |
92 |
+ TARGET=hackrf |
93 |
+ shift |
94 |
+ ;; |
95 |
+ portapack|--portapack) |
96 |
+ firmware="/usr/share/hackrf/portapack-h1-firmware.bin" |
97 |
+ TARGET=portapack |
98 |
+ shift |
99 |
+ ;; |
100 |
+ havoc|--havoc) |
101 |
+ firmware="/usr/share/hackrf/portapack-h1-havoc.bin" |
102 |
+ TARGET=havoc |
103 |
+ shift |
104 |
+ ;; |
105 |
+ cpld|--cpld) |
106 |
+ CPLD=1 |
107 |
+ get_cpld |
108 |
+ shift |
109 |
+ ;; |
110 |
+ dfu|--dfu) |
111 |
+ DFU_MODE=1 |
112 |
+ get_dfu |
113 |
+ shift |
114 |
+ ;; |
115 |
+ --) |
116 |
+ shift |
117 |
+ break |
118 |
+ ;; |
119 |
+ *) |
120 |
+ break |
121 |
+ ;; |
122 |
+ esac |
123 |
+done |
124 |
+ |
125 |
+if [ -z "${firmware}" ]; then |
126 |
+ firmware="/usr/share/hackrf/hackrf_one_usb.bin" |
127 |
+ TARGET="hackrf" |
128 |
+fi |
129 |
+ |
130 |
+if [ ! -r "${firmware}" ]; then |
131 |
+ printf "Unable to find or read ${firmware}\n" |
132 |
+ printf "Please ensure the requested firmware is installed and readable\n" |
133 |
+ exit 1 |
134 |
+fi |
135 |
+ |
136 |
+if [ "${CPLD}" = 1 ] && [ "${TARGET}" != "hackrf" ]; then |
137 |
+ printf "To update the CPLD you must use the stock hackrf firmware or do this update manually\n" |
138 |
+ printf "Try \"$(basename $0) --cpld && $(basename $0) ${TARGET}\"\n" |
139 |
+ exit 1 |
140 |
+fi |
141 |
+ |
142 |
+if [ ${DFU_MODE} = 1 ]; then |
143 |
+ printf "Preparing to reset hackrf with DFU ${ram_firmware}\n" |
144 |
+ printf "Then flashing with ${firmware}\n\n" |
145 |
+ printf "Hold down the HackRF's DFU button (the button closest to the antenna jack)\n" |
146 |
+ printf "then plug the HackRF into a USB port on your computer.\n" |
147 |
+ printf "After the HackRF is plugged in, you may release the DFU button.\n" |
148 |
+ printf "Press any key to continue or ^c to abort\n" |
149 |
+ read |
150 |
+ if ! dfu-util --device 1fc9:000c --download "${ram_firmware}" --reset; then |
151 |
+ printf "dfu-util reported failure, quitting\n" |
152 |
+ exit 1 |
153 |
+ fi |
154 |
+ sleep 2s |
155 |
+else |
156 |
+ if hackrf_info | grep -q 'No HackRF boards found.'; then |
157 |
+ printf "No hackrf found, please ensure you are in hackrf mode or try --dfu\n" |
158 |
+ exit 1 |
159 |
+ fi |
160 |
+fi |
161 |
+if hackrf_spiflash -w "${firmware}"; then |
162 |
+ sleep 3s |
163 |
+ hackrf_spiflash -R |
164 |
+ sleep 3s |
165 |
+else |
166 |
+ printf "hackrf_spiflash reported failure, quitting\n" |
167 |
+ exit 1 |
168 |
+fi |
169 |
+if [ "${CPLD}" = 1 ]; then |
170 |
+ #printf "To update the cpld, please reset your hackrf into it's new firmware before updating the cpld\n" |
171 |
+ #printf "Please reset your hackrf by pressing the button furthest from the antenna or power cycling it.\n" |
172 |
+ #printf "Press any key to continue or ^c to abort\n" |
173 |
+ #read |
174 |
+ if hackrf_cpldjtag -x "${cpld}"; then |
175 |
+ sleep 3s |
176 |
+ hackrf_spiflash -R |
177 |
+ else |
178 |
+ printf "hackrf_cpldjtag reported failure\n" |
179 |
+ exit 1 |
180 |
+ fi |
181 |
+fi |
182 |
+if [ "${TARGET}" = "hackrf" ]; then |
183 |
+ hackrf_info |
184 |
+fi |
185 |
+printf "If you saw no errors, you are up to date with the requested firmware\n" |
186 |
|
187 |
diff --git a/net-wireless/hackrf-tools/hackrf-tools-2018.01.1.ebuild b/net-wireless/hackrf-tools/hackrf-tools-2018.01.1-r1.ebuild |
188 |
similarity index 91% |
189 |
rename from net-wireless/hackrf-tools/hackrf-tools-2018.01.1.ebuild |
190 |
rename to net-wireless/hackrf-tools/hackrf-tools-2018.01.1-r1.ebuild |
191 |
index 8e2e2ed538c..077393444eb 100644 |
192 |
--- a/net-wireless/hackrf-tools/hackrf-tools-2018.01.1.ebuild |
193 |
+++ b/net-wireless/hackrf-tools/hackrf-tools-2018.01.1-r1.ebuild |
194 |
@@ -1,4 +1,4 @@ |
195 |
-# Copyright 1999-2018 Gentoo Foundation |
196 |
+# Copyright 1999-2019 Gentoo Authors |
197 |
# Distributed under the terms of the GNU General Public License v2 |
198 |
|
199 |
EAPI=6 |
200 |
@@ -30,6 +30,7 @@ RDEPEND="${DEPEND}" |
201 |
|
202 |
src_install() { |
203 |
cmake-utils_src_install |
204 |
+ dosbin "${FILESDIR}/hackrf_easy_flash" |
205 |
if [[ ${PV} != "9999" ]] ; then |
206 |
insinto /usr/share/hackrf |
207 |
newins "${WORKDIR}/hackrf-${PV}/firmware-bin/hackrf_jawbreaker_usb.bin" hackrf_jawbreaker_usb-${PV}.bin |
208 |
@@ -41,6 +42,7 @@ src_install() { |
209 |
ln -s hackrf_one_usb-${PV}.bin "${ED}/usr/share/hackrf/hackrf_one_usb.bin" |
210 |
ln -s hackrf_one_usb-${PV}.dfu "${ED}/usr/share/hackrf/hackrf_one_usb_ram.dfu" |
211 |
ln -s hackrf_one_usb-${PV}.dfu "${ED}/usr/share/hackrf/hackrf_one_usb.dfu" |
212 |
+ ln -s hackrf_cpld_default-${PV}.xsvf "${ED}/usr/share/hackrf/hackrf_cpld_default.xsvf" |
213 |
else |
214 |
ewarn "The compiled firmware files are only available in the versioned releases, you are on your own for this." |
215 |
fi |