Skip to content
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

OpenOCD and GDB keep failing randomly during debug sessions #84

Open
getreu opened this issue Sep 17, 2017 · 5 comments
Open

OpenOCD and GDB keep failing randomly during debug sessions #84

getreu opened this issue Sep 17, 2017 · 5 comments

Comments

@getreu
Copy link
Contributor

getreu commented Sep 17, 2017

After running the "concurrency" example, the STLink communication gets unstable. The only way to connect is keeping the reset button hold while starting openocd. As soon as I release reset the connection breaks down:

Polling target stm32f3x.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 6300ms
Info : Previous state query failed, trying to reconnect  
Error: jtag status contains invalid mode value - communication failure

A similar symptom and its solution is described here:
Error: jtag status contains invalid mode value – communication failure = SOLVED! – Jara's Spare Time Electronics

Finally I found this message in a discussion forum. The problem is in the low-power mode! When CPUcore clock is halted the debugger connection fails and debug session is halted.

I am using low-power mode to halt CPU clock when OS is idle – in vApplicationIdleHook() function I have the __WFI() – wait for interrupt – intrinsic function.

DBGMCU_Config(DBGMCU_SLEEP \| DBGMCU_STOP \| DBGMCU_STANDBY, ENABLE);
-- | --

@getreu
Copy link
Contributor Author

getreu commented Sep 19, 2017

Workaround:

  1. Keep the reset button pressed while connecting with openocd.
  2. Build your program in debug mode, sometimes it also helps to comment out the rtfm::wfi(); instruction.
  3. In arm-none-eabi-gdb type load and release reset.

I also updated the bootloader, but I did not notice any influence.

@japaric
Copy link
Owner

japaric commented Sep 20, 2017

Keep the reset button pressed while connecting with openocd.

I think there's an option for this (reset upon connection) on OpenOCD but the RST (?) line of the microcontroller has to be connected to the hardware debugger.

From the linked blog post:

The solution is either to entirely disable low-power modes, or allow low-power debugging in the DBGMCU_CR register:

It might be possible to do this in .gdbinit (using monitor commands to make OpenOCD do the register manipulation) though I'm not sure how portable DBGMCU is.

@getreu
Copy link
Contributor Author

getreu commented Sep 22, 2017

It would be very useful to find a suitable way to set the DBGMCU register. My above workaround only works when you compile the binary in debug mode. Seeing that the binaries compiled in debug mode are 10-20 times bigger my method is limited to very simple programs.

@getreu
Copy link
Contributor Author

getreu commented Sep 23, 2017

I discovered that some people experience the same issue with the blue-pill board:
blinky program bricked Blue-pill · Issue #20 · japaric/blue-pill. Surprisingly with this board I can not reproduce the issue.

@bergus
Copy link

bergus commented May 15, 2018

No description provided.

colosimo added a commit to colosimo/kim-os that referenced this issue Dec 3, 2019
Temporarly disabled sleep (Low Power Mode), because something similar
to this issues is occurring:

japaric/f3#84
http://www.jsykora.info/2014/10/error-jtag-status-contains-invalid-mode-value-communication-failure-solved/

Signed-off-by: Aurelio Colosimo <[email protected]>
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

3 participants