Electronic – How to run an STM32L with an unpowered ST-Link connected

freertosmicrocontrollerst-linkstm32swd

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.

Best Answer

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

Related Topic