How to program a LoRa-E5

I have determined experimentally that the second of the two defines is correct. Otherwise the uplink RSSI is very poor. I have filed a bug report here: https://github.com/seeed-lora/LoRa-E5-LoRaWAN-End-Node/issues/3

As I have noted before, it would be much better if Seeed would trust its users and publish circuit diagrams, which would allow such confusion to be cleared up quickly.

Im also struggling with this one. Ive managed to program the LoRa-E5 mini dev board using an ST-Link via SWD and have loaded on the given Seeed modified example code: LoRaWAN_End_Node. This firmware works and is able to send uplinks no problem. This was thanks to @acutetech whose post was my savior.

However, Im now not able to get the STM32CUBEProgrammer to connect to the device. I see:

Error: Problem occured while trying to connect

I suspect that without the Seeed provided bootloader Im now not able to get it into DFU mode.

From what Ive read it seems that the Lora E5 module doesnt have a pinout for the STM32s BOOT0 so Im wondering how I might get it into system boot mode?

Does this mean I might have bricked this poor little dev board?

Any insight would be much appreciated

Solved it after some trial and error.

Turns out the third party ST Link V2 I have, has to be unplugged and replugged into the USB which presumably puts it into the correct mode. Then, holding down the RST button on the Lora E5 Mini dev board, clicking Connect on the STM32CUBEProgrammer software and releasing the RST button, allows the board to be detected and programmed every time.

This is on a macbook pro running Big Sur (11.2.3) using a Yootech USB-C to USB adaptor. The Lora E5 Mini is also connected via USB with an Arduino Serial Monitor open to view its output. The dev board is wired up according these instructions: https://wiki.seeedstudio.com/LoRa_E5_mini/#2-develop-with-stm32cube-mcu-package

Now to actually write some code for it!

Hi @cmydlarz
Which third party ST Link V2 you are using?
Can you suggest any which is compatible with LoRa-E5?

I use this one: Aideepen ST-Link V2 Programming… https://www.amazon.com/dp/B01J7N3RE6?ref=ppx_pop_mob_ap_share

Which as mentioned is a bit finicky but can program the Lora E5 mini dev board. I’ve not tried any other programmers so my experience is limited.

I am having issue in getting the ST-Link/V2 programmer to connect to the LoRa-E5-Mini. I am using Windows PC, STM32 Cube Programmer and IDE.

I am using ST-Link/V2 to program LoRa-E5 mini. I connected the ST-Link/V2 programmer as follows, using the 20 pin connector of the programmer, pin 9 (SDIO) to LoRa-E5 SDIO, Pin 7 (SWCLK) to LoRa-E5 SWCLK. Pin 6 (GND) to LoRA-E5 GND. I am using the USB port connected to my Windows PC to power the LoRA-E5 mini module.

It would be great if there were a concise step by step to make this work.
From what I see in the posts, I should do the following:

  1. Before applying power to Lora-E5 module, Connect PB13 to GND
  2. Connect STLink/V2 to PC USB port
  3. Start STCubeProgrammer
  4. Connect Lor-E5-Mini to PC USB port (For power)
  5. Press and hold the LoRa-E5-Mini RESET Button.
  6. Click ‘Connect’ on STCube Programmer
  7. Release LoRA-E5-Min Reset button.

I tried the above repetitively and virtually all combinations, and yet cannot get connection - log below. Clearly I am doing something wrong, and is likely obvious. Help please. A nice step by step guide would be great, thank you!

09:24:22 : ST-LINK SN : 37FF6F064243393027222057
09:24:22 : ST-LINK FW : V2J37S7
09:24:22 : Board : –
09:24:22 : Voltage : 1.56V
09:24:23 : Error: ST-LINK error (DEV_TARGET_CMD_ERR)
09:24:28 : ST-LINK SN : 37FF6F064243393027222057
09:24:28 : ST-LINK FW : V2J37S7
09:24:28 : Board : –
09:24:28 : Voltage : 0.53V
09:24:28 : Error: No STM32 target found!
09:24:33 : ST-LINK SN : 37FF6F064243393027222057
09:24:33 : ST-LINK FW : V2J37S7
09:24:33 : Board : –
09:24:33 : Voltage : 1.56V
09:24:35 : Error: ST-LINK error (DEV_TARGET_CMD_ERR)

I should also add the the AT application is still working fine, so the hardware appears to be good.

Problem solved:

  • Connect ST-Link/V2 programmer as follows:
    • CN3 Pin 1 to Lora-E5 3V3
    • CN3 Pin 7 to Lora-E5 SWDIO
    • CN3 Pin 9 to Lora-E5 SWCLK
    • CN3 Pin 19 to Lora-E5 SCK
    • CN3 Pin 8 to Lra-E5 GND
  • Connect ST-Link/V2 programmer to USB port
  • Connect Lora-E5 to USB port
  • Press and hold the RST button on the Lora-E5 module
  • Click on the ‘Connect’ button on the ST-Cube Programmer
  • Release the RST button on the Lora-E5 module. ST-Cube Program should now indicate ‘connected’.
  • In St-Cube Programmer, select the ‘OB’ menu.
  • Change Read Out Protection from BB to AA and apply it.
1 Like

I hope this video’s to connect and program wl55jc, B-L072z and L476RG STM32 boards can be helpful:


Good luck.

@acutetech You are a life save :slight_smile:

Hi all, I was able to remove RDP with STM32Cube Programmer using a ST-Link and create my own custom project. I no longer have the ST-Link so I tried to remove RDP of another LoraE5-mini board using UART via the USB-C port. I was not able to establish a connection, I get the error:

22:08:33 : Serial Port cu.usbserial-141430 is successfully opened.
22:08:33 : Port configuration: parity = none, baudrate = 115200, data-bit = 8, stop-bit = 1.0, flow-control = off
22:08:34 : Timeout error occured while waiting for acknowledgement.
22:08:34 : Error: Activating device: KO. Please, verify the boot mode configuration and check the serial port configuration. Reset your device then try again…

Does anyone know if it is possible to remove RDP and program the LoraE5-mini board using UART (without a ST-Link)? Thank you.

I stumbled across this exact process as well. However, my process is a little different in that I use the CLI on macos (located at /Applications/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/Contents/MacOs/bin/STM32_Programmer_CLI This is very reliable to erase the memory and let it connect to the IDE.

However, I haven’t been able to get it to work in the debugger. I suspect that something in the programming messes up the SWD interface. I can work with my Nucleo board with no issues.

Has anyone figured out the debugger on the E5 modules?

Thanks!

I am stuck! nothing works! I cannot connect my lora e5 dev board to the programmer!! tried everything!

Thanks for the solution. There is a lot of doubt about how to connect. I’m working with LoRa E5 Dev and it works too

Thanks acutetech, your post helped me to clear the factory firmware.

Because I was unsure of how to hook things up to do this I’ll detail what I did to use a Nucleo board to connect to the LoRa-E5 dev kit.

I removed the two jumpers on the Nucleo stlink programmer so that it was acting as a programmer for an external device, not the attached Nucleo board. Those are the jumpers near the crystal with ST-LINK written on one side and NUCLEO on the other.

The blue 5 pin header is the programming header on the LoRa-E5 dev kit.

Here are the links I made:

ST-LINK CN4                     E5 dev kit

2                                         3                    swd clk
3                                         5                    gnd
4                                         2                    swd io

Both the Nucleo/ST-LINK and the E5 dev kit have their USB cables in, and the stm programmer is connected using the ST-LINK option.

As acutech says, reading the E5 dev kit MCU will fail until the read-out-protection option byte is set to AA and that value is applied. This clears the factory firmware and all FFs are read.

Programming works fine, and SB12 - the reset line from the ST-LINK to the Nucleo - did not need to be opened, so there were no modifications to the ST-LINK part of the Nucleo except to open the two jumpers.

Preparation

  1. Connect LoRa-E5 mini to PC via a Type-C cable.
  2. Open a serial tool(eg. Arduino Serial Monitor), select the right COM port, set the baud rate to 9600, and select Both NL & CR.
  3. Try to send “AT” and you will see the response.

Regards,
Willjoe

I have been working towards a custom application on the Lora-E5 Dev Board which, if successful, I will turn into a product using the SEEED Lora module or some other STM Lora Module. Although I can understand locking down the application and the chip from a regulatory standpoint it is nto very useful for developers such as myself who do not want to use the module as a modem but instead want to run our application directly on the processor and in my case really don’t want to attach to a LoraWan and all that comes along with that. It has taken a few days but I am now able to build applications using the STM drivers as generated by CubeMX and compile in Eclipse an program and debug using OpenOCD. Aside from the normal setup and configuration issues one encounters with Eclipse the big hurdles were with OpenOCD and the module itself. There is a new cfg file for OpenOCD that supports the STM32WLx series but that only works with OpenOCD 0.11.4. I was using Linux 16.04 and that had to be upgraded to Linux 20.04 to work with OpenOCD 0.11. Once all that was complete and using CubeProg to erase the chip (using a ST-Link provided by a old Nucleo board) then I could load the code and fire up the debugger. Unfortunately the device would jump to the System boot loader and not to my program, I suspect this has something to do with how the BOOT0 pin is handled inside the module. To fix this I went back to CubeProg and set the BOOT_LOCK option which forces execution to start in User Flash and now things seem to be working just fine, program executes and I can set break points and debug. Now the fun begins…
Hope this helps other who are trying to develop their own applications.

1 Like

Do you know if the SWO pin from the STM32WL is exposed? So far, I’ve only been able to program the module using the directions on the wiki using SWDIO and SWCLK. For printf debugging, I’ve had to just use the UART to USB bridge. That said, I would like to be able to use the serial wire viewer instead if possible. Without the schematic for the module internals, I’ve been left to guess. Thanks!

SWO is on PB3 of the chip and this pin is available on the Lora-E5 module. I tried to get it working as a console output. I don’t recall how successful I was, but I don’t use it, which probably means it was not useful, in my case. I find I made notes on this, whcih I copy below. Note that I have not reviewed these note for accuracy etc - use at your own risk.

Console output using SWO pin

Start by looking at Console_Output.txt to see how APP_LOG and printf() work.
Redirecting printf() to the SWO pin sees possible and is documented in several places such as:

1 AN4989 Application note STM32 microcontroller debug toolbox section 7.3

2 Succinct summary: printf() using ST-Link debug interface (SWD, ITM View) - embedded communication

3 This video : https://www.youtube.com/watch?v=Efgp34LbkLU

4 This video - shows _write() code at 4: https://www.youtube.com/watch?v=JqrUAzjJ0tw
It starts with showing connecting a wire but does not explain why. The next link does.
(It connects target nRST to a St-Link v2)

5 SWD part 3 – SWO and nRST – Kudelski Security Research

6 Erich Styger Tutorial: Using Single Wire Output SWO
Tutorial: Using Single Wire Output SWO with ARM Cortex-M and Eclipse | MCU on Eclipse
Also: SWO | MCU on Eclipse

7 Using Printf Debugging, LIVE expressions and SWV Trace in CubeIDE || STM32 || ITM || SWV
https://www.youtube.com/watch?v=sPzQ5CniWtw

These examples extend the printf() direction documented in Console_Output.txt by changing the _write()
call to make calls to ITM_SendChar(); or as the ST App note AN4989 says:

int __io_putchar(int ch) {
ITM_SendChar(ch);
return(ch);
}

Thanks for the notes @acutetech. Went through them and everything makes sense. The only problem I am having is changing the IOC to enable SWO on PB3. SeeedStudio repo’s config file is incomplete and throws a series of errors when trying to regenerate the code with the added debug pin. I know you mentioned you don’t remember implementing this, but have you run into problems modifying the IOC while trying to use the STM32WL in the module (e.g. enabling additional GPIOs etc.)? Presumably this is why you don’t use it? I’m thinking I’ll probably just use one of the UARTs for console output if I can’t get this working in the next day or so.