From d5f27f228bae2481c977d8cc8715ca05ecb6201e Mon Sep 17 00:00:00 2001 From: "Christian W. Zuckschwerdt" Date: Tue, 28 Sep 2021 07:07:47 +0200 Subject: [PATCH] Add workflow --- .github/workflows/release.yml | 37 ++++++++ README.md | 57 ++++++++++++ Toolchain-arm-linux-gnueabi.cmake | 30 ++++++ build.sh | 146 ++++++++++++++++++++++++++++++ 4 files changed, 270 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 README.md create mode 100644 Toolchain-arm-linux-gnueabi.cmake create mode 100755 build.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..75cd460 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,37 @@ +name: Create release +on: workflow_dispatch + +jobs: + release_job: + runs-on: ubuntu-latest + name: Build Release + steps: + - uses: actions/checkout@v2 + - name: Build + # note: crossbuild-essential-armhf on 18.04 is GCC-7.2, on 20.04 GCC-9.2 + # GCC-7.2 has GLIBC trouble on SoapyRemote avahi linking + # GCC-9.2 has stropts.h trouble with socat + run: | + sudo apt-get install -y git rsync gcc-8-arm-linux-gnueabihf g++-8-arm-linux-gnueabihf cmake scons autoconf bison yodl + sudo update-alternatives --install /usr/bin/arm-linux-gnueabihf-gcc arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc-8 100 --slave /usr/bin/arm-linux-gnueabihf-g++ arm-linux-gnueabihf-g++ /usr/bin/arm-linux-gnueabihf-g++-8 + ./build.sh + - name: Get Release tag + run: echo "RELEASE_VERSION=$(date +%F)" >> $GITHUB_ENV + - uses: actions/create-release@v1 + id: create_release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.RELEASE_VERSION }} + release_name: Release ${{ env.RELEASE_VERSION }} + body_path: RELEASE-INFO.md + draft: true + prerelease: true + - uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: plutosdr-apps.tar.gz + asset_name: plutosdr-apps-${{ env.RELEASE_VERSION }}.tar.gz + asset_content_type: application/gzip diff --git a/README.md b/README.md new file mode 100644 index 0000000..594df20 --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +# Prebuilt SoapySDR and rtl_433 apps for Pluto SDR + +This is a build action to create [binary releases](https://github.com/triq-org/PlutoSDR-Apps/releases) +for the [ADALM-Pluto SDR](https://www.analog.com/en/design-center/evaluation-hardware-and-software/evaluation-boards-kits/adalm-pluto.html#eb-overview). + +You mainly get [SoapySDR](https://github.com/pothosware/SoapySDR/), +the [SoapyPlutoSDR](https://github.com/pothosware/SoapyPlutoSDR/) module, +and [rtl_433](https://github.com/merbanan/rtl_433). +But there is also +[rx_tools](https://github.com/rxseger/rx_tools), +[tx_tools](https://github.com/triq-org/tx_tools), +[SoapyRemote](https://github.com/pothosware/SoapyRemote), +[chrony](https://chrony.tuxfamily.org/), +[gpsd](https://gitlab.com/gpsd/gpsd), +and for testing +[iperf](https://github.com/esnet/iperf), +[socat](http://repo.or.cz/socat). +Let me know what other tools would be useful. + +## Using + +Download [a Release](https://github.com/triq-org/PlutoSDR-Apps/releases), +then copy to the Pluto and unpack to `/usr` + +## Notes on the compiler toolchain + +If you want to compile yourself you need a compiler toolchain. +You want a host target of `arm-linux-gnueabihf`, a number of options are available: + +### Using Debian (or Ubuntu) crossbuild toolchain + +Simply install the `crossbuild-essential-armhf` meta package. + +Toolchain path will be `/usr` and is already setup. + +### Using ARM.com toolchain (previously Linaro) + +You can use the ARM.com (previously Linaro) supplied compiler. + +See [GNU Toolchain for the A-profile Architecture](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads/8-2-2019-01). +You want the download "AArch32 target with hard float (arm-linux-gnueabihf)", then just unpack. + +Toolchain path will be `DESTDIR/gcc-arm-8.2-2019.01-x86_64-arm-linux-gnueabihf` + +### Using Xilinx 2019.1 SDK toolchain + +You can use the Xilinix provided compiler. +The download needs an account though and there is no easy unattended install. + +See [Xilinx Software Development Kit (XSDK)](https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/vitis/archive-sdk.html). +You want the Software Development Kit Standalone WebInstall Client - 2019.1 Lightweight Installer Download, +then run `sh Xilinx_SDK_2019.1_0524_1430_Lin64.bin` + +We only need tools from /opt/Xilinx/SDK/2019.1/gnu/aarch32/lin/gcc-arm-linux-gnueabi +You might want to repackage the compiler base dir for unattended install. + +Toolchain path will be `/opt/Xilinx/SDK/2019.1/gnu/aarch32/lin/gcc-arm-linux-gnueabi` diff --git a/Toolchain-arm-linux-gnueabi.cmake b/Toolchain-arm-linux-gnueabi.cmake new file mode 100644 index 0000000..f61941a --- /dev/null +++ b/Toolchain-arm-linux-gnueabi.cmake @@ -0,0 +1,30 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm) +# Set to plutosdr-fw sysroot dir +if(DEFINED ENV{sysroot}) + set(CMAKE_SYSROOT $ENV{sysroot}) +else() + set(CMAKE_SYSROOT $ENV{HOME}/staging) +endif() +# Set to output dir +if(DEFINED ENV{stagedir}) + set(CMAKE_STAGING_PREFIX $ENV{stagedir}) +else() + set(CMAKE_STAGING_PREFIX $ENV{HOME}/stage) +endif() +# Set for SoapySDR to locate it's module search path (/usr/lib/SoapySDR/modules0.7) +set(CMAKE_INSTALL_PREFIX:PATH /usr) +# Set to cross compiler location +if(DEFINED ENV{tools}) + set(tools $ENV{tools}) +else() + set(tools /usr) +endif() +set(CMAKE_C_COMPILER ${tools}/bin/arm-linux-gnueabihf-gcc) +set(CMAKE_CXX_COMPILER ${tools}/bin/arm-linux-gnueabihf-g++) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) +# Set for Soapy modules and rtl_433 to locate staged SoapySDR libs +set(CMAKE_PREFIX_PATH ${CMAKE_STAGING_PREFIX}) diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..9318aa6 --- /dev/null +++ b/build.sh @@ -0,0 +1,146 @@ +#!/bin/bash + +set -e + +export builddir="${builddir:-$(pwd)}" + +date +%F >"${builddir}/RELEASE-VERSION.txt" +export releaseinfo="${builddir}/RELEASE-INFO.md" +echo -n >"${releaseinfo}" + +# Setup Toolchain + +if [ -z "${tools}" -a -n "$(command -v arm-linux-gnueabihf-gcc)" ] ; then + export tools=$(dirname $(dirname $(command -v arm-linux-gnueabihf-gcc))) + echo "- Compiler: $(arm-linux-gnueabihf-gcc --version | head -1)" >>"${releaseinfo}" +fi + +if [ -z "${tools}" -a -d "gcc-arm-8.2-2019.01-x86_64-arm-linux-gnueabihf" ] ; then + export tools="${builddir}/gcc-arm-8.2-2019.01-x86_64-arm-linux-gnueabihf" + export PATH="${tools}/bin:$PATH" + echo '- Compiler: gcc-arm-8.2-2019.01-x86_64-arm-linux-gnueabihf' >>"${releaseinfo}" +fi + +if [ -z "${tools}" -a -d "/opt/Xilinx/SDK/2019.1/gnu/aarch32/lin/gcc-arm-linux-gnueabi" ] ; then + export tools="/opt/Xilinx/SDK/2019.1/gnu/aarch32/lin/gcc-arm-linux-gnueabi" + export PATH="${tools}/bin:$PATH" + echo "- Compiler: $(arm-linux-gnueabihf-gcc --version | head -1)" >>"${releaseinfo}" +fi + +if [ -z "${tools}" ] ; then + echo 'Toolchain "arm-linux-gnueabihf" not found. On Debian try:' + echo '$ sudo apt-get install -y crossbuild-essential-armhf' + echo 'Or a standalone toolchain:' + echo '$ wget https://developer.arm.com/-/media/Files/downloads/gnu-a/8.2-2019.01/gcc-arm-8.2-2019.01-x86_64-arm-linux-gnueabihf.tar.xz' + echo '$ tar xf gcc-arm-8.2-2019.01-x86_64-arm-linux-gnueabihf.tar.xz' + exit 1 +fi + +# Setup Sysroot + +if [ ! -d staging ] ; then + [ -f sysroot-v0.34.tar.gz ] || wget https://github.com/analogdevicesinc/plutosdr-fw/releases/download/v0.34/sysroot-v0.34.tar.gz + tar xzf sysroot-v0.34.tar.gz +fi +echo '- plutosdr-fw: sysroot v0.34' >>"${releaseinfo}" +export sysroot="${sysroot:-${builddir}/staging}" +export stagedir="${stagedir:-${builddir}/stage}" +export toolchain="${toolchain:-${builddir}/Toolchain-arm-linux-gnueabi.cmake}" + +# Compile Apps + +[ -d SoapySDR ] || git clone https://github.com/pothosware/SoapySDR.git +pushd SoapySDR +git checkout feat-ratefmt +echo -n '- SoapySDR: ' >>"${releaseinfo}" +git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}" +rm -rf build ; mkdir build ; pushd build +cmake -DCMAKE_TOOLCHAIN_FILE="${toolchain}" -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_PYTHON=OFF -DENABLE_PYTHON3=OFF .. && make VERBOSE=1 && make install +popd ; popd + +[ -d SoapyPlutoSDR ] || git clone https://github.com/pothosware/SoapyPlutoSDR.git +pushd SoapyPlutoSDR +echo -n '- SoapyPlutoSDR: ' >>"${releaseinfo}" +git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}" +rm -rf build ; mkdir build ; pushd build +cmake -DCMAKE_TOOLCHAIN_FILE="${toolchain}" -DCMAKE_INSTALL_PREFIX=/usr -DSoapySDR_DIR="${stagedir}/share/cmake/SoapySDR" .. && make VERBOSE=1 && make install +popd ; popd + +[ -d SoapyRemote ] || git clone https://github.com/pothosware/SoapyRemote.git +pushd SoapyRemote +echo -n '- SoapyRemote: ' >>"${releaseinfo}" +git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}" +rm -rf build ; mkdir build ; pushd build +cmake -DCMAKE_TOOLCHAIN_FILE="${toolchain}" -DCMAKE_INSTALL_PREFIX=/usr -DSoapySDR_DIR="${stagedir}/share/cmake/SoapySDR" .. && make VERBOSE=1 && make install +popd ; popd + +[ -d rtl_433 ] || git clone https://github.com/merbanan/rtl_433.git +pushd rtl_433 +echo -n '- rtl_433: ' >>"${releaseinfo}" +git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}" +rm -rf build ; mkdir build ; pushd build +cmake -DENABLE_RTLSDR=OFF -DENABLE_SOAPYSDR=ON -DENABLE_OPENSSL=OFF -DCMAKE_TOOLCHAIN_FILE="${toolchain}" -DCMAKE_INSTALL_PREFIX=/usr -DSoapySDR_DIR="${stagedir}/share/cmake/SoapySDR" .. && make VERBOSE=1 && make install +popd ; popd + +[ -d rx_tools ] || git clone https://github.com/rxseger/rx_tools.git +pushd rx_tools +echo -n '- rx_tools: ' >>"${releaseinfo}" +git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}" +rm -rf build ; mkdir build ; pushd build +cmake -DCMAKE_TOOLCHAIN_FILE="${toolchain}" -DCMAKE_INSTALL_PREFIX=/usr -DSoapySDR_DIR="${stagedir}/share/cmake/SoapySDR" .. && make VERBOSE=1 && make install +popd ; popd + +[ -d tx_tools ] || git clone https://github.com/triq-org/tx_tools.git +pushd tx_tools +echo -n '- tx_tools: ' >>"${releaseinfo}" +git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}" +rm -rf build ; mkdir build ; pushd build +cmake -DCMAKE_TOOLCHAIN_FILE="${toolchain}" -DCMAKE_INSTALL_PREFIX=/usr -DSoapySDR_DIR="${stagedir}/share/cmake/SoapySDR" .. && make VERBOSE=1 && make install +popd ; popd + +[ -d chrony ] || git clone https://git.tuxfamily.org/chrony/chrony.git +pushd chrony +echo -n '- chrony: ' >>"${releaseinfo}" +git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}" +CC="arm-linux-gnueabihf-gcc" CFLAGS="--sysroot ${sysroot}" ./configure --prefix=/usr +# sudo apt-get install -y bison +make +# make install DESTDIR=${stagedir} BINDIR=/bin SBINDIR=/bin +cp -a chronyc chronyd "${stagedir}/bin/" +popd + +[ -d gpsd ] || git clone git://git.savannah.gnu.org/gpsd.git +pushd gpsd +echo -n '- gpsd: ' >>"${releaseinfo}" +git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}" +# sudo apt-get install -y scons +DESTDIR="${stagedir}" scons libgpsmm=No ncurses=No python=No sbindir=bin prefix=/ sysroot="${sysroot}" target=arm-linux-gnueabihf build install +popd + +[ -d iperf ] || git clone https://github.com/esnet/iperf.git +pushd iperf +echo -n '- iperf: ' >>"${releaseinfo}" +git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}" +CFLAGS="--sysroot ${sysroot}" ./configure --without-openssl --prefix=/usr --host=arm-linux-gnueabihf --enable-static --disable-shared +make +make install DESTDIR=${stagedir} prefix=/ +popd + +[ -d socat ] || git clone git://repo.or.cz/socat.git +pushd socat +echo -n '- socat: ' >>"${releaseinfo}" +git describe --tags --first-parent --abbrev=7 --long --dirty --always >>"${releaseinfo}" +autoconf +CFLAGS="--sysroot ${sysroot}" ./configure --disable-openssl --prefix=/usr --host=arm-linux-gnueabihf +# this might be wrongly detected +echo '#undef HAVE_SYS_STROPTS_H' >>config.h +# sudo apt-get install -y yodl +make +make install DESTDIR=${stagedir} prefix=/ +popd + +# Dist Package + +cd "${stagedir}" +find . -ls +tar czf "${builddir}/plutosdr-apps.tar.gz" bin lib/lib* lib/SoapySDR