Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Independent build #2

Merged
merged 8 commits into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/compile-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Compile Docker Images

on: [push]

jobs:
main:
runs-on: ubuntu-20.04
permissions:
packages: write
contents: read
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: |
nebraltd/lora_gateway
ghcr.io/${{ github.repository }}
flavor: |
latest=true
tags: |
type=sha,prefix=
type=sha,format=long,prefix=
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Builds libloragw for each SPI bus and copies each to
# $OUTPUT_DIR/$SPI_BUS respectively. Also copies reset_lgw.sh
# to $OUTPUT_DIR.

FROM balenalib/raspberry-pi-debian:buster-build as lora-gateway-sx1301-builder

ENV ROOT_DIR=/opt

# Output built files to this location
ENV OUTPUT_DIR="$ROOT_DIR/output"

# Used in libloragw/Makefile value and supplied to loragw_spi.native.c
ENV SPI_SPEED=2000000

WORKDIR "$ROOT_DIR"

# Copy upstream source into expected location
COPY . "$ROOT_DIR"

# Compile libloragw
RUN . "$ROOT_DIR/compile_libloragw.sh"
35 changes: 35 additions & 0 deletions compile_libloragw.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env sh

compile_libloragw_for_spi_bus() {
spi_bus="$1"
echo "Compiling upstream libloragw for sx1301 on $spi_bus"

cd "$ROOT_DIR/libloragw" || exit
export SPI_DEV_DIR="/dev/$spi_bus"
make clean
make -j 4

cd "$ROOT_DIR"
cp -r "$ROOT_DIR/libloragw/" "$OUTPUT_DIR/$spi_bus"

echo "Finished building libloragw for sx1301 on $spi_bus in $OUTPUT_DIR"
}

compile_libloragw() {
echo "Compiling libloragw for sx1301 concentrator on all the necessary SPI buses in $OUTPUT_DIR"

# Built outputs will be copied to this directory
mkdir -p "$OUTPUT_DIR"

# In order to be more portable, intentionally not interating over an array
compile_libloragw_for_spi_bus spidev0.0
compile_libloragw_for_spi_bus spidev0.1
compile_libloragw_for_spi_bus spidev1.0
compile_libloragw_for_spi_bus spidev1.1
compile_libloragw_for_spi_bus spidev1.2
compile_libloragw_for_spi_bus spidev2.0
compile_libloragw_for_spi_bus spidev2.1
compile_libloragw_for_spi_bus spidev32766.0
}

compile_libloragw
3 changes: 2 additions & 1 deletion libloragw/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ CROSS_COMPILE ?=
CC := $(CROSS_COMPILE)gcc
AR := $(CROSS_COMPILE)ar

CFLAGS := -O2 -Wall -Wextra -std=c99 -Iinc -I.
# Modified to include SPI_DEV_PATH and SPI_SPEED macros
CFLAGS := -O2 -Wall -Wextra -std=c99 -Iinc -I. -D'SPI_DEV_PATH="${SPI_DEV_DIR}"' -D'SPI_SPEED=${SPI_SPEED}'

OBJDIR = obj
INCLUDES = $(wildcard inc/*.h)
Expand Down
5 changes: 3 additions & 2 deletions libloragw/src/loragw_spi.native.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ Maintainer: Sylvain Miermont

#define READ_ACCESS 0x00
#define WRITE_ACCESS 0x80
#define SPI_SPEED 2000000
#define SPI_DEV_PATH "/dev/spidev0.0"
// SPI_SPEED and SPI_DEV_PATH are intended to be defined as part of CFLAGS in the Makefile
// #define SPI_SPEED 8000000
// #define SPI_DEV_PATH "/dev/spidev0.0"
//#define SPI_DEV_PATH "/dev/spidev32766.0"

/* -------------------------------------------------------------------------- */
Expand Down
Loading