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!