How to program a LoRa-E5

Seeed provides no documentation on this, and it took me a long time to figure it out.
This is what I did to program my own code into a Grove-LoRa-E5.

First, I prepared an image to program. I used the ST32CubeIDE with the STM32CubeWL Firmware Package installed. I opened the GPIO_IOToggle example and checked that it would build (its target hardware is the NUCLEO-WL55JC board
and I don’t have this, so I could not run it).

I created a new project from the existing GPIO_IOToggle.ioc configuration file. I opened the new .ioc file. In the Pinout & Configuration section, I added two pins:
PA0 as a GPIO output, labelled LED1: this the active low LED on the Grove-LoRa-E5.
PB14 as a GPIO output, labelled LED2: this is n/c on the Grove-LoRa-E5 and is an active high LED on my own PCB.

I did File > Save > Generate code, then in main.c I found MX_GPIO_Init() which contains code that initialises both pins as GPIO outputs. Comparing the new project with the GPIO_IOToggle project I see that the GPIO_IOToggle makes use of
existing BSP files, but the structure is similar. I copied across the LED toggling code from the while loop and made the necessary renames so it would build (e.g. LED1_PIN to LED1_Pin).

Second, I prepared a NUCLEO board that I already had to act as the ST Link programmer. (I had purchased a Seeed STLink V2 programmer but when I connected it to STM32CubeProgrammer I get “Error: OLD STLink firmware. Please upgrade it before trying to connect”. I have not worked out how to do this.)

I followed instructions here: UM2179 “STM32 Nucleo-144 boards” section 5.4.4 “Using ST-LINK/V2-1 to program and debug an external STM32 application.” (This video provides useful background: https://www.youtube.com/watch?v=Tt-eyglKpIs)
I wired from the NUCLEO board to the SWD pads on the bottom of the Grove-LoRa-E5 board, using the NUCLEO board as the 3.3V power source. It appears that BOOT (PB13) must be pulled low when the board is powered on or it will not be
detected by the STM32CubeProgrammer software. This step was not necessary after I programmed my own code.

Third, I downloaded and installed the STM32CubeProgrammer software. With the NUCLEO board connected to the Grove-LoRa-E and to my laptop, I selected ST-Link (top RHS) and clicked Connect. This connects to the STM23WL processor, but initially it failed reading from address 0x8000000 with “Error: data read failed”.

Clicking the Option Bytes icon and looking at the RDP value showed it was set to BB which means the flash cannot be read. I changed this from BB to AA and clicked Apply, then clicked Disconnect and (re-)Connect. This time I get “Data read successfully”. Note that changing the RDP value erases the previous AT Command software. (It would be good if Seeed could provide a file so it could be restored).

Finally, I clicked the Erasing and Programming icon and browsed to find the .elf file generated from my new project. I checked the “Verify Programming” and “Run After Programming” checkboxes, and clicked “Start Programming”.

I got success messages and the LED started blinking!

3 Likes

Hi, LoRa-E5 Module, Grove - LoRa-E5, LoRa-E5 mini, and LoRa-E5 Dev Board are programmed with the same AT Firmware and bootloader. If you find ‘C’ character comes out from serial at baud rate 115200, that means your module is running in the bootloader.
We use PB13 to control the module to stay in bootloader(for DFU) or jump to the AT application. When PB13 is HIGH, the module will jump to AT application after reset.
What is more, the Factory AT Firmware is programmed with RDP Level 1. If you want to develop your own application, please remove RDP first with STM32Cube Programmer. Note that regression RDP to level 0 will cause a flash memory mass erase. That means the Factory AT Firmware can not restore.
Thanks for your interest and support. We will provide more instructions of LoRa-E5. Thanks again!

1 Like

I also discovered a nice to do on how to program custom firmware on documentation of the LoRa-E5 wiki devkit version containing a LoRa-E5.

Would have been nice to have this link also on LoRa-E5 product.

2 Likes

Thank you for sharing~

Hi, @acutetech we have post a guide of How To Develop with STM32Cube MCU Package, please check here: https://wiki.seeedstudio.com/LoRa_E5_mini/#2-develop-with-stm32cube-mcu-package and the source code of the example is in our github: https://github.com/seeed-lora/LoRa-E5-LoRaWAN-End-Node

Thanks!