Skip to content

Hangs when OpenOCD isn't connected #1

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

Closed
cs2dsb opened this issue Jan 29, 2020 · 4 comments
Closed

Hangs when OpenOCD isn't connected #1

cs2dsb opened this issue Jan 29, 2020 · 4 comments

Comments

@cs2dsb
Copy link
Owner

cs2dsb commented Jan 29, 2020

There are some checks to make sure ITM is enabled before attempting to wait on the FIFOs but these aren't sufficient, this still causes the device to hang if OpenOCD hasn't done whatever it does when you first connect it.

@diondokter
Copy link

Yeah, only when a debugger is connected will it not hang.

You can luckily check that: https://docs.rs/cortex-m/0.6.2/cortex_m/peripheral/struct.DCB.html#method.is_debugger_attached

What you could do is check it just before you want to log to the ITM. If it's false, then don't log.

@cs2dsb
Copy link
Owner Author

cs2dsb commented Apr 21, 2020

Yeah, only when a debugger is connected will it not hang.

You can luckily check that: https://docs.rs/cortex-m/0.6.2/cortex_m/peripheral/struct.DCB.html#method.is_debugger_attached

What you could do is check it just before you want to log to the ITM. If it's false, then don't log.

I'm not sure this is actually possible in a reliable way across multiple cortex-m devices. See rust-embedded/cortex-m#82 (comment) and the few comments back and forth after it.

I'd love to be proved wrong but in my experiments on the bluepill hardware is_debugger_attached and the other registers mentioned in the above issue couldn't reliably determine if it was safe to log or not.

@diondokter
Copy link

diondokter commented Apr 21, 2020

Haven't used it on the blue pill.

But I've worked on the ATSAML4 (SWD with JLink), STM32F4 and the STM32F7 (both SWD with STLink) and it worked reliably there. I'll soon be able to check it for the STM32H7 with JTAG.
I didn't know it doesn't always work. That's pretty annoying if true.

What can be done is to make a feature gate for it. You can then turn the check on if you know that it works for your setup and leave it off if you know that it doesn't.

@cs2dsb
Copy link
Owner Author

cs2dsb commented Apr 21, 2020

I'll redo my testing around it because based off re-reading the thread it appears if you check debugen and the itm enable registers that should work for all except the m0 which would be a good subset to support the checks on.

I had most of the checks implemented in this crate at one point so I don't know why I didn't add the debugen check and be done with it at that time.

@cs2dsb cs2dsb closed this as completed Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants