-1

Connection:

Hi I use STM32G031J6M6. Connection:

enter image description here enter image description here

Why i can load firmware to mcu only once? After programing Stm32CubeIde can't connect to mcu. I have to erase the chip using "STM32 ST-LINK Utility" every time when i need to load new firmware.

I use "ST-Link V2 mini":

enter image description here

Sem
  • 45
  • 5
  • 3
    Your firmware likely reconfigures PA14 from the initial SWCLK to USART1_TX right at the start, possibly turning off the serial wire protocol completely. This will make it hard to reconnect again. Typically, you will need to hold the device in reset to connect. ST-Link Utility can do it. But I'm not familiar with STM32CubeIDE. It might offer a similar option. – Codo Jul 30 '23 at 09:51
  • 1
    with the stm32g parts they only go into the bootloader automatically if the flash (vector table) is erased. after that you cannot get there with boot0 and reset like other parts. unless... you change some non volatile bits. clearly the bootloader is on its way out and like other vendors, swd is the way forward. if the st-link can get in that means swd is available. if the cube ide cant figure that out that is very strange but an ide problem or ide setting problem. (or it may be as mentioned an illegal/incompatible clone). – old_timer Jul 30 '23 at 17:09
  • 1
    you can run a program (has to be a program) that can modify the non volatile config registers so that the uart interface works like all the prior generations of stm32 parts. if that is the interface you are using,.. you are not clear on the interface you are after, but it appears not to be swd. – old_timer Jul 30 '23 at 17:11
  • The solution: connect pin 18 (Reset) of the programmer (with original stm32f103c8t6) mcu to pin 4 of stm32g031j6m6 through a 220 ohm resistor. Reset line required. – Sem Jul 30 '23 at 19:15

1 Answers1

2

To program this micro you need to use something which has NRST line as well. Unfortunately, those Chinese fake ST-Links (BTW illegal) do not support the "connect under reset" required in this case.

The solution.

  1. Bin your fake ST-Link
  2. Buy a genuine one - they are not expensive. Do not try to buy cheap - use authorized distributors.

I use "ST-Link V2 mini":

No, you use an illegal Chinese fake copy with stolen firmware.

0___________
  • 60,014
  • 4
  • 34
  • 74
  • The OP seems to be able to connect to the device using STM32 ST-LINK Utility. Most likely, he/she isn't using a different debug adapter. So the hardware doesn't explain it all. – Codo Jul 30 '23 at 15:59
  • @Codo it does explain all. If your program changes the mode of the SWD pins you need to connect under reset. OPs debug probe has to be able to handle this mode. Those chineese probes **do not** support it. – 0___________ Jul 30 '23 at 16:23
  • if using the uart interface, then a stock stm32g you get one shot at that, then it doesnt work with stock settings. yet swd will work. OP needs to provide more info. – old_timer Jul 30 '23 at 17:12
  • @old_timer he even posted the picture of the debug probe :) – 0___________ Jul 30 '23 at 17:21
  • @Sem "funny"? It simply does not work and uses stolen ST-Link firmware. Make yourself a favour and buy https://uk.farnell.com/stmicroelectronics/stm32g0316-disco/discovery-kit-arm-cortex-m0/dp/3247675?cjevent=06de95822f0f11ee834c03fb0a18b8fa&cjdata=MXxZfDB8WXww&CMP=AFC-CJ-UK-8989328&gross_price=true&source=CJ You can the main part of this board as as proper STM32 debug probe (not only for this micro) – 0___________ Jul 30 '23 at 19:28
  • yeah, adafruit and everyone else sells that probe as well as ones called jlink, etc, they are just swd probes like the stm32 nucleo frontends, doesnt matter, its an swd device. – old_timer Jul 30 '23 at 22:38
  • the stm32g you get one uart then swd from there on out. until you erase the vector table on the uart. that is one way to match the question. – old_timer Jul 30 '23 at 22:39
  • the stlink protocol and derived products have been there since the beginning of cortex-m (predating stm32s) – old_timer Jul 30 '23 at 22:43
  • @old_timer st-link is a STM SWD probe. Chineese copies use stolen STM probe software. 2. I am not responsible for Adafruit offer. 3. j-link is a very high quality probe (edu is limited functionality version). J-link is also copied by far east manufacturers. Segger is trying to protect its IP by disabling illegal copies in new software releases. – 0___________ Jul 30 '23 at 23:05
  • stlink protocol was open source from day one. github repo pulled into openocd etc. well before the stm32 folks got involved. – old_timer Jul 30 '23 at 23:18
  • @old_timer there is nothing like st-link protocol. There is SW protocol and Jtag. They are open and well documented. The debug probe firmware implementation is proprietary software. Open source is CMSIS-DAP library providing very simple and slow implementation of the probe. – 0___________ Jul 30 '23 at 23:21
  • none of this is relevant to a single time programming of an stm32g – old_timer Jul 30 '23 at 23:22
  • @old_timer openOCD is a completely different piece of software - it is open-source gdbserver-like software. This software communicates with probe - and it needs to know how to communicate with the particular one. You use gdb to connect to openOCD and openOCD communicate with the probe. – 0___________ Jul 30 '23 at 23:24
  • I never use gdb of course I telnet into openocd. but this does not explain the one time programming – old_timer Jul 30 '23 at 23:25
  • can use a ftdi mpsse part, or whatever bit banger you want, open source, early days – old_timer Jul 30 '23 at 23:25
  • @old_timer it is as this probe does not use reset line needed to connect under reset. You need to connect under reset if the pin used by the SWD interface is being reprogrammed by the firmware. So first time you can program - second tone not as SWD does not have access to the pins. You need to have a probe which controls the NRST pin – 0___________ Jul 30 '23 at 23:26
  • none of this is relevant to one time vs two time programming – old_timer Jul 30 '23 at 23:26
  • @old_timer do you know why sometimes you need to use "connect under reset"? If not stop commenting. – 0___________ Jul 30 '23 at 23:27
  • as with you I have been using all of the devices since luminary micro, bought the clones, stlink, jlink, real jlinks, ftdi solutions, bit bang without mpsse, discovery, nucleo, all of it. tried them on most brands using cortex-ms. stm32gs are a specific and scary turning point for st if that is not relevant here, fine. – old_timer Jul 30 '23 at 23:32
  • @old_timer do you know why sometimes it is necessary to connect under reset? This is relevant here. And the probe OP has does not provide this functionality. https://mcu4edu.pl/wp-content/uploads/2013/06/CD00262073-1.pdf – 0___________ Jul 30 '23 at 23:45
  • in these decades I have never needed to connect reset to the debugger, countless devices. power cycle resets. sure I do not disconnect the reset on the nucleo/discovery boards. but dont use swd on those (other than demonstration purposes). I very much understand the concept of reset or power cycle. – old_timer Jul 31 '23 at 00:20
  • yes that specific debugger is not one you want to use. real jlink, clone jlnk, nucleo frontend. or ftdi breakout. – old_timer Jul 31 '23 at 00:22
  • @old_timer so why all those comments? Is my answer relevant? If yes, delete all the comments – 0___________ Jul 31 '23 at 00:26
  • @0___________ Yes, Your answer helped me solve the problem. Thank you very much. Reset line required. – Sem Jul 31 '23 at 06:31