Reset Pin outside of gpiochip0

Does any know if the Concentratord support pins above gpiochip0?

What I’m trying to do is run chipstack on a SeeedStudio Gateway with a custom image, as the gateway is not a opensource project I’m having to work thing out myself (support have been helpfully with some request).

I have two pin controlling the LoRa connect on this device:
Power/Enable: gpio0_22 (22)
LoRa_RST: gpio1_17 (49)

configuring up my globle.toml like:

# Concentratord configuration.

# Log level.
# Valid options are:
#   * TRACE
#   * DEBUG
#   * INFO
#   * WARN
#   * ERROR
#   * OFF

# Log to syslog.
# When set to true, log messages are being written to syslog instead of stdout.

# Statistics interval.

  # Configuration for the (ZeroMQ based) API.

  # Event PUB socket bind.

  # Command REP socket bind.

# LoRa gateway configuration.

# Antenna gain (dB).

# Public LoRaWAN network.

# Gateway vendor / model.
# This configures various vendor and model specific settings like the min / max
# frequency, TX gain table.

# Gateway vendor / model flags.

# Gateway ID.
gateway_id="<my gateway id>"

# Reset pin.
# Note: most model configurations come with a pre-defined reset_pin, in which
# case the setting below will be ignored.

I get and error when running:

thread 'main' panicked at 'setup reset pin error: Error { kind: Offset(49) }', src/libcore/
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

having a look through the concentratord source to try and work out what I should be doing I can across (and don’t know if it related or not), let mut chip = Chip::new("/dev/gpiochip0")?; in

also of note I see power_en in this same file, where do we define what pin to use for power_en?


Never programed rust before, but I gave it a hack and most likely missed a few things, but it not erroring out on offset anymore. Just need to get my SPI bus working and we will see.

This is what I came up with for

use std::sync::Mutex;
use std::thread::sleep;
use std::time::Duration;

use gpio_cdev::errors::Error;
use gpio_cdev::{Chip, LineHandle, LineRequestFlags};
use log::info;
// use modular::*;

lazy_static! {
    static ref RESET: Mutex<Option<LineHandle>> = Mutex::new(None);
    static ref POWER_EN: Mutex<Option<LineHandle>> = Mutex::new(None);

pub fn setup_pins(reset: u32, power_en: Option<u32>) -> Result<(), Error> {
    let chip_number = (reset / 32) as i16;
    // let reset_pin = (reset.to_modulo(32)) as i16;
    let reset_pin = (((reset % 32) + 32) % 32) as i16;;
    let mut chip = Chip::new(format!("/dev/gpiochip{}", chip_number))?;

    info!("Configuring reset pin, pin: {}", reset_pin);
    let line = chip.get_line(reset_pin)?;
    let mut reset = RESET.lock().unwrap();
    *reset = Some(line.request(LineRequestFlags::OUTPUT, 0, "reset")?);

    if power_en.is_some() {
        let power_en = power_en.unwrap();
        info!("Configuring power enable pin, pin: {}", power_en);
        let line = chip.get_line(power_en)?;
        let mut power_en = POWER_EN.lock().unwrap();
        *power_en = Some(line.request(LineRequestFlags::OUTPUT, 0, "power_en")?);


pub fn reset() -> Result<(), Error> {
    let reset = RESET.lock().unwrap();
    if reset.is_some() {
        let reset = reset.as_ref().unwrap();

        info!("Triggering concentrator reset");


    let power_en = POWER_EN.lock().unwrap();
    if power_en.is_some() {
        let power_en = power_en.as_ref().unwrap();

        info!("Enabling concentrator power");



If you like, maybe it makes sense to add config options for the reset pin gpio chip numbers? In that case, please create an issue in the Concentratord repo :slight_smile:

Note that the power_en is only used for the SX1302.

Add request to the repo

Thanks for having a look.

1 Like