openwifi/user_space/sdcard_boot_update.sh

93 lines
2.3 KiB
Bash
Raw Normal View History

2019-12-10 13:03:47 +00:00
#!/bin/bash
2021-01-20 12:30:12 +00:00
2021-02-03 14:55:07 +00:00
# Author: Xianjun Jiao
# SPDX-FileCopyrightText: 2019 UGent
2021-01-20 12:30:12 +00:00
# SPDX-License-Identifier: AGPL-3.0-or-later
2020-03-04 18:39:12 +00:00
if [ "$#" -ne 1 ]; then
echo "You must enter the \$BOARD_NAME as argument"
2020-04-27 07:37:04 +00:00
echo "Like: adrv9364z7020 adrv9361z7035 zc706_fmcs2 zed_fmcs2 zc702_fmcs2 zcu102_fmcs2 zcu102_9371"
2020-03-04 18:39:12 +00:00
exit 1
fi
BOARD_NAME=$1
2020-04-27 07:37:04 +00:00
if [ "$BOARD_NAME" != "zc706_fmcs2" ] && [ "$BOARD_NAME" != "zc702_fmcs2" ] && [ "$BOARD_NAME" != "zed_fmcs2" ] && [ "$BOARD_NAME" != "adrv9361z7035" ] && [ "$BOARD_NAME" != "adrv9364z7020" ] && [ "$BOARD_NAME" != "zcu102_fmcs2" ] && [ "$BOARD_NAME" != "zcu102_9371" ]; then
echo "\$BOARD_NAME is not correct. Please check!"
exit 1
else
echo "\$BOARD_NAME is found!"
fi
if [ "$BOARD_NAME" == "zcu102_fmcs2" ] || [ "$BOARD_NAME" == "zcu102_9371" ]; then
dtb_filename="system.dtb"
image_filepath="arch/arm64/boot/"
image_filename="Image"
LINUX_KERNEL_SRC_DIR_NAME=adi-linux-64
else
dtb_filename="devicetree.dtb"
image_filepath="arch/arm/boot/"
image_filename="uImage"
LINUX_KERNEL_SRC_DIR_NAME=adi-linux
fi
echo $dtb_filename
echo $image_filepath
echo $image_filename
2019-12-10 13:03:47 +00:00
set -x
mv BOOT.BIN BOOT.BIN.bak
2019-12-10 13:03:47 +00:00
sync
2020-03-04 18:39:12 +00:00
wget ftp://192.168.10.1/kernel_boot/boards/$BOARD_NAME/output_boot_bin/BOOT.BIN
if [ -f "./BOOT.BIN" ]; then
echo "BOOT.BIN downloaded!"
else
echo "WARNING! BOOT.BIN not downloaded! Old file used!"
mv BOOT.BIN.bak BOOT.BIN
# exit 1
fi
2019-12-10 13:03:47 +00:00
sync
mv $image_filename $image_filename.bak
2019-12-10 13:03:47 +00:00
sync
2020-04-27 07:37:04 +00:00
wget ftp://192.168.10.1/$LINUX_KERNEL_SRC_DIR_NAME/$image_filepath/$image_filename
if [ -f "./$image_filename" ]; then
echo "$image_filename downloaded!"
else
echo "WARNING! $image_filename not downloaded! Old file used!"
mv $image_filename.bak $image_filename
# exit 1
fi
2019-12-10 13:03:47 +00:00
sync
mv $dtb_filename $dtb_filename.bak
2019-12-10 13:03:47 +00:00
sync
2020-04-27 07:37:04 +00:00
wget ftp://192.168.10.1/kernel_boot/boards/$BOARD_NAME/$dtb_filename
if [ -f "./$dtb_filename" ]; then
echo "$dtb_filename downloaded!"
else
echo "WARNING! $dtb_filename not downloaded! Old file used!"
mv $dtb_filename.bak $dtb_filename
# exit 1
fi
2019-12-10 13:03:47 +00:00
sync
2019-12-10 13:03:47 +00:00
#slepp 0.5
2020-03-04 18:39:12 +00:00
mount /dev/mmcblk0p1 /mnt
2019-12-10 13:03:47 +00:00
sync
#sleep 0.5
2020-03-04 18:39:12 +00:00
cp BOOT.BIN /mnt/ -f
2020-04-27 07:37:04 +00:00
rm /mnt/Image -f
rm /mnt/uImage -f
cp $image_filename /mnt/ -f
rm /mnt/*.dtb -f
cp $dtb_filename /mnt/ -f
cd /mnt/
sync
cd ~
2019-12-10 13:03:47 +00:00
#sleep 0.5
2020-03-04 18:39:12 +00:00
umount /mnt
2019-12-10 13:03:47 +00:00
sync
#sleep 3
sudo reboot now