From b51357979df08e43dcaf56ac11da6ba2aa1c7e95 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 20 Feb 2018 22:16:30 +0100 Subject: [PATCH 1/3] Add script to build for the Lorank8 This is just a copy of the build-pi.sh script, with some minimal changes: - Remove the WiringPi compilation - Do not install the python-rpi.gpio package - Set PLATFORM to "lorank" --- mp_pkt_fwd/build-lorank.sh | 90 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100755 mp_pkt_fwd/build-lorank.sh diff --git a/mp_pkt_fwd/build-lorank.sh b/mp_pkt_fwd/build-lorank.sh new file mode 100755 index 0000000..a53a06d --- /dev/null +++ b/mp_pkt_fwd/build-lorank.sh @@ -0,0 +1,90 @@ +#! /bin/bash +# +# Build script for the Lorank8 (Beagleboard + IC880A) based on rpi build script +# + +INSTALL_DIR="/opt/ttn-gateway" + +mkdir -p $INSTALL_DIR/dev +cd $INSTALL_DIR/dev + +# alwas get the latest +rm -rf lora_gateway +git clone https://github.com/kersing/lora_gateway.git || { echo 'Cloning lora_gateway failed.' ; exit 1; } + +if [ ! -d paho.mqtt.embedded-c ]; then + git clone https://github.com/kersing/paho.mqtt.embedded-c.git || { echo 'Cloning paho mqtt failed.' ; exit 1; } +else + cd paho.mqtt.embedded-c + git reset --hard + git pull + cd .. +fi + +if [ ! -d ttn-gateway-connector ]; then + git clone https://github.com/kersing/ttn-gateway-connector.git || { echo 'Cloning gateway connector failed.' ; exit 1; } +else + cd ttn-gateway-connector + git reset --hard + git pull + cd .. +fi + +if [ ! -d protobuf-c ]; then + git clone https://github.com/kersing/protobuf-c.git || { echo 'Cloning protobuf-c failed.' ; exit 1; } +else + cd protobuf-c + git reset --hard + git pull + cd .. +fi + +# make sure we get the latest +rm -rf packet_forwarder +git clone https://github.com/kersing/packet_forwarder.git || { echo 'Cloning packet forwarder failed.' ; exit 1; } + +if [ ! -d protobuf ]; then + git clone https://github.com/google/protobuf.git || { echo 'Cloning protobuf failed.' ; exit 1; } +else + cd protobuf + git reset --hard + git pull + cd .. +fi + +apt-get update +apt-get -y install protobuf-compiler libprotobuf-dev libprotoc-dev automake libtool autoconf python-dev + +cd $INSTALL_DIR/dev/lora_gateway/libloragw +sed -i -e 's/PLATFORM= .*$/PLATFORM= lorank/g' library.cfg +sed -i -e 's/CFG_SPI= .*$/CFG_SPI= native/g' library.cfg +#sed -i -e 's/DEBUG_GPS= .*$/DEBUG_GPS= 1/g' library.cfg +make + +cd $INSTALL_DIR/dev/protobuf-c +./autogen.sh +./configure +make protobuf-c/libprotobuf-c.la +mkdir bin +./libtool install /usr/bin/install -c protobuf-c/libprotobuf-c.la `pwd`/bin +rm -f `pwd`/bin/*so* + +cd $INSTALL_DIR/dev/paho.mqtt.embedded-c/ +make +make install + +cd $INSTALL_DIR/dev/ttn-gateway-connector +cp config.mk.in config.mk +make +cp bin/libttn-gateway-connector.so /usr/lib/ + +cd $INSTALL_DIR/dev/packet_forwarder/mp_pkt_fwd/ +make + +# Copy things needed at runtime to where they'll be expected +cp $INSTALL_DIR/dev/packet_forwarder/mp_pkt_fwd/mp_pkt_fwd $INSTALL_DIR/mp_pkt_fwd + +echo "Build & Installation Of Binaries Completed." +echo "Do not forget to get master configuration from" +echo "https://github.com/TheThingsNetwork/gateway-conf" +echo "and to create a local configuration as well" From 4ec514e62ec6e3d157102b86234fc9425e23d61b Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 28 Feb 2018 18:22:51 +0100 Subject: [PATCH 2/3] Install ttn library to /usr/local/lib /usr/lib is normally reserved for system libraries installed to the package manager. The paho.mqtt.embedded-c was already installed into /usr/local, now all libraries are. --- mp_pkt_fwd/build-lorank.sh | 2 +- mp_pkt_fwd/build-pi.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mp_pkt_fwd/build-lorank.sh b/mp_pkt_fwd/build-lorank.sh index a53a06d..c25ddeb 100755 --- a/mp_pkt_fwd/build-lorank.sh +++ b/mp_pkt_fwd/build-lorank.sh @@ -76,7 +76,7 @@ make install cd $INSTALL_DIR/dev/ttn-gateway-connector cp config.mk.in config.mk make -cp bin/libttn-gateway-connector.so /usr/lib/ +cp bin/libttn-gateway-connector.so /usr/local/lib/ cd $INSTALL_DIR/dev/packet_forwarder/mp_pkt_fwd/ make diff --git a/mp_pkt_fwd/build-pi.sh b/mp_pkt_fwd/build-pi.sh index fc9a27b..de2044b 100755 --- a/mp_pkt_fwd/build-pi.sh +++ b/mp_pkt_fwd/build-pi.sh @@ -87,7 +87,7 @@ make install cd $INSTALL_DIR/dev/ttn-gateway-connector cp config.mk.in config.mk make -cp bin/libttn-gateway-connector.so /usr/lib/ +cp bin/libttn-gateway-connector.so /usr/local/lib/ cd $INSTALL_DIR/dev/packet_forwarder/mp_pkt_fwd/ make From 2e89111d9277fe395b5adf9a4dc3e4a04770630f Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Mon, 5 Mar 2018 18:18:35 +0100 Subject: [PATCH 3/3] Allow overwriting a running binary on build This passes --remove-destination to the copy of `mp_pkt_fwd` in the rpi and lorank build scripts, to remove and recreate the file instead of writing to the existing file. This prevents the "Text file busy" error that would otherwise occur when the forwarder is running. --- mp_pkt_fwd/build-lorank.sh | 3 ++- mp_pkt_fwd/build-pi.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mp_pkt_fwd/build-lorank.sh b/mp_pkt_fwd/build-lorank.sh index c25ddeb..3c648a4 100755 --- a/mp_pkt_fwd/build-lorank.sh +++ b/mp_pkt_fwd/build-lorank.sh @@ -82,7 +82,8 @@ cd $INSTALL_DIR/dev/packet_forwarder/mp_pkt_fwd/ make # Copy things needed at runtime to where they'll be expected -cp $INSTALL_DIR/dev/packet_forwarder/mp_pkt_fwd/mp_pkt_fwd $INSTALL_DIR/mp_pkt_fwd +# Pass --remove-destination to allow overwriting a running binary +cp --remove-destination $INSTALL_DIR/dev/packet_forwarder/mp_pkt_fwd/mp_pkt_fwd $INSTALL_DIR/mp_pkt_fwd echo "Build & Installation Of Binaries Completed." echo "Do not forget to get master configuration from" diff --git a/mp_pkt_fwd/build-pi.sh b/mp_pkt_fwd/build-pi.sh index de2044b..b6e70af 100755 --- a/mp_pkt_fwd/build-pi.sh +++ b/mp_pkt_fwd/build-pi.sh @@ -93,7 +93,8 @@ cd $INSTALL_DIR/dev/packet_forwarder/mp_pkt_fwd/ make # Copy things needed at runtime to where they'll be expected -cp $INSTALL_DIR/dev/packet_forwarder/mp_pkt_fwd/mp_pkt_fwd $INSTALL_DIR/mp_pkt_fwd +# Pass --remove-destination to allow overwriting a running binary +cp --remove-destination $INSTALL_DIR/dev/packet_forwarder/mp_pkt_fwd/mp_pkt_fwd $INSTALL_DIR/mp_pkt_fwd echo "Build & Installation Of Binaries Completed." echo "Do not forget to get master configuration from"