[Solved] STM32 debugging if SWD is used as GPIO - Page 1
Forum section: electronics / general

author: blueskull
author_rank: Unknown
timestamp: April 15, 2016, 02:51:05 am
content: I'm designing a custom PCB incorporating an STM32F070. I do not have to do this, but I am just curious if I released PA13 and PA14 from SWD controller, how do I program the chip?Can the chip be programmed under reset conditions? Or do I have to pull BOOT0 up to force my user program from being executed?

author: ade
author_rank: Unknown
timestamp: April 15, 2016, 03:18:08 am
content: Yes hence a typical SWD connector will have a reset line in addition to clock and data (plus power and ground). Or you can use an alternative bootloader (e.g., via UART).

author: ade
author_rank: Unknown
timestamp: April 15, 2016, 03:36:06 am
content: Yes those five... reset is optional but useful for the scenario you've described.SWO is the other common pin, useful for real-time tracing (via Serial Wire Viewer) if your IDE supports it and you can spare the pin. E.g., the IDE variable "watch" function works over SWO... you can also stream your own data using SWO I believe.

author: ade
author_rank: Unknown
timestamp: April 15, 2016, 05:56:18 am
content: Ah, I believe you're right. Coincidentally I just got a whole bunch of STM32F070s delivered to me (box still unopened), TSSOP-20 package... maybe I'll make a ghetto board this weekend to get more familiar with this part.

author: Brutte
author_rank: Frequent Contributor
timestamp: April 15, 2016, 08:23:08 am
content: Quote from: ade on April 15, 2016, 03:36:06 amTinies do not have SWO.Also target voltage is not really necessary if the target is powered from some external supply. The nRESET line is not needed if you have a reset button on-board as you can connect to a uC that is kept under reset. Alternatively you can insert a delay at power-up so that the SWD pins are in their default state for a fraction of a second - this is enough for a debugger to overtake control and halt the core before it executes the GPIO reconfiguration.

author: Jeroen3
author_rank: Super Contributor
timestamp: April 15, 2016, 08:41:55 am
content: I think some programmers even use the target voltage for their output buffers to perform level shifting.

author: Brutte
author_rank: Frequent Contributor
timestamp: April 15, 2016, 08:49:01 am
content: Quote from: blueskull on April 15, 2016, 08:36:21 amThe BOOT0 is only for pointing the uC on where to start from when it has no debugger connected. When the debugger is connected then you can keep the uC under reset as long as you want to and start from where you want to, not necessarily from where boot pins indicate.

author: bingo600
author_rank: Super Contributor
timestamp: April 15, 2016, 01:44:56 pm
content: I have used a design where there was a 500ms boot delay , before switching (disabling) the jtag-pins, and reuse them for io.Then there was no issue "activating jtag" before it got disabled./Bingo

author: ade
author_rank: Unknown
timestamp: April 15, 2016, 02:52:40 pm
content: It's a matter of convenience I think. By having NRST, programming can happen anytime without needing to first plug/unplug power or manually pressing the reset button and get the timing right. When you're coding + debugging + flashing all day long, every day, each additional step gets really annoying.For a production board the answer might be different...

author: mikerj
author_rank: Super Contributor
timestamp: April 15, 2016, 03:36:24 pm
content: I had this problem on a product using an STM32F103. Switching the SWD pins into GPIO via the firmware disconnected the debugger, so I had to make the firmware check if a debugger was attached before changing the pin functions. I don't know if this is required with the STM32F070 however.

author: Brutte
author_rank: Frequent Contributor
timestamp: April 15, 2016, 05:35:55 pm
content: Quote from: ade on April 15, 2016, 02:52:40 pmDefinitely, I would not do a development on TSSOP-20.