Ic880a and SPI on balenaOS. `ERROR: [main] failed to start the concentrator`

Good day,

I am new to balenaOS. Currently I am working with LoRa gateways.
I trying to run ic880a on balenaOS. I am not able to get concentrator to work. I get ERROR: [main] failed to start the concentrator. Here is full log:

*** Beacon Packet Forwarder for Lora Gateway ***
Version: 4.0.1
*** Lora concentrator HAL library version info ***
Version: 5.0.1;
***
INFO: Little endian host
INFO: found global configuration file global_conf.json, parsing it
INFO: global_conf.json does contain a JSON object named SX1301_conf, parsing SX1301 parameters
INFO: lorawan_public 0, clksrc 1
INFO: no configuration for LBT
INFO: antenna_gain 0 dBi
INFO: Configuring TX LUT with 16 indexes
INFO: radio 0 enabled (type SX1257), center frequency 867500000, RSSI offset -165.000000, tx enabled 1, tx_notch_freq 129000
INFO: radio 1 enabled (type SX1257), center frequency 868500000, RSSI offset -165.000000, tx enabled 0, tx_notch_freq 0
INFO: Lora multi-SF channel 0>  radio 1, IF -400000 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 1>  radio 1, IF -200000 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 2>  radio 1, IF 0 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 3>  radio 0, IF -400000 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 4>  radio 0, IF -200000 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 5>  radio 0, IF 0 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 6>  radio 0, IF 200000 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora multi-SF channel 7>  radio 0, IF 400000 Hz, 125 kHz bw, SF 7 to 12
INFO: Lora std channel> radio 1, IF -200000 Hz, 250000 Hz bw, SF 7
INFO: FSK channel> radio 1, IF 300000 Hz, 125000 Hz bw, 50000 bps datarate
INFO: global_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
INFO: gateway MAC address is configured to AA555A0102030405
INFO: server hostname or IP address is configured to "localhost"
INFO: upstream port is configured to "1700"
INFO: downstream port is configured to "1700"
INFO: downstream keep-alive interval is configured to 10 seconds
INFO: statistics display interval is configured to 30 seconds
INFO: upstream PUSH_DATA time-out is configured to 100 ms
INFO: packets received with a valid CRC will be forwarded
INFO: packets received with a CRC error will NOT be forwarded
INFO: packets received with no CRC will NOT be forwarded
INFO: found local configuration file local_conf.json, parsing it
INFO: redefined parameters will overwrite global parameters
INFO: local_conf.json does not contain a JSON object named SX1301_conf
INFO: local_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
INFO: gateway MAC address is configured to AA555A0102030405
INFO: packets received with a valid CRC will be forwarded
INFO: packets received with a CRC error will NOT be forwarded
INFO: packets received with no CRC will NOT be forwarded
ERROR: [main] failed to start the concentrator

In documentation SPI says it is enabled by default if working with Node SPI. First question is: What is meaning of SPI is enabled by default and should work out of the box with the spi node module.? Does it means that SPI only works with spi node module library? Can I use SPI devices without this library?

When building same docker image on raspberry pi with default OS concentrator starts to work.
For some reason I thought that spi node module is for enabling SPI. So I made following script:

var SPI = require('spi');
var spi = new SPI.Spi('/dev/spidev0.0', {'mode': SPI.MODE['MODE_0']});
// get/set aditional options
spi.maxSpeed(8000000); // in Hz
spi.open();

And configured Dockerfile, then last Dockerfile line is:

CMD node ${SPI_CONNECTOR_DIR}/spi_connector.js && \
	./lora_pkt_fwd

My theory was wrong, after running docker image I still got ERROR: [main] failed to start the concentrator

Sorry for pure English.

Changed in Dockerfile CMD command to:

CMD ${PACKET_FORWARDER_DIR}/lora_gateway/reset_lgw.sh stop 17 && \
	${PACKET_FORWARDER_DIR}/lora_gateway/reset_lgw.sh start 17 && \
	./lora_pkt_fwd

Now it works. No need for SPI node module.

Hello iAmDomas,

Welcome to the forums!

Glad to see you managed to sort out the issue. Thank you for contributing your solution.

To answer your original question:

What is meaning of SPI is enabled by default and should work out of the box with the spi node module.?
Does it means that SPI only works with spi node module library? Can I use SPI devices without this library?

On other operating systems, SPI may not be enabled. You usually have to enable it manually. For e.g on Raspbian, you usually use raspi-config and enable SPI in Interfacing Options or edit the /boot/config.txt file. But on balenaOS for Raspberry Pi, this is already configured for you.

It is suggested here that you can use the spi node module library to interface with your device. As you have already noticed, you can use SPI devices without this library. Perhaps the wording there could have been better. I will report this to the person in charge of docs here. Thanks

Cheers,
Rahul

1 Like