-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
Related to #27
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
#!/bin/bash | ||
|
||
# This script creates our custom firmware image | ||
# based on analog decices plutosdr-fw | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
# Required plutosdr-fw version | ||
REQUIRED_PLUTOSDR_FW_VERSION="v0.32" | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
|
||
#Check if env variable for Xilinx tools exists | ||
: "${VIVADO_SETTINGS?Need to set VIVADO_SETTINGS (e.g. /opt/Xilinx/Vivado/2019.1/settings64.sh)}" | ||
source $VIVADO_SETTINGS || (echo "Specified wrong Vivado settings path?"; exit 1;) | ||
|
||
#Check if env variable for Path to pluto sysroot directory exists | ||
: "${PLUTO_SYSROOT_DIR?Need to set PLUTO_SYSROOT_DIR}" | ||
|
||
SCRIPT_DIR=`pwd`/`dirname "$0"` | ||
cd $SCRIPT_DIR || exit 1 | ||
|
||
# Download the current plutosdr-fw image | ||
if [[ ! -d plutosdr-fw ]] | ||
This comment has been minimized.
Sorry, something went wrong. |
||
then | ||
echo "plutosdr-fw repository not found. Downloading it..." | ||
git clone --recurse-submodules -j8 https://github.com/analogdevicesinc/plutosdr-fw.git | ||
else | ||
echo "plutosdr-fw already exists. Skipping git clone." | ||
fi | ||
|
||
|
||
cd plutosdr-fw || (echo "Failed to cd"; exit 1) | ||
if [[ $REQUIRED_PLUTOSDR_FW_VERSION != $(git describe --tags) ]]; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
then | ||
echo "Got wrong plutosdr-fw version. Checking out "$REQUIRED_PLUTOSDR_FW_VERSION | ||
git reset --hard | ||
git submodule foreach --recursive git reset --hard | ||
git checkout $PLUTOSDR_FW_VERSION -b master | ||
git submodule update --recursive | ||
|
||
# Changes to buildroot | ||
BR_CONFIG=buildroot/configs/zynq_pluto_defconfig | ||
echo 'BR2_ROOTFS_OVERLAY="'"$PLUTOSDR_FW_ROOTOVERLAY"'"' >> $BR_CONFIG | ||
echo 'BR2_PACKAGE_LIBCONFIG=y' >> $BR_CONFIG | ||
echo 'BR2_PACKAGE_FFTW_SINGLE=y' >> $BR_CONFIG | ||
echo 'BR2_PACKAGE_TUNCTL=y' >> $BR_CONFIG | ||
echo 'BR2_PACKAGE_IPERF3=y' >> $BR_CONFIG | ||
echo 'BR2_PACKAGE_LLDPD=y' >> $BR_CONFIG | ||
|
||
# Changes to the linux kernel | ||
echo "Applying PREEMPT_RT kernel patch..." | ||
wget https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/4.19/older/patch-4.19-rt1.patch.gz | ||
gunzip patch-4.19-rt1.patch.gz | ||
cd linux || exit 1 | ||
patch -p1 < ../patch-4.19-rt1.patch | ||
|
||
# Configure RT kernel | ||
KERNEL_CONFIG=arch/arm/configs/zynq_pluto_defconfig | ||
echo "CONFIG_TUN=y" >> $KERNEL_CONFIG | ||
echo "CONFIG_PREEMPT_RT_FULL=y" >> $KERNEL_CONFIG | ||
else | ||
echo "plutosdr-fw already seems to be configured." | ||
fi | ||
This comment has been minimized.
Sorry, something went wrong.
dl1com
Contributor
|
||
|
||
|
||
## Init rootfs overlay structure | ||
PLUTOSDR_FW_ROOTOVERLAY=$SCRIPT_DIR/plutosdr-fw/rootfs-overlay | ||
if [[ ! -d $PLUTOSDR_FW_ROOTOVERLAY ]] | ||
This comment has been minimized.
Sorry, something went wrong. |
||
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 | ||
|
||
cd $SCRIPT_DIR || exit 1 | ||
|
||
## Create sysroot | ||
./create_sysroot.sh || exit 1 | ||
|
||
# Copy libfec and liquid-dsp to rootfs overlay. These libs are not built with buildroot | ||
# so we have to manually copy them. | ||
cp $PLUTO_SYSROOT_DIR/usr/lib/libliquid.so $PLUTOSDR_FW_ROOTOVERLAY/usr/lib/ | ||
cp $PLUTO_SYSROOT_DIR/usr/lib/libfec.so $PLUTOSDR_FW_ROOTOVERLAY/usr/lib | ||
|
||
## Build Main Apps | ||
This comment has been minimized.
Sorry, something went wrong.
dl1com
Contributor
|
||
echo "Building main application..." | ||
cd $SCRIPT_DIR/../ || exit 1 | ||
if [[ ! -d cmake-build ]] | ||
then | ||
mkdir cmake-build | ||
fi | ||
cd cmake-build || exit 1 | ||
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 .. | ||
|
||
# Create VERSION file | ||
touch $PLUTOSDR_FW_ROOTOVERLAY/root/VERSION | ||
echo "hnap "`git describe --tags` > $PLUTOSDR_FW_ROOTOVERLAY/root/VERSION | ||
echo "plutosdr-fw "$PLUTOSDR_FW_VERSION >> $PLUTOSDR_FW_ROOTOVERLAY/root/VERSION | ||
|
||
## Copy network init script to rootfs | ||
echo "Copy network autoconfig script to rootfs..." | ||
cp startup_scripts/* $PLUTOSDR_FW_ROOTOVERLAY/etc/init.d/ | ||
|
||
|
||
## 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/ | ||
|
||
cd $SCRIPT_DIR/plutosdr-fw/ || exit 1 | ||
make || exit 1 | ||
cp build/pluto.frm ../ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
|
||
# This script customizes the plutosdr-fw sysroot image to our needs. | ||
# NOTE: you only need this script if you want to rebuild the sysroot | ||
# folder, i.e. after a new release of the plutosdr-fw! | ||
# Usually it is enough to download an already customized sysroot | ||
# from the releases page. | ||
|
||
|
||
#Check if env variable for Path to pluto sysroot directory exists | ||
: "${PLUTO_SYSROOT_DIR?Need to set PLUTO_SYSROOT_DIR}" | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
dl1com
Contributor
|
||
SCRIPT_DIR=`pwd`/`dirname "$0"` | ||
cd $SCRIPT_DIR || exit 1 | ||
|
||
mkdir .tmp_create_sysroot | ||
cd .tmp_create_sysroot || exit 1 | ||
|
||
echo "Downloading fftw3" | ||
wget http://www.fftw.org/fftw-3.3.8.tar.gz | ||
tar -xzf fftw-3.3.8.tar.gz | ||
|
||
echo "Installing fftw3" | ||
cd fftw-3.3.8 || exit 1 | ||
./configure arm --enable-float --enable-shared --host=arm-linux-gnueabihf --prefix="$PLUTO_SYSROOT_DIR/usr/" CC="arm-linux-gnueabihf-gcc --sysroot=$PLUTO_SYSROOT_DIR/" | ||
make install | ||
|
||
echo "Downloading libconfig" | ||
wget https://hyperrealm.github.io/libconfig/dist/libconfig-1.7.2.tar.gz | ||
tar -xzf libconfig-1.7.2.tar.gz | ||
echo "Installing libconfig" | ||
cd libconfig-1.7.2 || exit 1 | ||
./configure --host=arm-linux-gnueabihf --prefix="$PLUTO_SYSROOT_DIR/usr/" CC="arm-linux-gnueabihf-gcc --sysroot=$PLUTO_SYSROOT_DIR/" | ||
make install | ||
|
||
cd $SCRIPT_DIR/../libfec || exit 1 | ||
echo "Installing libfec..." | ||
./configure arm --host=arm-linux-gnueabihf --prefix="$PLUTO_SYSROOT_DIR/usr/" CC="arm-linux-gnueabihf-gcc --sysroot=$PLUTO_SYSROOT_DIR/" | ||
make install | ||
|
||
echo "Installing liquid-dsp..." | ||
cd ../liquid-dsp || exit 1 | ||
./bootstrap.sh | ||
./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 install | ||
|
||
echo "Cleaning up..." | ||
cd $SCRIPT_DIR || exit 1 | ||
rm -R .tmp_create_sysroot | ||
|
||
SYSROOT_NAME="sysroot-custom-"`git describe --tags`".tar.gz" | ||
tar -czf $SYSROOT_NAME $PLUTO_SYSROOT_DIR | ||
echo "Created sysroot archive "$SYSROOT_NAME | ||
exit 0 |
This file was deleted.
Typo: "devices"