Author Topic: STM3F0 debug probe connection on-the-fly  (Read 2210 times)

0 Members and 1 Guest are viewing this topic.

Offline WarhawkTopic starter

  • Frequent Contributor
  • **
  • Posts: 821
  • Country: 00
    • Personal resume
STM3F0 debug probe connection on-the-fly
« on: January 17, 2018, 07:11:53 am »
Hello everyone,
I use STM32 my first time and have been wondering if there is a chance to connect to the MCU with a debug probe on-the-fly without stopping code execution or resetting the chip.
I have a module with the MCU connected to a host system, which gives the module a special startup sequence (and also power) in order to start the code.
I would need to wait until everything "boots" and then connect the debug probe to the MCU to read (and modify) a couple of variables.

I use Keil uVision v5, Discovery kit and my own PCB with the MCU. I use all SWD wires and can't connect with different settings other than "connect under reset".

If that does not work, I'll do UART.

Thanks for any hint.


PS: Great IC, but documentation, libraries and information consistency is  |O



Online ataradov

  • Super Contributor
  • ***
  • Posts: 11236
  • Country: us
    • Personal site
Re: STM3F0 debug probe connection on-the-fly
« Reply #1 on: January 17, 2018, 07:47:02 am »
Technically it is possible, whether Keil supports it, I don't know, but it may be worth keeping trying.
Alex
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3237
  • Country: gb
Re: STM3F0 debug probe connection on-the-fly
« Reply #2 on: January 17, 2018, 08:33:46 am »
It's been a while since I've used an STM32 but I had to do exactly this on an ADuCM320 recently, using Keil.  I tried every single option, and the only way that worked for me was selecting hardware reset but leaving the hardware reset pin of the debugger disconnected.  It would then reliably connect without resetting the target. YMMV of course.
 

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 895
  • Country: us
Re: STM3F0 debug probe connection on-the-fly
« Reply #3 on: January 17, 2018, 06:38:25 pm »
Making a physical connection on the fly seems risky. Whenever I try that (on STM32 boards) the board almost always seems to reset.

Once you've got the electrical connection, it's certainly possible to allow the mcu to run and then break in whenever you want.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11236
  • Country: us
    • Personal site
Re: STM3F0 debug probe connection on-the-fly
« Reply #4 on: January 17, 2018, 06:41:32 pm »
Making a physical connection on the fly seems risky. Whenever I try that (on STM32 boards) the board almost always seems to reset.
That is something wrong with the hardware design. Attaching to a running target is one of the advertised features of the Cortex-Mx family.

I have not tried this with ST chips, but it works very reliably with Atmel/Microchip chips. I do that very often, it is a very helpful thing when debugging wireless network software, which typically runs on many devices to form a network.
Alex
 

Offline WarhawkTopic starter

  • Frequent Contributor
  • **
  • Posts: 821
  • Country: 00
    • Personal resume
Re: STM3F0 debug probe connection on-the-fly
« Reply #5 on: January 17, 2018, 07:01:29 pm »
Making a physical connection on the fly seems risky. Whenever I try that (on STM32 boards) the board almost always seems to reset.
That is something wrong with the hardware design. Attaching to a running target is one of the advertised features of the Cortex-Mx family.

I have not tried this with ST chips, but it works very reliably with Atmel/Microchip chips. I do that very often, it is a very helpful thing when debugging wireless network software, which typically runs on many devices to form a network.

I second that. My colleagues and I used this feature on SAM3U (CM3) successfully.

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3785
  • Country: de
Re: STM3F0 debug probe connection on-the-fly
« Reply #6 on: January 17, 2018, 08:56:57 pm »
No idea about Keil, don't use it, but OpenOCD has no issues with connecting to an already running STM32. Just once it connects you get a warning message that the target is running already, so debugging could be iffy due to the uncertain state of the CPU.

I have done this (minus the probe hotplugging - it is safer to connect the probe with the power off) to debug various hangs. MCU not responding, I fired up OpenOCD/gdb, sent a break command and checked where is the firmware stuck from the backtrace.
 

Offline lucazader

  • Regular Contributor
  • *
  • Posts: 221
  • Country: au
Re: STM3F0 debug probe connection on-the-fly
« Reply #7 on: January 18, 2018, 05:37:22 am »
Definitely can be done.

I dont tend to try this with the likes of keil or other IDE's.

One of the best tools that i have found for the stm32 chips of run time debugging is STMstudio (made by st).
This program AFAIK can only connect to a chip on the fly.

Basically it can gives you a live text or graph read out of any variable in ram.
You cant use it to set break points and step through code, but for projects such as motor control it has been invaluable for tuning the PID loops.
Much easier and less overhead than uart debugging. Requires no additional code, just compile for debug and you can open up the elf file and import variables to watch.
 

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 895
  • Country: us
Re: STM3F0 debug probe connection on-the-fly
« Reply #8 on: January 18, 2018, 05:49:31 pm »
Making a physical connection on the fly seems risky. Whenever I try that (on STM32 boards) the board almost always seems to reset.
That is something wrong with the hardware design. Attaching to a running target is one of the advertised features of the Cortex-Mx family.

I have not tried this with ST chips, but it works very reliably with Atmel/Microchip chips. I do that very often, it is a very helpful thing when debugging wireless network software, which typically runs on many devices to form a network.
It might have something to do with my daily caffeine intake. :P Shaky hands.
 

Offline WarhawkTopic starter

  • Frequent Contributor
  • **
  • Posts: 821
  • Country: 00
    • Personal resume
Re: STM3F0 debug probe connection on-the-fly
« Reply #9 on: January 22, 2018, 07:41:13 pm »
Thanks for the tip with STMstudio, I am just downloading it.  :)

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: STM3F0 debug probe connection on-the-fly
« Reply #10 on: January 23, 2018, 10:23:59 am »
Yes you can. But I couldn't get it to work with an ST-Link, have done it countless times with ULink an JLink.
http://www.keil.com/support/docs/3697.htm
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3785
  • Country: de
Re: STM3F0 debug probe connection on-the-fly
« Reply #11 on: January 24, 2018, 08:33:51 pm »
Yes you can. But I couldn't get it to work with an ST-Link, have done it countless times with ULink an JLink.
http://www.keil.com/support/docs/3697.htm

For me it worked fine with a cheap ST-Link clone too, using OpenOCD. It is not a ST-Link problem.
 

Offline WarhawkTopic starter

  • Frequent Contributor
  • **
  • Posts: 821
  • Country: 00
    • Personal resume
Re: STM3F0 debug probe connection on-the-fly
« Reply #12 on: January 28, 2018, 01:11:01 pm »
Just a quick follow-up.
I could not achieve the desired functionality using Keil and STlink on the discovery board. No matter what I do it always halts the CPU, at least. That's practically that they say here:
http://www.keil.com/support/docs/3697.htm

I use STM32 studio and it does what I want. Thanks for the tip!


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf