Skip to content

Commit

Permalink
Show Version info (#49)
Browse files Browse the repository at this point in the history
* Renamed path to firmware overlay data

* [#48] Show HNAP version in MOTD and website

* [#8] Show motd warning in case root passwd is default

* Redirect version checker to HNAP Github releases

* Remove obsole png files in buildroot msd/img folder

* Don't fail rm over nonexistant files

* Re-Add information about libiio usage as we still support this

* Fix version comparison for our version string format

* Insert HNAP version to version.js instead of firmware version
  • Loading branch information
chris007de authored Nov 13, 2020
1 parent 27c614d commit 48b157d
Show file tree
Hide file tree
Showing 13 changed files with 675 additions and 17 deletions.
27 changes: 10 additions & 17 deletions build_scripts/build_firmware.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,6 @@ else
echo "Linux kernel seems to be already configured."
fi


## Init rootfs overlay structure
mkdir -p $FW_OVERLAY/usr/lib
mkdir -p $FW_OVERLAY/root
mkdir -p $FW_OVERLAY/etc/init.d

cd $SCRIPT_DIR || exit 1

## Create sysroot
Expand All @@ -105,33 +99,32 @@ sed -i '/STATUS_SYSROOT_GOT_LIBLIQUID/d' $BUILD_STATUS

# Copy libfec and liquid-dsp to rootfs overlay. These libs are not built with buildroot
# so we have to manually copy them.
mkdir -p $FW_OVERLAY/usr/lib
cp $SYSROOT_DIR/usr/lib/libliquid.so $FW_OVERLAY/usr/lib/
cp $SYSROOT_DIR/usr/lib/libfec.so $FW_OVERLAY/usr/lib

## Build Main Apps
./build_standalone_binaries.sh
cd $BUILD_DIR || exit 1
mkdir -p $FW_OVERLAY/root
cp basestation client client-calib $FW_OVERLAY/root/


# Create VERSION file
touch $FW_OVERLAY/root/VERSION
echo "hnap "`git describe --tags` > $FW_OVERLAY/root/VERSION
echo "plutosdr-fw "$PLUTOSDR_FW_TAG >> $FW_OVERLAY/root/VERSION

## Copy network init script to rootfs
## Copy firmware overlay files to rootfs
cd $SRC_DIR || exit 1
echo "Copy network autoconfig script to rootfs..."
cp startup_scripts/* $FW_OVERLAY/etc/init.d/

echo "Copy overlay files to firmware rootfs..."
cp -R overlay/fw/* $FW_OVERLAY/

## Copy FIR filter to rootfs
echo "Copy FIR filter coefficients to rootfs..."
cp AD9361_256kSPS.ftr $FW_OVERLAY/root/
echo "Copy overlay files to buildroot..."
cp -R overlay/buildroot/* $PLUTOSDR_FW_DIR/buildroot/board/pluto/

## Copy the default configuration file to rootfs
echo "Copy config.txt to rootfs..."
cp config.txt $FW_OVERLAY/root/
echo "Removing unnecessary files from buildroot"
cd $PLUTOSDR_FW_DIR/buildroot/board/pluto/msd/img
rm -f ADI_Logo_AWP.png ez.png fb.png GNURadio_logo.png gp.png ig.png li.png mathworks_logo.png osc128.png PlutoSDR.png prof_blue.png SDR-Sharp.png sdrangel.png ss.png sw.png tw.png yk.png yt.png

cd $PLUTOSDR_FW_DIR || exit 1
make || exit 1
Expand Down
86 changes: 86 additions & 0 deletions overlay/buildroot/S45msd
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/bin/sh
# Server-side demuxing by default

source /etc/device_config

CONF=/opt/config.txt
file=/sys/kernel/config/usb_gadget/composite_gadget/functions/mass_storage.0/lun.0/file
img=/opt/vfat.img

patch_html_page() {
LINUX=`uname -a | tr / - | tr '\n' ';' ; echo -n $(nproc) "core(s)"`
MODEL=`cat /etc/libiio.ini | grep hw_model= | cut -d '=' -f 2`
SERIAL=`cat /sys/kernel/config/usb_gadget/composite_gadget/strings/0x409/serialnumber`
MACHOST=`cat /sys/kernel/config/usb_gadget/composite_gadget/functions/rndis.0/host_addr`
MAC=`cat /sys/kernel/config/usb_gadget/composite_gadget/functions/rndis.0/dev_addr`
IIO=`iio_info 2>/dev/null | grep "Library version:"`
BUILD=`grep device-fw /opt/VERSIONS | cut -d ' ' -f 2`
FPGA=`grep hdl /opt/VERSIONS | cut -d ' ' -f 2`
ROOTFS=`grep buildroot /opt/VERSIONS | cut -d ' ' -f 2`
UBOOT=`cat /proc/cmdline | tr "=" "\n" | grep "U-Boot"`

sed -i -e "s/#LINUX#/$LINUX/g" -e "s/#MODEL#/$MODEL/g" -e "s/#SERIAL#/$SERIAL/g" -e "s/#MACHOST#/$MACHOST/g" -e "s/#MAC#/$MAC/g" -e "s/#IIO#/$IIO/g" -e "s/#BUILD#/$BUILD/g" -e "s/#FPGA#/$FPGA/g" -e "s/#ROOTFS#/$ROOTFS/g" -e "s/#UBOOT#/$UBOOT/g" $1

CALLSIGN=$(fw_printenv -n hnap_callsign)
PLATFORM=$(grep plutosdr-fw /root/VERSION)
HNAP=$(grep hnap /root/VERSION | cut -d' ' -f2)

sed -i -e "s/#CALLSIGN#/$CALLSIGN/g" -e "s/#PLATFORM#/$PLATFORM/g" -e "s/#HNAP#/$HNAP/g" $1
sed -i -e "s/#CALLSIGN#/$CALLSIGN/g" -e "s/#PLATFORM#/$PLATFORM/g" -e "s/#HNAP#/$HNAP/g" /etc/motd

sed -i -e "s/#BUILD#/$HNAP/g" $2

# Warning because of default root pw
PWWARNING=""
SHADOW="$(grep -E '^root:' /etc/shadow 2>/dev/null)"
SALT=$(echo "${SHADOW}" | sed -n 's/root:\$5\$//;s/\$.*//p')
HASH=$(mkpasswd -msha-256 analog "$SALT")

if echo "${SHADOW}" | grep -q "${HASH}"; then
PWWARNING="The default password for the 'root' user has not been changed.\n"
PWWARNING="${PWWARNING}This is a security risk - please login as the 'root' user and type 'device_passwd' to set a new password"
fi
sed -i -e "s/#PWWARNING#/$PWWARNING/g" /etc/motd
}


case "$1" in
start)
echo -n "Starting MSD Daemon: "
patch_html_page /www/index.html /www/img/version.js
losetup /dev/loop7 $img -o 512
mount /dev/loop7 /mnt/msd

if [ "$TARGET" == "m2k" ]; then
cp /opt/${CALIBFILENAME} /mnt
md5sum /mnt/msd/${CALIBFILENAME} > /opt/${CALIBFILENAME}.md5
fi

cp $CONF /mnt/msd
md5sum /mnt/msd/config.txt > /opt/config.md5

cp -a /www/* /mnt/msd
mv /mnt/msd/index.html /mnt/msd/info.html
umount /mnt/msd
echo $img > $file

start-stop-daemon -S -b -q -m -p /var/run/update.pid -x /bin/sh -- /sbin/update.sh
[ $? = 0 ] && echo "OK" || echo "FAIL"
;;

stop)
echo -n "Stopping MSD Daemon: "
start-stop-daemon -K -q -p /var/run/update.pid 2>/dev/null
[ $? = 0 ] && echo "OK" || echo "FAIL"
;;

restart)
$0 stop
sleep 1
$0 start
;;

*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
Loading

0 comments on commit 48b157d

Please sign in to comment.