STM32 programming - Nucleo (STM32L073) versus own PCB (STM32L082)

Hi,

I am familiar with the nucleo and have been programming it thru the on-board ST-LINKV2.
Now I created my own PCB with and STM32L082KZ MCU.

For the programming the SWDIO, SWCLK, NRST, VCC and GND are connected to the outside world (same design as Nucleo). However the programming (flashing) is different when using platformIO.

  1. Nucleo we flash “just” by uploading it (STML073RZ).
  2. Own PCB - we need to press NRST, start uploading process and release the NRST button.

For obvious reasons we would like to have similar flash process as the Nucleo has.
However I am not sure what the reason is why we have to press the NRST before being able to upload.

Does anybody has experience with this? And more important → do you have a solution :slight_smile:

Thanks,

It’s a bit difficult to tell from your information what you’re really doing:

  • What debug probe do you connect?
  • What debug_protocol do you specify in platformio.ini?
  • What does the schematic of your PCB look like?
  • What have you connected to BOOT0?

If the experience from a STM32F0xx applies to the STM32L0xx, there isn’t much needed:

  • connect BOOT0 to GND
  • connect an ST-Link v2 to GND, SWDCLK, SWDIO and VCC (no NRST)
  • upload the code with the default debug_protocol (= stlink)

Sounds more like openocd is instructed to use the wrong reset_config method for resetting the chip. Full platformio.ini?

@maxgerhardt: Now that you mention it: I did create an OpenOCD config file with:

reset_config none separate

@JeroenIoT: Can you show the error message you get when you don’t press NRST?

In case I do not press NRST we get the following (so without your suggestion - just as I use platformio now):

Uploading .pio\build\STM32L082KZ\firmware.elf
xPack OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev (2019-07-17-11:28)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
debug_level: 1

srst_only separate srst_nogate srst_open_drain connect_deassert_srst

Error: init mode failed (unable to connect to the target)
in procedure ‘program’

  • OpenOCD init failed *
    shutdown command invoked

*** [upload] Error 1

Yes, this very much looks as if the OpenOCD settings for resetting the MCU do not match the PCB.

Try different settings like:

reset_config none separate
1 Like

To be changed in the .cfg board / target file that openocd is invoked with. Check pio run -v -t upload for a “Verbose Upload” to see the openocd invocation.

1 Like

This is great - we got it working now without having to press NRST

1.cfg file updated (located in .platformio\packages\tool-openocd\scripts\board)
2. Now we get the following output

Uploading .pio\build\STM32L082KZ\firmware.elf
xPack OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev (2019-07-17-11:28)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
debug_level: 1

target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x080007a8 msp: 0x20005000
STM32L0: Enabling HSI16

  • Programming Started *
  • Programming Finished *
  • Verify Started *
  • Verified OK *
  • Resetting Target *
    shutdown command invoked