Skip to content

Part 4: Software modifications

Nestor Ayuso edited this page Nov 23, 2015 · 4 revisions

The software modifications should be done before compile. But Part 3 of the tutorial uses a fork of the original lora_gateway with the necesary patches already done. You need not edit any file, but if you want to know the changed I have done, read below and feel free to watch my commits.

The first time I compiled and it didn't run I realized that USB device was not recognized because mCard uses a different FTDI USB to SPI converted than original IOT Starter kit. FT232H has a different PID (USB Product IDentification), I fixed it and also created a new rule:

loragw_spi.ftdi.c

/* parameters for a FT232H */
#define VID		0x0403
#define PID		0x6010

99-libftdi.rules

# FTDI Devices: FT2232H
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6014", MODE="0664", GROUP="plugdev"

As we are going to use FTDI SPI and not native, we must change this:

library.cfg

CFG_SPI= ftdi

Now the board is correctly detected but failed to comunicate to SX1301 because it is in a reset state. The reset pin is controlled from host through a FTDI's GPIO pin. The pin used is the same but inverted. There is a chip in mCard that maybe it is a not gate. Fortunately this can be fixed by software:

loragw_spi.ftdi.c

/* toggle pin ADBUS5 of the FT232H */
/* On the MTAC-LORA, it resets the SX1301 */
a = PinLow(mpsse, GPIOL1);
b = PinHigh(mpsse, GPIOL1);

Now SX1301 seems working but failed to read some registers. It is because SX1301 had no clock source. Both SX1257 are clocked by a shared TCXO, SX1257 has a clock output that is used to clock to SX1301. Reviewing the schematic, I see that Radio_0 (the one with TX capabilities) clock output and not Radio_1 is routed to SX1301 clock input:

global_conf.json

"clksrc": 0, /* radio_0 provides clock to concentrator */

Finally all is running !!

Note: After writing this tutorial, MultiTech released publicly the GIT repository with the same changes.