1
\$\begingroup\$

I have an STM32L476RG on a custom board that I have to leave connected to an external ST-Link/V2 so that I can reprogram it without accessing the hardware. I'm also forced to do this via a USB hub due to my limited number of available outputs.

Right now the MCU runs when the hub (and in turn the ST-Link) is powered via a connection to a computer. I'm searching for a way to make it run when the hub isn't powered, however.

I've found some information here regarding the NRST pin, however I only have one ST-Link at the moment and I'd like to avoid messing with it until I've exhausted other options. I should add that its in SWD mode and that I'm also using a 10-to-20 pos JTAG adapter.

Finally, my firmware is largely based on FreeRTOS. A software solution would be ideal if someone can suggest how to do that.

\$\endgroup\$
  • \$\begingroup\$ I do run MCU wiithout removing the programmer. I have isolated NRST pin from STLink. Just select, RESET after programming option and it should be okay \$\endgroup\$ – Umar Aug 28 at 15:37
  • 1
    \$\begingroup\$ Is this an XY Problem? Is your real issue that you need to load new application code to the thing in-circuit? If you just want to update software, but don't need to debug it, then you should be using some sort of a bootloader. \$\endgroup\$ – TimWescott Aug 28 at 16:32
  • 1
    \$\begingroup\$ The purpose is to develop the software while testing it, so I will need to debug it. \$\endgroup\$ – Zurn Aug 28 at 17:12
1
\$\begingroup\$

Option 1: Disconnect NRST pin from the debug connector on target board. Works okay for me. Unless you do not use sleep modes, it should be fine. Be ready for very rare need of Power Resets still.

Option 2: Use a analog Switch to cut all the JTAG and NRST lines when you don't need them to the connected to the target. When you power the hub there are ways to enable this analog Switch (or Buffer) and when you remove the hub, it can get automatically disabled. Disabling the buffer (or Analog Switch) will keep boh target and STLINK isolated.

my firmware is largely based on FreeRTOS. A software solution would be ideal if someone can suggest how to do that.

Not a good idea because, this will become a case of dog trying to bite its tail case.

Further worked solution from OP:

had to change the stm32l4discovery.cfg file from "reset_config srst_only" to "reset_config srst_nogate

\$\endgroup\$
  • \$\begingroup\$ Removing the NRST pin has solved the issue of running without the ST-Link powered, but now it won't flash/debug new code onto the MCU from my IDE (Eclipse)... is there a setting I need to change? I'm getting the same Eclipse error that I would get when I accidentally forget to disconnect ST Link Utility from the target ("Error erasing flash with vFlashErase packet"). \$\endgroup\$ – Zurn Aug 28 at 17:32
  • \$\begingroup\$ @Zurn I have tried with STM32L and STM32F family. It always works. Perhaps, try enabling connect under reset or other options. Also. Check again, whether remounting NRST works for programming. \$\endgroup\$ – Umar Aug 28 at 18:07
  • \$\begingroup\$ I got it, same idea but had to go a littler deeper than that: had to change the stm32l4discovery.cfg file from "reset_config srst_only" to "reset_config srst_nogate". Works now thanks a lot. \$\endgroup\$ – Zurn Aug 28 at 18:24
0
\$\begingroup\$

SWD with STLINK/V2 should only need clock, data, ground and supply. Disconnect the NRST pin from the flat cable somehow, snip the flat cable or connector pin.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.