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

[reset] Unable to reset board in gdb #254

Closed
dflogeras opened this issue Aug 4, 2014 · 10 comments · Fixed by #712
Closed

[reset] Unable to reset board in gdb #254

dflogeras opened this issue Aug 4, 2014 · 10 comments · Fixed by #712

Comments

@dflogeras
Copy link
Contributor

dflogeras commented Aug 4, 2014

I am using ChibiOS-2.6.5 and attempting to integrate the CMSIS library for DSP functionality.

My board is a STM32F407-Discovery and my toolchain was generated using Gentoo's crossdev package, with the following:
gcc-4.7.3 (compiled arm-hardfloat-eabi)
binutils-2.23.2
newlib-2.0.0
gdb-7.6.2

So far, the process of compile, flash, debug, repeat has worked great on this, as well as another project using a STM32L151 chip.

After adding linking the CMSIS library into my project, I have found that I cannot debug reliably. If I attach to the gdb server, it will often be in the ChibiOS unhandled_exception() handler, or maybe __gnu_unwind_execute(), I assume after hitting an exception condition.

Oddly though, I cannot reset the board in gdb with kill/run. Doing so ends up right where it was before, even with a breakpoint in the ResetHandler() function. Even pressing the reset button on the devkit doesn't reset it. I have to use 'load' with gdb, sometimes pressing the reset button while loading the firmware before it works fully.

I am wondering if this is a known issue, and if there is anything I can do to debug or work around it?

@xor-gate
Copy link
Member

Please test against v1.2.0 or master and report if the problem still exists.

@dflogeras
Copy link
Contributor Author

dflogeras commented May 17, 2016

I can reliably debug with my current toolchain and stlink on a STM32F4 CMSIS project. Unfortunately I cannot easily go back to the toolchain I had 2 years ago, but I doubt it has much value.

I did notice while testing that doing a kill/run in gdb would produce:

Starting program: /home/dave/ChibiOS_3.0.5/stm32f4_test/build/ch.elf 
inferior.c:361: internal-error: find_inferior_pid: Assertion `pid != 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

I found that I can:

a. Instead of kill/run, I can kill, then "target remote :4242" to re-attach and it is waiting for me in ResetHandler()
b. Upgrade gdb from 7.10.1 to 7.11 and the issue seems to go away

Is this expected?

@xor-gate
Copy link
Member

xor-gate commented May 17, 2016

Thank you for testing, that is a good answer. I have currently no clue what is expected (by others) and why it is solved by using gdb 7.11. I have seen similar problems when running under ChibiOS RTOS also under OpenOCD. This needs more investigation by others who may or may not reproduce the problem.

@rewolff
Copy link
Contributor

rewolff commented May 21, 2016

To me: "even pressing the reset button doesn't reset it" is a red flag. The hardware reset should always work.

What possibly might not be working is that the debugger catches the processor as it comes out of reset. In that case Chibios will be crashed in "unhandled exception" before you get to move your finger from the reset button to your keyboard.

@xor-gate
Copy link
Member

You are right, I have no clue how OpenOCD handles this nicely. Again the gdb-stubs in stlink are in a very bad shape currently (as you know yourself).

@xor-gate xor-gate added this to the Unplanned (Contributions Welcome) milestone Dec 25, 2016
@stlink-org stlink-org locked and limited conversation to collaborators Dec 30, 2016
@Nightwalker-87 Nightwalker-87 modified the milestones: Unplanned (Contributions Welcome), Next Feb 19, 2020
@Nightwalker-87 Nightwalker-87 removed this from the General milestone Feb 21, 2020
@stlink-org stlink-org unlocked this conversation Mar 17, 2020
@Nightwalker-87 Nightwalker-87 modified the milestones: d) Reset issues, v1.6.2 Oct 22, 2020
@Nightwalker-87 Nightwalker-87 changed the title [reset] Unable to reset board [reset] Unable to reset board in gdb Mar 10, 2021
@stlink-org stlink-org deleted a comment from rewolff Mar 22, 2021
@stlink-org stlink-org deleted a comment from rewolff Mar 22, 2021
@Nightwalker-87 Nightwalker-87 pinned this issue Mar 22, 2021
@Nightwalker-87 Nightwalker-87 unpinned this issue Mar 23, 2021
@stlink-org stlink-org deleted a comment from rewolff Mar 25, 2021
@Nightwalker-87 Nightwalker-87 modified the milestones: v1.6.2, Old issues Mar 25, 2021
@Ant-ON
Copy link
Collaborator

Ant-ON commented Mar 31, 2021

@Nightwalker-87
I think it can be closed by #1071
The problem is most likely due to the reset pin not being connected. In older versions of the st-util, the reset through the SWD was not implemented

@Nightwalker-87 Nightwalker-87 modified the milestones: Old issues, v1.6.2 Mar 31, 2021
@Nightwalker-87 Nightwalker-87 linked a pull request Apr 4, 2021 that will close this issue
@Nightwalker-87 Nightwalker-87 modified the milestones: v1.6.2, v1.5.1 Apr 4, 2021
@Nightwalker-87
Copy link
Member

The observed behaviour obviously derived from the following issues:

With this conclusion based on a final review of the related topic we can safely close this ticket as resolved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.