Initial commit
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
source "$BR2_EXTERNAL_ATOY_PATH/package/lora-gateway/Config.in"
|
||||
source "$BR2_EXTERNAL_ATOY_PATH/package/packet-forwarder/Config.in"
|
||||
@@ -0,0 +1,17 @@
|
||||
# a|toy Buildroot 2 external tree
|
||||
|
||||
## TheThingsNetwork gateway
|
||||
|
||||
This projet create an image for a raspberrypi board running the TTN packet forwarder. You need a SX1301 extension board.
|
||||
|
||||
* Clone buildroot2
|
||||
* Clone this repository
|
||||
|
||||
Then, generate the sdcard image :
|
||||
|
||||
```bash
|
||||
cd /into/buildroot2
|
||||
make BR2_EXTERNAL=/this/repository ttngw_defconfig && make
|
||||
```
|
||||
|
||||
You'll find the generated image into output/images/sdcard.img. Just "dd" it on your sdcard (or use etcher on OSX).
|
||||
@@ -0,0 +1,33 @@
|
||||
image boot.vfat {
|
||||
vfat {
|
||||
files = {
|
||||
"bcm2710-rpi-3-b.dtb",
|
||||
"bcm2710-rpi-3-b-plus.dtb",
|
||||
"bcm2710-rpi-cm3.dtb",
|
||||
"rpi-firmware/bootcode.bin",
|
||||
"rpi-firmware/cmdline.txt",
|
||||
"rpi-firmware/config.txt",
|
||||
"rpi-firmware/fixup.dat",
|
||||
"rpi-firmware/start.elf",
|
||||
"rpi-firmware/overlays",
|
||||
"zImage"
|
||||
}
|
||||
}
|
||||
size = 32M
|
||||
}
|
||||
|
||||
image sdcard.img {
|
||||
hdimage {
|
||||
}
|
||||
|
||||
partition boot {
|
||||
partition-type = 0xC
|
||||
bootable = "true"
|
||||
image = "boot.vfat"
|
||||
}
|
||||
|
||||
partition rootfs {
|
||||
partition-type = 0x83
|
||||
image = "rootfs.ext4"
|
||||
}
|
||||
}
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -u
|
||||
set -e
|
||||
|
||||
# Mount first partition to access config files
|
||||
if [ -e ${TARGET_DIR}/etc/fstab ]; then
|
||||
if ! grep -qE '^\/dev\/mmcblk0p1' "${TARGET_DIR}/etc/fstab"; then
|
||||
cat << __EOF__ >> "${TARGET_DIR}/etc/fstab"
|
||||
/dev/mmcblk0p1 /mnt vfat defaults,ro 0 0
|
||||
__EOF__
|
||||
fi
|
||||
fi
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Enable SPI
|
||||
if ! grep -qE '^dtparam=spi=on' "${BINARIES_DIR}/rpi-firmware/config.txt"; then
|
||||
cat << __EOF__ >> "${BINARIES_DIR}/rpi-firmware/config.txt"
|
||||
|
||||
# enable SPI
|
||||
dtparam=spi=on
|
||||
__EOF__
|
||||
fi
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Load SPI modules
|
||||
#
|
||||
|
||||
start() {
|
||||
printf "Load SPI kernel modules: "
|
||||
|
||||
modprobe spi-bcm2835
|
||||
modprobe spidev
|
||||
}
|
||||
stop() {
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart|reload)
|
||||
restart
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
@@ -0,0 +1,42 @@
|
||||
BR2_arm=y
|
||||
BR2_cortex_a53=y
|
||||
BR2_ARM_FPU_NEON_VFPV4=y
|
||||
|
||||
BR2_TOOLCHAIN_BUILDROOT_CXX=y
|
||||
|
||||
BR2_SYSTEM_DHCP="eth0"
|
||||
|
||||
# Linux headers same as kernel, a 4.14 series
|
||||
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_14=y
|
||||
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,c117a8bccf37bfba323065b566cf999ed4629a4a)/linux-c117a8bccf37bfba323065b566cf999ed4629a4a.tar.gz"
|
||||
BR2_LINUX_KERNEL_DEFCONFIG="bcm2709"
|
||||
|
||||
# Build the DTB from the kernel sources
|
||||
BR2_LINUX_KERNEL_DTS_SUPPORT=y
|
||||
BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2710-rpi-3-b bcm2710-rpi-3-b-plus bcm2710-rpi-cm3"
|
||||
|
||||
BR2_PACKAGE_RPI_FIRMWARE=y
|
||||
|
||||
# Required tools to create the SD image
|
||||
BR2_PACKAGE_HOST_DOSFSTOOLS=y
|
||||
BR2_PACKAGE_HOST_GENIMAGE=y
|
||||
BR2_PACKAGE_HOST_MTOOLS=y
|
||||
|
||||
# Filesystem / image
|
||||
BR2_TARGET_ROOTFS_EXT2=y
|
||||
BR2_TARGET_ROOTFS_EXT2_4=y
|
||||
BR2_TARGET_ROOTFS_EXT2_SIZE="128M"
|
||||
# BR2_TARGET_ROOTFS_TAR is not set
|
||||
BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi3/post-build.sh $(BR2_EXTERNAL_BAR_42_PATH)/board/ttngw/post-build.sh"
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_BAR_42_PATH)/board/ttngw/post-image.sh board/raspberrypi3/post-image.sh"
|
||||
BR2_ROOTFS_POST_SCRIPT_ARGS="--add-pi3-miniuart-bt-overlay"
|
||||
|
||||
# TTNGW specific options and packages
|
||||
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_BAR_42_PATH)/board/ttngw/rootfs-overlay"
|
||||
BR2_TARGET_GENERIC_ROOT_PASSWD="azerty"
|
||||
BR2_PACKAGE_DROPBEAR=y
|
||||
BR2_PACKAGE_DROPBEAR_DISABLE_REVERSEDNS=y
|
||||
BR2_PACKAGE_PACKET_FORWARDER=y
|
||||
@@ -0,0 +1,2 @@
|
||||
name: ATOY
|
||||
desc: Custom projects using BR2
|
||||
@@ -0,0 +1 @@
|
||||
include $(sort $(wildcard $(BR2_EXTERNAL_ATOY_PATH)/package/*/*.mk))
|
||||
@@ -0,0 +1,4 @@
|
||||
config BR2_PACKAGE_LORA_GATEWAY
|
||||
bool "lora-gateway"
|
||||
help
|
||||
This is the lora gateway package from The Things Network
|
||||
@@ -0,0 +1,25 @@
|
||||
LORA_GATEWAY_VERSION = legacy
|
||||
LORA_GATEWAY_SITE = https://github.com/TheThingsNetwork/lora_gateway.git
|
||||
LORA_GATEWAY_INSTALL_STAGING = YES
|
||||
LORA_GATEWAY_SITE_METHOD = git
|
||||
|
||||
define LORA_GATEWAY_CONFIGURE_CMDS
|
||||
sed -i -e 's/PLATFORM= kerlink/PLATFORM= imst_rpi/g' $(@D)/libloragw/library.cfg
|
||||
endef
|
||||
|
||||
define LORA_GATEWAY_BUILD_CMDS
|
||||
CROSS_COMPILE=arm-buildroot-linux-uclibcgnueabihf- LD=$(TARGET_LD) $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) all
|
||||
endef
|
||||
|
||||
define LORA_GATEWAY_INSTALL_STAGING_CMDS
|
||||
$(INSTALL) -d -m 0755 $(STAGING_DIR)/opt/ttn/libloragw
|
||||
$(INSTALL) -D -m 0755 $(@D)/libloragw/library.cfg $(STAGING_DIR)/opt/ttn/libloragw/library.cfg
|
||||
$(INSTALL) -D -m 0755 $(@D)/libloragw/libloragw.a $(STAGING_DIR)/opt/ttn/libloragw/libloragw.a
|
||||
$(INSTALL) -d -m 0755 $(STAGING_DIR)/opt/ttn/libloragw/inc
|
||||
$(INSTALL) -D -m 0755 $(@D)/libloragw/inc/*.h $(STAGING_DIR)/opt/ttn/libloragw/inc/
|
||||
endef
|
||||
|
||||
define LORA_GATEWAY_INSTALL_TARGET_CMDS
|
||||
endef
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -0,0 +1,5 @@
|
||||
config BR2_PACKAGE_PACKET_FORWARDER
|
||||
bool "packet-forwarder"
|
||||
select BR2_PACKAGE_LORA_GATEWAY
|
||||
help
|
||||
This is the lora packet forwarder package from The Things Network
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Starts Lora packet forwarder
|
||||
#
|
||||
|
||||
# Allow a few customizations from a config file
|
||||
test -r /etc/default/packet-forwarder && . /etc/default/packet-forwarder
|
||||
|
||||
reset_sx1301() {
|
||||
echo "$SX1301_RESET_BCM_PIN" > /sys/class/gpio/export
|
||||
echo "out" > /sys/class/gpio/gpio$SX1301_RESET_BCM_PIN/direction
|
||||
echo "0" > /sys/class/gpio/gpio$SX1301_RESET_BCM_PIN/value
|
||||
sleep 0.1
|
||||
echo "1" > /sys/class/gpio/gpio$SX1301_RESET_BCM_PIN/value
|
||||
sleep 0.1
|
||||
echo "0" > /sys/class/gpio/gpio$SX1301_RESET_BCM_PIN/value
|
||||
sleep 0.1
|
||||
echo "$SX1301_RESET_BCM_PIN" > /sys/class/gpio/unexport
|
||||
}
|
||||
|
||||
start() {
|
||||
printf "Starting LoRa packet forwarder: "
|
||||
umask 077
|
||||
|
||||
reset_sx1301
|
||||
|
||||
cd /etc/ttn
|
||||
start-stop-daemon -S -b -q -p /var/run/packet-forwarder.pid \
|
||||
--exec /usr/bin/poly_pkt_fwd -- $PACKETFORWARDER_ARGS
|
||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
||||
}
|
||||
stop() {
|
||||
printf "Stopping LoRa packet forwarder: "
|
||||
start-stop-daemon -K -q -p /var/run/packet-forwarder.pid
|
||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
||||
}
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart|reload)
|
||||
restart
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
@@ -0,0 +1,2 @@
|
||||
# GPIO connected to SW1301 reset pin
|
||||
SX1301_RESET_BCM_PIN=17
|
||||
@@ -0,0 +1,24 @@
|
||||
PACKET_FORWARDER_VERSION = legacy
|
||||
PACKET_FORWARDER_SITE = https://github.com/TheThingsNetwork/packet_forwarder.git
|
||||
PACKET_FORWARDER_SITE_METHOD = git
|
||||
PACKET_FORWARDER_DEPENDENCIES = lora-gateway
|
||||
|
||||
define PACKET_FORWARDER_CONFIGURE_CMDS
|
||||
endef
|
||||
|
||||
define PACKET_FORWARDER_BUILD_CMDS
|
||||
LGW_PATH=$(STAGING_DIR)/opt/ttn/libloragw CROSS_COMPILE=$(TARGET_CROSS) LD=$(TARGET_LD) $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) all
|
||||
endef
|
||||
|
||||
define PACKET_FORWARDER_INSTALL_TARGET_CMDS
|
||||
$(INSTALL) -D -m 0755 $(@D)/poly_pkt_fwd/poly_pkt_fwd $(TARGET_DIR)/usr/bin/poly_pkt_fwd
|
||||
$(INSTALL) -D -m 0644 $(@D)/poly_pkt_fwd/global_conf.json $(TARGET_DIR)/etc/ttn/global_conf.json
|
||||
$(INSTALL) -D -m 0644 package/thethingsnetwork/packet-forwarder/packet-forwarder $(TARGET_DIR)/etc/default/packet-forwarder
|
||||
endef
|
||||
|
||||
define PACKET_FORWARDER_INSTALL_INIT_SYSV
|
||||
$(INSTALL) -D -m 755 package/thethingsnetwork/packet-forwarder/S52packetforwarder \
|
||||
$(TARGET_DIR)/etc/init.d/S52packetforwarder
|
||||
endef
|
||||
|
||||
$(eval $(generic-package))
|
||||
Reference in New Issue
Block a user