forked from open-sdr/openwifi
-
Notifications
You must be signed in to change notification settings - Fork 8
/
load_fpga_img.sh
executable file
·83 lines (70 loc) · 1.84 KB
/
load_fpga_img.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
#!/bin/bash
# Author: Xianjun Jiao
# SPDX-FileCopyrightText: 2022 UGent
# SPDX-License-Identifier: AGPL-3.0-or-later
# get fpga image file name
if [[ -n $1 ]]; then
fpga_img_filename=$1
else
fpga_img_filename=system_top.bit.bin
fi
fpga_type=$(cat /proc/device-tree/compatible)
fpga_img_filename_core=${fpga_img_filename##*/}
echo $fpga_type
echo $fpga_img_filename
echo $fpga_img_filename_core
set -x
ifconfig sdr0 down
rmmod sdr
# rmmod mac80211
# rmmod cfg80211
# rmmod ad9361_drv
# rmmod xilinx_dma.ko
rmmod openofdm_rx
rmmod openofdm_tx
rmmod rx_intf
rmmod tx_intf
rmmod xpu
sleep 1
if [ -f "$fpga_img_filename" ]; then
echo 0 > /sys/class/fpga_manager/fpga0/flags
mkdir -p /lib/firmware
cp $fpga_img_filename /lib/firmware/ -rf
echo $fpga_img_filename_core > /sys/class/fpga_manager/fpga0/firmware
fi
# insmod ad9361_drv.ko
# sleep 1
if [ "$fpga_type" != "xlnx,zynq-7000" ]; then
SPI_DEVNAME="spi1.0"
DDS_DEVNAME="99024000.cf-ad9361-dds-core-lpc"
ADC_DEVNAME="99020000.cf-ad9361-lpc"
else
SPI_DEVNAME="spi0.0"
DDS_DEVNAME="79024000.cf-ad9361-dds-core-lpc"
ADC_DEVNAME="79020000.cf-ad9361-lpc"
fi
while [ ! -d "/sys/bus/spi/drivers/ad9361/$SPI_DEVNAME" ]
do
echo "Waiting for /sys/bus/spi/drivers/ad9361/$SPI_DEVNAME"
sleep 0.2
done
cd /sys/bus/spi/drivers/ad9361/
echo $SPI_DEVNAME > unbind
echo $SPI_DEVNAME > bind
#while [ ! -d "/sys/bus/platform/drivers/cf_axi_dds/$DDS_DEVNAME" ]
#do
# echo "Waiting for /sys/bus/platform/drivers/cf_axi_dds/$DDS_DEVNAME"
# sleep 0.2
#done
#cd /sys/bus/platform/drivers/cf_axi_dds/
#echo $DDS_DEVNAME > unbind
#echo $DDS_DEVNAME > bind
while [ ! -d "/sys/bus/platform/drivers/cf_axi_adc/$ADC_DEVNAME" ]
do
echo "Waiting for /sys/bus/platform/drivers/cf_axi_adc/$ADC_DEVNAME"
sleep 0.2
done
cd /sys/bus/platform/drivers/cf_axi_adc/
echo $ADC_DEVNAME > unbind
echo $ADC_DEVNAME > bind
set +x