-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathadi_update_tools.sh
executable file
·451 lines (395 loc) · 12.5 KB
/
adi_update_tools.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
#!/bin/bash
if [ "$(id -u)" != "0" ] ; then
echo "This script must be run as root"
exit 1
fi
wget --spider -nv http://github.com/analogdevicesinc
EC=$?
if [ $EC -ne 0 ];then
ifconfig
echo "\n\nNetwork Connection: FAILED\n"
exit $EC
fi
#find md5of this file
md5_self=`md5sum $0`
# Keeps the scripts as the first thing, so we can check for updated
# scripts ...
# repository:branch:make_target
BUILDS_DEV="linux_image_ADI-scripts:origin/main \
libiio:origin/main \
libad9361-iio:origin/main \
libad9166-iio:origin/main \
iio-oscilloscope:origin/main \
fru_tools:origin/main \
iio-fm-radio:origin/main \
jesd-eye-scan-gtk:origin/main \
diagnostic_report:origin/main \
wiki-scripts:origin/main \
colorimeter:origin/main"
BUILDS_NEXT_STABLE="linux_image_ADI-scripts:origin/main \
libiio:origin/next_stable \
libad9361-iio:origin/next_stable \
libad9166-iio:origin/next_stable \
iio-oscilloscope:origin/next_stable \
fru_tools:origin/main \
iio-fm-radio:origin/main \
jesd-eye-scan-gtk:origin/main \
diagnostic_report:origin/main \
wiki-scripts:origin/main \
colorimeter:origin/2023_R2"
BUILDS_2021_R1="linux_image_ADI-scripts:origin/main \
libiio:origin/2021_R1 \
libad9361-iio:origin/2021_R1 \
libad9166-iio:origin/main \
iio-oscilloscope:origin/2021_R1\
fru_tools:origin/2021_R1 \
iio-fm-radio:origin/main \
wiki-scripts:origin/main \
jesd-eye-scan-gtk:origin/2021_R1 \
diagnostic_report:origin/main \
colorimeter:origin/2021_R1"
BUILDS_2021_R2="linux_image_ADI-scripts:origin/main \
libiio:origin/2021_R2 \
libad9361-iio:origin/2021_R2 \
libad9166-iio:origin/main \
iio-oscilloscope:origin/2021_R2\
fru_tools:origin/2021_R2 \
iio-fm-radio:origin/main \
wiki-scripts:origin/main \
jesd-eye-scan-gtk:origin/2021_R2 \
diagnostic_report:origin/main \
colorimeter:origin/2021_R2"
BUILDS_2022_R2="linux_image_ADI-scripts:origin/main \
libiio:origin/2022_R2 \
libad9361-iio:origin/2022_R2 \
libad9166-iio:origin/2022_R2 \
iio-oscilloscope:origin/2022_R2\
fru_tools:origin/2022_R2 \
iio-fm-radio:origin/main \
wiki-scripts:origin/main \
jesd-eye-scan-gtk:origin/2022_R2 \
diagnostic_report:origin/main \
colorimeter:origin/2022_R2"
BUILDS_2023_R2="linux_image_ADI-scripts:origin/main \
libiio:origin/2023_R2 \
libad9361-iio:origin/2023_R2 \
libad9166-iio:origin/2023_R2 \
iio-oscilloscope:origin/2023_R2\
fru_tools:origin/2023_R2 \
iio-fm-radio:origin/main \
wiki-scripts:origin/main \
jesd-eye-scan-gtk:origin/2023_R2 \
diagnostic_report:origin/main \
colorimeter:origin/2023_R2"
# Define file where to save git info
VERSION="/ADI_repos_git_info.txt"
[ -f $VERSION ] && rm -rf $VERSION
touch $VERSION
write_git_info()
{
local git_link="https://github.com/analogdevicesinc/$1"
local git_branch=$2
echo "Repo : $git_link" >> $VERSION
echo "Branch : $git_branch" >> $VERSION
echo "Git_sha: $(git rev-parse --short HEAD)\n" >> $VERSION
}
do_build ()
{
local prj=$1
local target=$2
make clean;
make -j $(nproc) $target && make install && echo "\n Building $prj target $target finished Successfully\n" ||
echo "Building $prj Failed\n"
}
rfsom_box ()
{
cd /usr/local/src
if [ -d "input-event-daemon" ] ; then
cd ./input-event-daemon
git pull
else
git clone https://github.com/gandro/input-event-daemon.git
cd ./input-event-daemon
fi
make clean
make input-event-daemon
make install
if [ "$(grep input-event-daemon /etc/rc.local | wc -l)" -eq "0" ] ; then
# add /usr/bin/input-event-daemon to /etc/rc.local
sed -i '0,/^exit 0$/s/^exit 0.*/\/usr\/bin\/input-event-daemon\n&/' /etc/rc.local
fi
cp $1/input-event-daemon.conf.rfsombox /etc/input-event-daemon.conf
cd /usr/local/src
sudo apt-get -y install qt5-default gpsd python-gps gpsd-clients libmozjs-24-bin \
mplayer libx264-142 libncurses5 libreadline5 libreadline-dev libexif12 \
libexif-dev python3-scipy sox
curl -L http://github.com/micha/jsawk/raw/master/jsawk > /tmp/jsawk
mv /tmp/jsawk /usr/bin/jsawk
chmod 777 /usr/bin/jsawk
ln -s /usr/bin/js24 /usr/bin/js
if [ -d "rfsom-box-gui" ] ; then
cd ./rfsom-box-gui
for i in $(find ./ -name Makefile -exec -exec dirname {} \; ) ; do
pushd $(pwd)
cd ${i}
if [ $(grep "uninstall:" Makefile | wc -l) -ne "0" ] ; then
make uninstall 2>/dev/null
fi
popd
done
git clean -f -d -x
git fetch
git checkout -f master
git pull
else
git clone https://github.com/analogdevicesinc/rfsom-box-gui.git
cd ./rfsom-box-gui
fi
write_git_info "rfsom-box-gui" "master"
if [ ! -d ./build_packrf ] ; then
mkdir ./build_packrf
fi
cd ./build_packrf
qmake ..
make && make install
cd ..
sudo systemctl daemon-reload
#auto-start packrf
sudo systemctl enable packrf.service
if [ ! -d ./build_fft ] ; then
mkdir ./build_fft
fi
cd ./build_fft
cmake ../fft-plot
make && make install
cd ../tun_tap
make && make install
cd ..
#install ffmpeg, if needed
if [ $(which ffmpeg | wc -l) -eq "0" ] ; then
if [ "$(arch)" = "armv7l" ] ; then
cd /usr/local/src
wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-armhf-32bit-static.tar.xz
mkdir ffmpeg-release-armhf-32bit
cd ffmpeg-release-armhf-32bit
# skip first level
tar xvf ../ffmpeg-release-armhf-32bit-static.tar.xz --strip 1
rm ../ffmpeg-release-armhf-32bit-static.tar.xz
ln -s /usr/local/src/ffmpeg-release-armhf-32bit/ffmpeg \
/usr/local/bin/ffmpeg
fi
# should support 64-bit, but not yet
fi
#install fim
# FIM (Fbi IMproved) image viewer program
if [ $(which fim | wc -l) -eq "0" ] ; then
cd /usr/local/src
wget http://download.savannah.nongnu.org/releases/fbi-improved/fim-0.6-trunk.tar.gz
tar xvf fim-0.6-trunk.tar.gz
cd fim-0.6-trunk
./configure
make && make install
rm /usr/local/src/fim-0.6-trunk.tar.gz
fi
cd /usr/local/src/
#install plutosdr-scripts
git clone https://github.com/analogdevicesinc/plutosdr_scripts
cd plutosdr_scripts
write_git_info "plutosdr_scripts" "master"
make
cp cal_ad9361 /usr/local/bin
/usr/local/src/rfsom-box-gui/wpa-supplicant/install.sh
# install a low end terminal (bterm) for /dev/fb
apt-get -y install libbogl-dev bogl-bterm fonts-droid otf2bdf
# create a bitmap font, from the true-type font
otf2bdf -p 8 -d 140 \
-o /usr/share/fonts/truetype/droid/DroidSansMono.bdf \
/usr/share/fonts/truetype/droid/DroidSansMono.ttf
# create a font for the terminal
# https://manpages.debian.org/jessie/libbogl-dev/bdftobogl.1.en.html
bdftobogl -b /usr/share/fonts/truetype/droid/DroidSansMono.bdf > \
/usr/share/fonts/truetype/droid/DroidSansMono.bgf
}
# Allow selective builds by default build the latest release branches
if [[ "$1" =~ "dev" ]] || [[ "$1" = "main" ]]
then
BUILDS=$BUILDS_DEV
elif [[ "$1" = "2018_R2" ]] || [[ "$1" = "2018_r2" ]] || \
[[ "$1" = "2019_R1" ]] || [[ "$1" = "2019_r1" ]] || \
[[ "$1" = "2019_R2" ]] || [[ "$1" = "2019_r2" ]]
then
echo "Only last two releases are supported for update."
exit 1
elif [[ "$1" = "2021_R1" ]] || [[ "$1" = "2021_r1" ]]
then
BUILDS=$BUILDS_2021_R1
elif [[ "$1" = "2021_R2" ]] || [[ "$1" = "2021_r2" ]]
then
BUILDS=$BUILDS_2021_R2
elif [[ "$1" = "2022_R2" ]] || [[ "$1" = "2022_r2" ]]
then
BUILDS=$BUILDS_2022_R2
elif [[ "$1" = "2023_R2" ]] || [[ "$1" = "2023_r2" ]]
then
BUILDS=$BUILDS_2023_R2
elif [[ "$1" = "NEXT_STABLE" ]] || [[ "$1" = "next_stable" ]]
then
BUILDS=$BUILDS_NEXT_STABLE
elif [ -n "$1" ]
then
BUILDS=$1
else
BUILDS=$BUILDS_2023_R2
fi
for i in $BUILDS
do
REPO=`echo $i | cut -d':' -f1`
BRANCH=`echo $i | cut -s -d':' -f2`
TARGET=`echo $i | cut -s -d':' -f3`
# selective build without branch? use main
if [ -z $BRANCH ]
then
echo HERE
BRANCH=origin/main
TARGET=""
fi
cd /usr/local/src
if [ -d $REPO ]
then
cd ./$REPO
echo "\n *** Updating $REPO BRANCH $BRANCH ***"
dirty=`git diff --shortstat 2> /dev/null | tail -n1`
if [ "$dirty" != "" ]
then
echo "Tree is dirty - generating branch" `date +"%F"`
git branch `date +"%F"`
fi
git checkout -f $BRANCH
make uninstall 2>/dev/null
git fetch
git checkout -f $BRANCH 2>/dev/null
else
echo "\n *** Cloning $REPO/$BRANCH ***"
git clone https://github.com/analogdevicesinc/$REPO.git || continue
cd ./$REPO
git checkout $BRANCH || continue
fi
write_git_info "$REPO" "$BRANCH"
echo "\n *** Building $REPO ***"
# Handle some specialties here
if [ $REPO = "linux_image_ADI-scripts" ]
then
new=`md5sum ./adi_update_tools.sh`
if [ "$new" = "$md5_self" ]
then
echo ./adi_update_tools.sh script is the same, continuing
# Now we are sure we are using the latest, make sure the pre-reqs
# are installed. If someone reports an error, fix the list.
apt-get -y install libgtk2.0-dev libmatio-dev \
libfftw3-dev libxml2 libxml2-dev bison flex libavahi-common-dev \
libavahi-client-dev libcurl4-openssl-dev libjansson-dev cmake libaio-dev ncurses-dev \
libserialport-dev libcdk5-dev
if [ "$?" -ne "0" ] ; then
echo Catastrophic error in prerequisite packages, please report error to:
echo https://ez.analog.com/community/linux-device-drivers/linux-software-drivers
exit
else
# Non-essential applications, which help out sometime
apt-get -y install gpsd gpsd-clients u-boot-tools evtest
if [ ! -f /etc/fw_env.config ]
then
cp ./fw_env.config /etc/
fi
REFCLK=$(fw_printenv -n ad9361_ext_refclk)
if [ $? -eq 0 ]; then
echo $REFCLK | grep '^<.*>$'
if [ $? -ne 0 ]; then
REFCLK="<${REFCLK}>"
fw_setenv ad9361_ext_refclk ${REFCLK}
fi
fi
p=$(pwd)
grep -q "RFSOM-BOX" /sys/firmware/devicetree/base/model && rfsom_box $p
cd $p
fi
#Misc fixup:
sed -i 's/wiki.analog.org/wiki.analog.com/g' /etc/update-motd.d/10-help-text
sed -i 's/ analog.com/ www.wiki.analog.com www.analog.com/g' /etc/network/if-up.d/htpdate
else
# run the new one instead, and then just quit
echo ./adi_update_tools.sh has been updated, switching to new one
./adi_update_tools.sh $@
exit
fi
elif [ $REPO = "libiio" ]
then
# Just in case an old version is still under /usr/local
rm -f /usr/local/lib/libiio.so* /usr/local/sbin/iiod \
/usr/local/bin/iio_* /usr/local/include/iio.h \
/usr/local/lib/pkgconfig/libiio.pc
# Remove old services file
rm -f /etc/avahi/services/iio.service
# Remove old init.d links if they exist
if [ -f /etc/init.d/iiod.sh ] ; then
rm -f /etc/init.d/iiod.sh
update-rc.d -f iiod.sh remove
fi
if [ -f /etc/init.d/iiod ] ; then
rm -f /etc/init.d/iiod
update-rc.d -f iiod remove
fi
# New libiio versions install to /usr/lib/arm-linux-gnueabihf;
# remove the old ones that might still be inside /usr/lib
rm -f /usr/lib/libiio.so*
grep -q usb_functionfs_descs_head_v2 /usr/include/linux/usb/functionfs.h
if [ "$?" -eq "1" ] ; then
# Get a more recent version of functionfs.h, allowing libiio to build
# the IIOD USB backend
wget -O /usr/include/linux/usb/functionfs.h http://raw.githubusercontent.com/torvalds/linux/master/include/uapi/linux/usb/functionfs.h
fi
rm -rf build
# Apparently, under undetermined circumstances CMake will output the build
# files to the source directory instead of the current directory.
# Here we use the undocumented -B and -H options to force the directory
# where the build files are generated.
if grep -Fxq "/lib/systemd" /sbin/init
then
EXTRA_CMAKE=$EXTRA_CMAKE" -DWITH_SYSTEMD=ON"
elif grep -Fxq "upstart" /sbin/init
then
EXTRA_CMAKE=$EXTRA_CMAKE" -DWITH_UPSTART=ON"
else
EXTRA_CMAKE=$EXTRA_CMAKE" -DWITH_SYSVINIT=ON"
fi
cmake ${EXTRA_CMAKE} -DWITH_HWMON=ON -DWITH_SERIAL_BACKEND=ON -DWITH_MAN=ON -DWITH_EXAMPLES=ON \
-DPYTHON_BINDINGS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_COLOR_MAKEFILE=OFF -Bbuild -H.
cd build
elif [ $REPO = "libad9361-iio" ]
then
rm -rf build
# Same as above
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DCMAKE_COLOR_MAKEFILE=OFF -Bbuild -H.
cd build
elif [ $REPO = "libad9166-iio" ]
then
rm -rf build
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DCMAKE_COLOR_MAKEFILE=OFF \
-DPYTHON_BINDINGS=ON -Bbuild -H.
cd build
elif [ $REPO = "mathworks_tools" ]
then
cd ./motor_control/linux_utils/
elif [ $REPO = "iio-oscilloscope" ]
then
rm -rf build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_COLOR_MAKEFILE=OFF -Bbuild -H.
cd build
elif [ $REPO = "wiki-scripts" ]
then
cd iio/iio_jesd204_fsm_sync
rm -rf build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_COLOR_MAKEFILE=OFF -Bbuild -H.
cd build
fi
do_build $REPO $TARGET
done