Deploying a LoRaWAN gateway running the Basics™ Station Semtech Packet Forward protocol as a balena.io application.

Hello,

I am new to balena and I’m trying to deploy a LoRaWAN gateway running the Basics™ Station Semtech Packet Forward protocol as a balena.io application.
I have followed this guide for setting up: GitHub - xoseperez/basicstation-docker: Basics™ Station Packet Forward protocol using Docker and I have SX1308 Picocell gateway connected to a cm4.

On the balena dashboard, I am getting this error:

and on the things stack, the gateway connects and disconnects almost immediately:

I have tried to troubleshoot but I haven’t been successful. Could anyone please help me?

Hello @Emily thanks for your message!

It looks like the basicstation service is in a restarting loop. Could you please confirm the hardware that you are using? Could you also please share the Device Variables that you have defined?

Maybe @xoseperez can also help here!

Thanks

Thanks @mpous for responding.

I am using SX1308P868GW picocell gateway that I am connecting to a Rpi Compute module 4.
In terms of device variables:

Hello @Emily
Can you share the full log of the service between reboots? It’s hard to see what’s wrong without more info…

Hi @xoseperez
Sure,

Here’s the log file.
pet-tracking_floral-fin-2024-05-02t14_19_45+02_00.txt (100.4 KB)

Well, the log does not provide much info…

I very much doubt the device is at /dev/ttyAMA0. How do you connect the module to the CM4? What carrier board are you using You can try set the DEVICE variable to AUTO and let the service try to find the device, it will probably be in /dev/ttyUSBx.

1 Like

Hi @xoseperez , I have connected the module to the CM4 board through a USB port.
If I set the device variable to AUTO, I get this:

Hi @Emily
Are you sure you are using the latest version of the basicstation app? Autodiscover is available since 2.8.0

I’m using release 2.7.0

And in the settings, I have:

Hi @xoseperez ,

I updated the release to 2.8.3.

These are my devices and connected via USB port:


I set the model to SX1308, Interface to USB, and Device to auto, but I am getting this error:

Please advise on the way forward.

Thanks.

Ah, probably it’s because the USB2 interface is disabled by default on the CM4. You must add dtoverlay=dwc2,dr_mode=host to the config.txt file.
See Balena CM4 IO Board image: usb support - #6 by nmx
Can also be done from the dashboard under the device configuration option.

Overwriting this or defining new configs?

1 Like

Yes @Emily

Feel free to read more here Advanced boot settings - Balena Documentation

Hi @xoseperez and @mpous ,

Thanks for the support thus far.

I have updated the above through the device configuration option:

But then we are back to the initial problem. I still have the gateway re-starting and getting the error killing process ## as shown in the log files:
pet-tracking_floral-fin-2024-05-09t16_43_24+02_00.txt (102.2 KB)

Please let me know what else to check.
Thanks.

Hi @xoseperez , @mpous,

Any advice on the above?

Hi

I’m currently trying to deploy a LoRaWAN gateway using a Raspberry Pi 4 and RAK5146L (SX1303, 433–435 MHz) concentrator. The setup is managed via Balena Cloud, and the gateway runs LoRa Basics™ Station (xoseperez/basicstation) in a Docker container.

Although the gateway appears as operational in the Balena dashboard, it appears disconnected from The Things Network (TTN)
Screenshots of the Balena dashboard and the TTN console are shown below. I need help and am quite green.

Hi!

If you’re only seeing a single service called main in your BalenaCloud dashboard, that usually means your application is running from a single-container release, not a docker-compose.yml with multiple defined services.

For LoRa Basics™ Station on a RAK5146 using Balena, you should typically see at least one service named basicstation (or whatever you named it in your Compose file).

Here are a few things you can check:

  1. Verify your project type — in BalenaCloud, your app should be of type “Multicontainer”. If it’s “Single-container,” Balena will ignore the docker-compose.yml and only run one default service (main).

  2. Push the whole folder — make sure you deploy using:

    1. balena push <appName> 
      

    from the same directory that contains your docker-compose.yml.
    (If you push from inside a subfolder, Balena only uploads one container.)

  3. Check the service name inside your docker-compose.yml. It should look like:

    services:
      basicstation:
        image: xoseperez/basicstation
        ...
    
    
  4. After redeploying, you should see basicstation as the service name in your dashboard — not main.

Once that’s fixed, we can then look at the connection logs between Basics™ Station and TTN.

If you share your docker-compose.yml, I can help you review i

this is my docker-compose.yml details:
version: ‘2.1’

services:
basicstation:
build: .
container_name: basicstation
restart: always
network_mode: host
privileged: true
devices:

  • “/dev/spidev0.1:/dev/spidev0.1” # For RAK5146
  • “/dev/gpiochip0:/dev/gpiochip0”
    environment:
    MODEL: “RAK5146”
    INTERFACE: “SPI”
    SPI_SPEED: “8000000”
    GW_RESET_PIN: 17
    GW_SPI_DEV: “/dev/spidev0.1”
    GW_EUI: “D83ADDFFFE690B42”
    TC_URI: “wss://eu1.cloud.thethings.network:8887”
    TC_KEY: “NNSXS.RUAVHKVSAFKV3QRMNFZHJJEVWBOFKCMHLUMH2DA.5CVMZOQVDGWWB7T6YB7KFTLIFAZASFBGZ6PWYM6JOTXGLVIVZIXA”
    TTS_USERNAME: “agrosense-project”
    USE_LIBGPIOD: 1
    TC_TRUST: “/app/config/cacert.pem”

but I still get these errors from the balena cloud dashboard:
basicstation 2025-10-12 19:02:41.505 [AIO:ERRO] tc trust certificates rejected by MBedTLS
basicstation 2025-10-12 19:02:41.505 [TCE:INFO] INFOS reconnect backoff 20s (retry 2)
basicstation 2025-10-12 19:03:01.505 [any:ERRO] Parsing trust certificate: X509 - The CRT/CRL/CSR format is invalid, e.g. different type expected.
The gateway still remains disconnected on the TTN console.
I aslo have a dockerfile with this details:
#Base image: the LoRa BasicStation from Xose Pérez

FROM xoseperez/basicstation:latest

#Copy your local config (cacert.pem etc.) into the container

COPY config /app/config

Hi Abdul,

I can see you’ve copied a Dockerfile in order to setup your container with a docker-compose.yml.

Have you included a .pem certs in a directory called config to so that the Docker engine can COPY correctly?

Yes,
I have my Dockerfile and docker-compose.yml files in the directory “C:\Users\abdul-aziz.n-yo\Desktop\Thesis\balena\basicstation” and the cacert.pem file in this directory “C:\Users\abdul-aziz.n-yo\Desktop\Thesis\balena\basicstation\config”.