Skip to content

Commit

Permalink
Add scripts and files required to build custom firmware
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasostendorf committed Jun 17, 2020
1 parent 68dd5f4 commit 7df45ec
Show file tree
Hide file tree
Showing 5 changed files with 334 additions and 0 deletions.
138 changes: 138 additions & 0 deletions AD9361_256kSPS.ftr
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Generated with the MATLAB AD9361 Filter Design Wizard 16.1.1-gd3d6024
# Generated 24-May-2016 14:07:59
# Inputs:
# Data Sample Frequency = 2048000 Hz
TX 3 GAIN 0 INT 4
RX 3 GAIN -6 DEC 4
RTX 1048576000 65536000 32768000 16384000 8192000 2048000
RRX 1048576000 65536000 32768000 16384000 8192000 2048000
BWTX 1701126
BWRX 1703632
84,191
-72,-88
97,331
-128,-40
-69,241
-303,-99
-354,-22
-569,-349
-622,-375
-717,-611
-637,-573
-531,-604
-282,-396
-39,-230
238,65
408,239
490,393
402,349
210,227
-79,-46
-346,-300
-544,-534
-572,-594
-436,-506
-135,-221
227,137
565,512
747,737
716,766
444,526
6,103
-489,-420
-874,-853
-1026,-1070
-856,-948
-393,-512
256,155
894,841
1320,1342
1362,1451
967,1101
202,333
-724,-638
-1535,-1531
-1946,-2029
-1772,-1923
-983,-1153
248,114
1587,1544
2609,2678
2927,3100
2311,2537
792,999
-1313,-1204
-3437,-3479
-4888,-5097
-5009,-5347
-3367,-3752
122,-201
5120,4964
10914,11002
16543,16896
21005,21582
23470,24174
23470,24174
21005,21582
16543,16896
10914,11002
5120,4964
122,-201
-3367,-3752
-5009,-5347
-4888,-5097
-3437,-3479
-1313,-1204
792,999
2311,2537
2927,3100
2609,2678
1587,1544
248,114
-983,-1153
-1772,-1923
-1946,-2029
-1535,-1531
-724,-638
202,333
967,1101
1362,1451
1320,1342
894,841
256,155
-393,-512
-856,-948
-1026,-1070
-874,-853
-489,-420
6,103
444,526
716,766
747,737
565,512
227,137
-135,-221
-436,-506
-572,-594
-544,-534
-346,-300
-79,-46
210,227
402,349
490,393
408,239
238,65
-39,-230
-282,-396
-531,-604
-637,-573
-717,-611
-622,-375
-569,-349
-354,-22
-303,-99
-69,241
-128,-40
97,331
-72,-88
84,191
99 changes: 99 additions & 0 deletions config-firmware.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/bin/bash

#Script generates the custom root system overlay for the Adalm Pluto linux system firmware

#Path to the plutosdr firmware directory
PLUTOSDR_FW_ROOTOVERLAY=$HOME/plutosdr-fw/rootfs-overlay

#Path to pluto sysroot directory
PLUTO_SYSROOT_DIR=$HOME/pluto-0.31.sysroot

SCRIPT_DIR=`pwd`/`dirname "$0"`
cd $SCRIPT_DIR

## Init rootfs overlay structure
if [[ ! -d $PLUTOSDR_FW_ROOTOVERLAY ]]
then
mkdir $PLUTOSDR_FW_ROOTOVERLAY
fi
if [[ ! -d $PLUTOSDR_FW_ROOTOVERLAY/usr/ ]]
then
mkdir $PLUTOSDR_FW_ROOTOVERLAY/usr/
fi
if [[ ! -d $PLUTOSDR_FW_ROOTOVERLAY/usr/lib/ ]]
then
mkdir $PLUTOSDR_FW_ROOTOVERLAY/usr/lib/
fi
if [[ ! -d $PLUTOSDR_FW_ROOTOVERLAY/root/ ]]
then
mkdir $PLUTOSDR_FW_ROOTOVERLAY/root/
fi
if [[ ! -d $PLUTOSDR_FW_ROOTOVERLAY/etc/ ]]
then
mkdir $PLUTOSDR_FW_ROOTOVERLAY/etc/
fi
if [[ ! -d $PLUTOSDR_FW_ROOTOVERLAY/etc/init.d/ ]]
then
mkdir $PLUTOSDR_FW_ROOTOVERLAY/etc/init.d/
fi

## Build libfec
echo "Building libfec..."
cd libfec
./configure arm --host=arm-linux-gnueabihf --prefix="$PLUTO_SYSROOT_DIR/usr/" CC="arm-linux-gnueabihf-gcc --sysroot=$PLUTO_SYSROOT_DIR/"
make
make install

cp $PLUTO_SYSROOT_DIR/usr/lib/libfec.so $PLUTOSDR_FW_ROOTOVERLAY/usr/lib/
cd ..

## Build liquidsdr
echo "Building liquidsdr..."
cd liquid-dsp
./configure arm --host=arm-linux-gnueabihf --prefix="$PLUTO_SYSROOT_DIR/usr/" CC="arm-linux-gnueabihf-gcc --sysroot=$PLUTO_SYSROOT_DIR"

# Configure somehow does not correctly identify malloc and realloc
# and redefines them in the generated config.h script as rpl_malloc.
# This makes the code unusable, therefore we delete this:
sed -i '/rpl_realloc/d' config.h
sed -i '/rpl_malloc/d' config.h

make
make install
cp $PLUTO_SYSROOT_DIR/usr/lib/libliquid.so $PLUTOSDR_FW_ROOTOVERLAY/usr/lib/
cd ..

## Build Main Apps
echo "Building main application..."
if [[ ! -d cmake-build ]]
then
mkdir cmake-build
fi
cd cmake-build
cmake -DCMAKE_TOOLCHAIN_FILE=CmakeArmToolchain.cmake ..
make basestation
make client
make client-calib
cp basestation $PLUTOSDR_FW_ROOTOVERLAY/root/
cp client $PLUTOSDR_FW_ROOTOVERLAY/root/
cp client-calib $PLUTOSDR_FW_ROOTOVERLAY/root/
cd ..

## Copy network init script to rootfs
echo "Copy network autoconfig script to rootfs..."
cd startup_scripts
cp S101transceiver.sh $PLUTOSDR_FW_ROOTOVERLAY/etc/init.d/
cp S102iperf.sh $PLUTOSDR_FW_ROOTOVERLAY/etc/init.d/
cp S103basestation.sh $PLUTOSDR_FW_ROOTOVERLAY/etc/init.d/
cd ..

## Copy FIR filter to rootfs
echo "Copy FIR filter coefficients to rootfs..."
cp AD9361_256kSPS.ftr $PLUTOSDR_FW_ROOTOVERLAY/root/

## Copy the default configuration file to rootfs
echo "Copy config.txt to rootfs..."
cp config.txt $PLUTOSDR_FW_ROOTOVERLAY/root/

echo "Done."

16 changes: 16 additions & 0 deletions startup_scripts/S101transceiver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

# Configure pluto platform so that the waveform can be started
# Name of the custom FIR filter
FILTER=AD9361_256kSPS.ftr

# Networking: create tap devices
TAP_IP_ADDR=`fw_printenv -n hnap_tap_ip`

tunctl -t tap0
ifconfig tap0 $TAP_IP_ADDR
ifconfig tap0 up

# Install custom FIR filter
cat /root/$FILTER > /sys/bus/iio/devices/iio:device1/filter_fir_config

39 changes: 39 additions & 0 deletions startup_scripts/S102iperf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh

[ -f /usr/bin/iperf3 ] || exit 0

start() {
printf "Starting iperf3 server: "
iperf3 -s &
echo "done"
}


stop() {
printf "Stopping iperf3: "
killall iperf3
echo "done"
}

restart() {
stop
start
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
*)
echo "Usage: $0 {start|stop|reload|restart}"
exit 1
esac

exit $?
42 changes: 42 additions & 0 deletions startup_scripts/S103basestation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

[ -f /root/basestation ] || exit 0

start() {
if [ `fw_printenv -n hnap_bs_autostart` = 1 ]
then
printf "Starting basestation application"
/root/./basestation -t 0 -g 70 &
fi
echo "done"
}


stop() {
printf "Stopping basestation: "
killall basestation
echo "done"
}

restart() {
stop
start
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
*)
echo "Usage: $0 {start|stop|reload|restart}"
exit 1
esac

exit $?

0 comments on commit 7df45ec

Please sign in to comment.