As already mentioned in my last post LoRaWAN GPS Tracker Dragino LGT-92 and OwnTracks, the firmware of the Dragino LGT-92 GPS Tracker has to be updated using an ST-LINK/V2. The fine folks from bastelgarage.ch sent me one to give it a try. Update 2020-06-10: The product is now available in the online shop: ST-LINK V2 Debugger Programmer für STM8 STM32.
Before continuing with the steps below, I strongly suggest to carefully read the user guide section "4. Upload Firmware" in LGT-92_LoRa_GPS_Tracker_UserManual_v1.5.5.pdf (page 24 and 38) and the changelog to better understand what's going on.
These are the steps I've taken to get my LGT-92 updated to firmware version v1.6.0 under Linux (the user manual only helps with Windows):
openocd: Arch users can install it using
pacman -S openocd, Ubuntu users with
apt install openocd, macOS users with
brew install openocd.
- Download the firmware file from dragino.com (choose the matching LoRaWAN frequency)
- Connect the LGT-92 to the ST-LINK/V2 and to your computer (see below how to exactly do that)
- Press the Reset button on the LGT-92 and run the following command (replace "
EU868.hex" with the firmware file you've downloaded):
openocd -f /usr/share/openocd/scripts/interface/stlink-v2.cfg -c "transport select hla_swd" -f /usr/share/openocd/scripts/target/stm32l0.cfg -c init -c 'program EU868.hex verify reset exit'
Note 1: I had to try that a few times as I wasn't sure when to exactly release the reset button and run the command
Note 2: macOS users will find the script files of openocd under
- Check that the output shows:
** Verified OK ** ** Resetting Target **. The output on my try showed some other errors, but in the end the firmware upgrade worked
To verify that the firmware is really upgraded, connect to the LGT-92 via serial console (see below) and send the command
AT+VER. The manual also suggests running
AT+FDR to reset to factory defaults (reboot after that!). See DRAGINO_LGT92_AT_Commands_v1.5.3.pdf for a description of all the AT commands.
Please note that the firmware behavior and also the LoRaWAN payload changed significantly between version 1.4 and version 1.6 (see user manual and changelog for details). This also means that the payload decoder on The Things Network needs to be updated (source) and I had to adapt my Python script which sends the received data to OwnTracks (via MQTT) and to InfluxDB.
My hope is that with the newer firmware version the location reporting will be much more accurate. Let's see if this turns out to be true.
Connecting LGT-92 to ST-LINK/V2
This is how I connected the LGT-92 to the ST-LINK/V2:
LGT-92 black -> ST-LINK/V2 STM32 Pin 20 (GND)
LGT-92 white -> ST-LINK/V2 STM32 Pin 7 (TMS_SWDIO)
LGT-92 green -> ST-LINK/V2 STM32 Pin 9 (TCK_SWCLK)
LGT-92 red -> ST-LINK/V2 STM32 Pin 19 (VDD)
I'm not 100% sure if this is the correct cabling - but in the end it worked. Update 2021-04-02: The cabling has been corrected, thanks Marcel Stör for the hint.
The user manual of the ST-LINK/V2 is available here: dm00026748-st-link-v2-in-circuit-debugger-programmer-for-stm8-and-stm32-stmicroelectronics.pdf, containing the full description of the pinout.
Connecting LGT-92 to UART
For having a serial console, an FTDI connector like the Mini USB UART FTDI Programm is needed.
I own an UartSBee V4, the connection looks like this:
LGT-92 black -> UartSBee GND
LGT-92 green -> UartSBee RX
LGT-92 white -> UartSBee TX
Now a connection via f.e. with
screen /dev/ttyUSB0 9600 can be used to see the console output or to issue
Example of a booting LGT-92:
References which helped me