New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could assert_srst be forced for stm32l0? #386
Comments
Asserting SRST automatically will inhibit connecting to a crashed CPU with crashed program. Wiping out the program state by a reset by default is not a good idea. So I think active user intervention (assert_srst=scan) is a good compromise. Doesn't https://github.com/blacksphere/blackmagic/blob/master/src/target/adiv5.c#L417-L419 time out after 2 or maybe 2 * 20 seconds? Did you try implementing your suggestion? |
I'm seeing a related issue. I have an stm32l0 that mostly sits in stop mode and briefly wakes up every 2 seconds. I set
The pgm I'm running sits in stop mode for 2 seconds, then wakes up and prints something on the uart. Looking at the uart output I noticed that the swdp_scan causes a reset as expected. But after the scan the program continues and by the time I type the attach command the MCU is back in stop mode. |
Well, there is a time-out, but that doesn't help if it's not triggered :-). What I'm seeing right now is that |
Thorsten, was your last comment already with #391 applied? If not , your analysis "So somehow the write to bring power up didn't work (not sure why yet)" correlates good to the STM32 remark about the needed two additional SWD cycles:"This is particularly important when writing the CTRL/STAT for a power-up request. If the next transaction (requiring a power-up) occurs immediately, it will fail." |
Yes, I had the extra idle cycles. Even increased it to 4 just to see. I spent a couple of hours troubleshooting, attaching scope and manually verifying the bits, adding debug printf's. It all looked correct, but the chip just didn't actually power up the domains. When I reached a dead end a lightbulb went on and I power cycled the thing. Guess what, it worked right away w/out any code change and repeatedly. So there are funny states that don't get reset by the reset line, only by power cycle. Argh! |
Yes, many debug related registers are only reset by Power Up. Are your problems now solved? |
Dunno yet, I have to unwind a pile of debug stuff :-). Also, I noticed that the bit banging in swdptap.c isn't that great. For example, the way the 'out' functions are written the set-up time of swdio before swclk rising is very short. With imperfect debug cables there is extremely little room for reflections or x-talk. Is there a reason you keep swdclk idle low, instead of keeping it idle high which would allow you to increase the set-up time considerably without slowing things down? |
@tve any updates on this? Were you able to test more? As this issue is a bit stale, and the bitbanging did get some improvements since this was filed I will close this issue. If there is more work to be done here please feel free to reopen this issue with additional information. |
I've had a hell of a time scanning for STM32L0's that are in stop mode until I figured out I needed assert_srst=scan (introduced in 44fc24e). Is there a way to do this automatically?
What I notice is that if an STM32L0 is in stop mode and reset is not asserted the BMP hangs in https://github.com/blacksphere/blackmagic/blob/master/src/target/adiv5.c#L417-L419
But
adiv5_dp_init
is called from https://github.com/blacksphere/blackmagic/blob/master/src/target/adiv5_swdp.c#L81 at which point the device IDCODE is known, could that be used to determine whether srst is required?I assume there are use-cases where the MCU is not in stop mode and someone wants to connect without resetting it. So perhaps at least the wait-for-ack could have a time-out and print the suggestion to use assert_srst ?
The text was updated successfully, but these errors were encountered: