Author Topic: [Solved] STM32 debugging if SWD is used as GPIO  (Read 11714 times)

0 Members and 1 Guest are viewing this topic.

Offline blueskullTopic starter

  • Supporter
  • ****
  • !
  • Posts: 367
  • Country: cn
  • BA7LKP
[Solved] STM32 debugging if SWD is used as GPIO
« on: April 15, 2016, 02:51:05 am »
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?
« Last Edit: April 15, 2016, 06:10:40 am by blueskull »
 

Offline ade

  • Supporter
  • ****
  • Posts: 231
  • Country: ca
Re: STM32 debugging if SWD is used as GPIO
« Reply #1 on: April 15, 2016, 03:18:08 am »
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).
 
The following users thanked this post: blueskull

Offline ade

  • Supporter
  • ****
  • Posts: 231
  • Country: ca
Re: STM32 debugging if SWD is used as GPIO
« Reply #2 on: April 15, 2016, 03:36:06 am »
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.
 

Offline ade

  • Supporter
  • ****
  • Posts: 231
  • Country: ca
Re: STM32 debugging if SWD is used as GPIO
« Reply #3 on: April 15, 2016, 05:56:18 am »
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.
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: STM32 debugging if SWD is used as GPIO
« Reply #4 on: April 15, 2016, 08:23:08 am »
SWO is the other common pin, useful for real-time tracing
Tinies 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.
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: [Solved] STM32 debugging if SWD is used as GPIO
« Reply #5 on: April 15, 2016, 08:41:55 am »
I think some programmers even use the target voltage for their output buffers to perform level shifting.
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: STM32 debugging if SWD is used as GPIO
« Reply #6 on: April 15, 2016, 08:49:01 am »
I will include test pads on PCB for BOOT0 and nRST.
The 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.
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
Re: [Solved] STM32 debugging if SWD is used as GPIO
« Reply #7 on: April 15, 2016, 01:44:56 pm »
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
 

Offline ade

  • Supporter
  • ****
  • Posts: 231
  • Country: ca
Re: [Solved] STM32 debugging if SWD is used as GPIO
« Reply #8 on: April 15, 2016, 02:52:40 pm »
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...
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3237
  • Country: gb
Re: [Solved] STM32 debugging if SWD is used as GPIO
« Reply #9 on: April 15, 2016, 03:36:24 pm »
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.
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: [Solved] STM32 debugging if SWD is used as GPIO
« Reply #10 on: April 15, 2016, 05:35:55 pm »
For a production board the answer might be different...
Definitely, I would not do a development on TSSOP-20.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf