2019-12-10 13:03:47 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-02-03 15:01:04 +00:00
|
|
|
# Author: Xianjun Jiao
|
2022-05-13 15:01:41 +00:00
|
|
|
# SPDX-FileCopyrightText: 2022 UGent
|
2021-01-20 12:30:12 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
2022-05-13 15:01:41 +00:00
|
|
|
print_usage () {
|
|
|
|
echo "usage:"
|
|
|
|
echo " Script for load (or download+load) different driver and FPGA img without rebooting"
|
|
|
|
echo " no argument: Load .ko driver files and FPGA img (if system_top.bit.bin exist) in current dir with test_mode=0."
|
|
|
|
echo " 1st argument: If it is a NUMBER, it will be assigned to test_mode. Then load everything from current dir."
|
|
|
|
echo " 1st argument: If it is a string called \"remote\", it will download driver/FPGA and load everything."
|
|
|
|
echo " - 2nd argument (if exist) is the target directory name for downloading and reloading"
|
|
|
|
echo " - 3rd argument (if exist) is the value for test_mode"
|
|
|
|
echo " 1st argument: neither NUMBER nor \"remote\" nor a .tar.gz file, it is regarded as a directory and load everything from it."
|
|
|
|
echo " - 2nd argument (if exist) is the value for test_mode"
|
|
|
|
echo " 1st argument: a .tar.gz file, it will be unpacked then load from that unpacked directory"
|
|
|
|
echo " - 2nd argument (if exist) is the value for test_mode"
|
|
|
|
echo " "
|
|
|
|
}
|
|
|
|
|
2019-12-10 13:03:47 +00:00
|
|
|
checkModule () {
|
2022-05-13 15:01:41 +00:00
|
|
|
MODULE_input="$1"
|
|
|
|
if lsmod | grep "$MODULE_input" &> /dev/null ; then
|
|
|
|
echo "$MODULE_input is loaded!"
|
2019-12-10 13:03:47 +00:00
|
|
|
return 0
|
|
|
|
else
|
2022-05-13 15:01:41 +00:00
|
|
|
echo "$MODULE_input is not loaded!"
|
2019-12-10 13:03:47 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-05-13 15:01:41 +00:00
|
|
|
download_module () {
|
|
|
|
MODULE_input="$1"
|
|
|
|
TARGET_DIR_input="$2"
|
|
|
|
mkdir -p $TARGET_DIR_input
|
|
|
|
if [ "$MODULE_input" == "fpga" ]; then
|
|
|
|
wget -O $TARGET_DIR_input/system_top.bit.bin ftp://192.168.10.1/user_space/system_top.bit.bin
|
|
|
|
else
|
|
|
|
if [ "$MODULE_input" == "sdr" ]; then
|
|
|
|
wget -O $TARGET_DIR_input/$MODULE_input.ko ftp://192.168.10.1/driver/$MODULE_input.ko
|
|
|
|
else
|
|
|
|
wget -O $TARGET_DIR_input/$MODULE_input.ko ftp://192.168.10.1/driver/$MODULE_input/$MODULE_input.ko
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
sync
|
|
|
|
}
|
2019-12-10 13:03:47 +00:00
|
|
|
|
2022-05-13 15:01:41 +00:00
|
|
|
insert_check_module () {
|
|
|
|
TARGET_DIR_input="$1"
|
|
|
|
MODULE_input="$2"
|
|
|
|
rmmod $MODULE_input
|
|
|
|
if [[ -n $3 ]]; then
|
|
|
|
(set -x; insmod $TARGET_DIR_input/$MODULE_input.ko test_mode=$3)
|
2019-12-10 13:03:47 +00:00
|
|
|
else
|
2022-05-13 15:01:41 +00:00
|
|
|
(set -x; insmod $TARGET_DIR_input/$MODULE_input.ko)
|
|
|
|
fi
|
|
|
|
|
|
|
|
checkModule $MODULE_input
|
|
|
|
if [ $? -eq 1 ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
print_usage
|
|
|
|
|
2023-01-27 21:31:22 +00:00
|
|
|
insmod ad9361_drv.ko
|
|
|
|
insmod xilinx_dma.ko
|
|
|
|
# modprobe ad9361_drv
|
|
|
|
# modprobe xilinx_dma
|
2023-01-26 16:09:31 +00:00
|
|
|
modprobe mac80211
|
|
|
|
lsmod
|
|
|
|
|
2022-05-13 15:01:41 +00:00
|
|
|
TARGET_DIR=./
|
|
|
|
DOWNLOAD_FLAG=0
|
|
|
|
test_mode=0
|
|
|
|
|
|
|
|
if [[ -n $1 ]]; then
|
|
|
|
re='^[0-9]+$'
|
|
|
|
if ! [[ $1 =~ $re ]] ; then # not a number
|
|
|
|
if [ "$1" == "remote" ]; then
|
|
|
|
DOWNLOAD_FLAG=1
|
|
|
|
if [[ -n $2 ]]; then
|
|
|
|
TARGET_DIR=$2
|
|
|
|
fi
|
|
|
|
if [[ -n $3 ]]; then
|
|
|
|
test_mode=$3
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [[ "$1" == *".tar.gz"* ]]; then
|
|
|
|
set -x
|
|
|
|
tar_gz_filename=$1
|
|
|
|
TARGET_DIR=${tar_gz_filename%".tar.gz"}
|
|
|
|
mkdir -p $TARGET_DIR
|
|
|
|
rm -rf $TARGET_DIR/*
|
|
|
|
tar -zxvf $1 -C $TARGET_DIR
|
|
|
|
find $TARGET_DIR/ -name \*.ko -exec cp {} $TARGET_DIR/ \;
|
|
|
|
find $TARGET_DIR/ -name \*.bit.bin -exec cp {} $TARGET_DIR/ \;
|
|
|
|
set +x
|
|
|
|
else
|
|
|
|
TARGET_DIR=$1
|
|
|
|
fi
|
|
|
|
if [[ -n $2 ]]; then
|
|
|
|
test_mode=$2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else # is a number
|
|
|
|
test_mode=$1
|
2019-12-10 13:03:47 +00:00
|
|
|
fi
|
|
|
|
fi
|
2022-03-28 09:20:22 +00:00
|
|
|
|
2022-05-13 15:01:41 +00:00
|
|
|
echo TARGET_DIR $TARGET_DIR
|
|
|
|
echo DOWNLOAD_FLAG $DOWNLOAD_FLAG
|
|
|
|
echo test_mode $test_mode
|
|
|
|
|
2022-03-28 09:20:22 +00:00
|
|
|
#if ((($test_mode & 0x2) != 0)); then
|
|
|
|
tx_offset_tuning_enable=0
|
|
|
|
#else
|
|
|
|
# tx_offset_tuning_enable=1
|
|
|
|
#fi
|
|
|
|
|
|
|
|
echo tx_offset_tuning_enable $tx_offset_tuning_enable
|
|
|
|
|
2022-05-13 15:01:41 +00:00
|
|
|
if [ -d "$TARGET_DIR" ]; then
|
|
|
|
echo "\$TARGET_DIR is found!"
|
|
|
|
else
|
|
|
|
if [ $DOWNLOAD_FLAG -eq 0 ]; then
|
|
|
|
echo "\$TARGET_DIR is not correct. Please check!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-12-10 13:03:47 +00:00
|
|
|
fi
|
|
|
|
|
2022-05-13 15:01:41 +00:00
|
|
|
echo " "
|
2019-12-10 13:03:47 +00:00
|
|
|
|
2023-01-17 13:29:15 +00:00
|
|
|
killall hostapd
|
|
|
|
service dhcpcd stop #dhcp client. it will get secondary ip for sdr0 which causes trouble
|
|
|
|
killall dhcpd
|
|
|
|
killall wpa_supplicant
|
|
|
|
#service network-manager stop
|
|
|
|
ifconfig sdr0 down
|
2019-12-10 13:03:47 +00:00
|
|
|
|
2022-05-13 15:01:41 +00:00
|
|
|
rmmod sdr
|
2019-12-10 13:03:47 +00:00
|
|
|
|
2022-05-13 15:01:41 +00:00
|
|
|
if [ $DOWNLOAD_FLAG -eq 1 ]; then
|
|
|
|
download_module fpga $TARGET_DIR
|
2019-12-10 13:03:47 +00:00
|
|
|
fi
|
|
|
|
|
2022-05-13 15:01:41 +00:00
|
|
|
if [ -f "$TARGET_DIR/system_top.bit.bin" ]; then
|
|
|
|
./load_fpga_img.sh $TARGET_DIR/system_top.bit.bin
|
|
|
|
else
|
|
|
|
echo $TARGET_DIR/system_top.bit.bin not found. Skip reloading FPGA.
|
2022-05-16 10:23:01 +00:00
|
|
|
./load_fpga_img.sh fjdo349ujtrueugjhj
|
2019-12-10 13:03:47 +00:00
|
|
|
fi
|
|
|
|
|
2022-05-13 15:01:41 +00:00
|
|
|
./rf_init_11n.sh
|
2019-12-10 13:03:47 +00:00
|
|
|
|
2022-05-13 15:01:41 +00:00
|
|
|
MODULE_ALL="tx_intf rx_intf openofdm_tx openofdm_rx xpu sdr"
|
|
|
|
for MODULE in $MODULE_ALL
|
|
|
|
do
|
|
|
|
if [ $DOWNLOAD_FLAG -eq 1 ]; then
|
|
|
|
download_module $MODULE $TARGET_DIR
|
|
|
|
fi
|
|
|
|
if [ "$MODULE" == "sdr" ]; then
|
|
|
|
insert_check_module $TARGET_DIR $MODULE $test_mode
|
|
|
|
else
|
|
|
|
insert_check_module $TARGET_DIR $MODULE
|
|
|
|
fi
|
|
|
|
done
|
2019-12-10 13:03:47 +00:00
|
|
|
|
2023-01-17 13:29:15 +00:00
|
|
|
# [ -e /tmp/check_calib_inf.pid ] && kill -0 $(</tmp/check_calib_inf.pid)
|
|
|
|
# ./check_calib_inf.sh
|
2022-03-28 09:34:48 +00:00
|
|
|
|
2019-12-10 13:03:47 +00:00
|
|
|
echo the end
|
2022-05-13 15:01:41 +00:00
|
|
|
# dmesg
|
|
|
|
# lsmod
|